andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 14 | package com.intel.jndn.utils; |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 15 | |
| 16 | import java.util.concurrent.ScheduledThreadPoolExecutor; |
| 17 | import net.named_data.jndn.Data; |
andrewsbrown | 86088d7 | 2015-05-07 01:38:29 +0100 | [diff] [blame] | 18 | import net.named_data.jndn.Face; |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 19 | import net.named_data.jndn.Name; |
andrewsbrown | 86088d7 | 2015-05-07 01:38:29 +0100 | [diff] [blame] | 20 | import net.named_data.jndn.OnInterestCallback; |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 21 | |
| 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 | */ |
andrewsbrown | 86088d7 | 2015-05-07 01:38:29 +0100 | [diff] [blame] | 31 | public interface Server extends Runnable, OnInterestCallback { |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * @return the {@link Name} prefix this server is serving on. |
| 35 | */ |
| 36 | public Name getPrefix(); |
| 37 | |
| 38 | /** |
andrewsbrown | d4bc52a | 2015-04-02 10:47:53 -0700 | [diff] [blame] | 39 | * @return the registered prefix ID of the server on the {@link Face} or -1 if |
| 40 | * unregistered |
| 41 | */ |
| 42 | public long getRegisteredPrefixId(); |
| 43 | |
| 44 | /** |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 45 | * 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 | * |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 50 | * @param stage a Data-to-Data processing stage |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 51 | */ |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 52 | public void addPostProcessingStage(ProcessingStage<Data, Data> stage); |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 53 | } |