blob: 197a52ad507e3e432cb35bca6a05f3d54045cc2f [file] [log] [blame]
andrewsbrown4dddd472015-04-01 14:28:46 -07001/*
2 * jndn-utils
3 * Copyright (c) 2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 3, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
13 */
andrewsbrown13b11c52015-07-02 14:23:15 -070014package com.intel.jndn.utils;
andrewsbrown4dddd472015-04-01 14:28:46 -070015
16import java.util.concurrent.ScheduledThreadPoolExecutor;
17import net.named_data.jndn.Data;
andrewsbrown86088d72015-05-07 01:38:29 +010018import net.named_data.jndn.Face;
andrewsbrown4dddd472015-04-01 14:28:46 -070019import net.named_data.jndn.Name;
andrewsbrown86088d72015-05-07 01:38:29 +010020import net.named_data.jndn.OnInterestCallback;
andrewsbrown4dddd472015-04-01 14:28:46 -070021
22/**
23 * Base interface for defining a server; see descendant interfaces for different
24 * modes of serving packets. This class extends {@link Runnable} expecting
25 * implementing classes to do any necessary event processing in the
26 * {@link Runnable#run()} block, thus allowing different ways to manage servers
27 * (e.g. single-thread vs {@link ScheduledThreadPoolExecutor}.
28 *
29 * @author Andrew Brown <andrew.brown@intel.com>
30 */
andrewsbrown86088d72015-05-07 01:38:29 +010031public interface Server extends Runnable, OnInterestCallback {
andrewsbrown4dddd472015-04-01 14:28:46 -070032
33 /**
34 * @return the {@link Name} prefix this server is serving on.
35 */
36 public Name getPrefix();
37
38 /**
andrewsbrownd4bc52a2015-04-02 10:47:53 -070039 * @return the registered prefix ID of the server on the {@link Face} or -1 if
40 * unregistered
41 */
42 public long getRegisteredPrefixId();
43
44 /**
andrewsbrown4dddd472015-04-01 14:28:46 -070045 * Add a stage to the server pipeline. Each stage should be processed once the
46 * server has the {@link Data} packet available to send (e.g. after a callback
47 * has produced a packet); also, stages should be processed in the order they
48 * are added.
49 *
andrewsbrown13b11c52015-07-02 14:23:15 -070050 * @param stage a Data-to-Data processing stage
andrewsbrown4dddd472015-04-01 14:28:46 -070051 */
andrewsbrown13b11c52015-07-02 14:23:15 -070052 public void addPostProcessingStage(ProcessingStage<Data, Data> stage);
andrewsbrown4dddd472015-04-01 14:28:46 -070053}