blob: 422074cd4a7cf5e4f40bcb938d43e30da7c49525 [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
andrewsbrown4dddd472015-04-01 14:28:46 -070016import net.named_data.jndn.Data;
andrewsbrown86088d72015-05-07 01:38:29 +010017import net.named_data.jndn.Face;
andrewsbrown4dddd472015-04-01 14:28:46 -070018import net.named_data.jndn.Name;
andrewsbrown86088d72015-05-07 01:38:29 +010019import net.named_data.jndn.OnInterestCallback;
andrewsbrown4dddd472015-04-01 14:28:46 -070020
Andrew Brown85234ea2016-09-07 13:41:29 -070021import java.util.concurrent.ScheduledThreadPoolExecutor;
22
andrewsbrown4dddd472015-04-01 14:28:46 -070023/**
24 * Base interface for defining a server; see descendant interfaces for different
25 * modes of serving packets. This class extends {@link Runnable} expecting
26 * implementing classes to do any necessary event processing in the
27 * {@link Runnable#run()} block, thus allowing different ways to manage servers
28 * (e.g. single-thread vs {@link ScheduledThreadPoolExecutor}.
29 *
Andrew Brown85234ea2016-09-07 13:41:29 -070030 * @author Andrew Brown, andrew.brown@intel.com
andrewsbrown4dddd472015-04-01 14:28:46 -070031 */
andrewsbrown86088d72015-05-07 01:38:29 +010032public interface Server extends Runnable, OnInterestCallback {
andrewsbrown4dddd472015-04-01 14:28:46 -070033
34 /**
35 * @return the {@link Name} prefix this server is serving on.
36 */
Andrew Brown85234ea2016-09-07 13:41:29 -070037 Name getPrefix();
andrewsbrown4dddd472015-04-01 14:28:46 -070038
39 /**
andrewsbrownd4bc52a2015-04-02 10:47:53 -070040 * @return the registered prefix ID of the server on the {@link Face} or -1 if
41 * unregistered
42 */
Andrew Brown85234ea2016-09-07 13:41:29 -070043 long getRegisteredPrefixId();
andrewsbrownd4bc52a2015-04-02 10:47:53 -070044
45 /**
andrewsbrown4dddd472015-04-01 14:28:46 -070046 * Add a stage to the server pipeline. Each stage should be processed once the
47 * server has the {@link Data} packet available to send (e.g. after a callback
48 * has produced a packet); also, stages should be processed in the order they
49 * are added.
50 *
andrewsbrown13b11c52015-07-02 14:23:15 -070051 * @param stage a Data-to-Data processing stage
andrewsbrown4dddd472015-04-01 14:28:46 -070052 */
Andrew Brown85234ea2016-09-07 13:41:29 -070053 void addPostProcessingStage(ProcessingStage<Data, Data> stage);
andrewsbrown4dddd472015-04-01 14:28:46 -070054}