blob: 8206e274a273820677d973c8d9c477d5831f01ba [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 */
14package com.intel.jndn.utils;
15
16import com.intel.jndn.utils.server.RespondWithData;
17import com.intel.jndn.utils.server.Server;
18import java.io.IOException;
19
20/**
21 * Defines the API for a {@link Server} producing {@link Data} packets
22 * dynamically; in other words, when an {@link Interest} arrives, this server
23 * will run a callback to determine what packet to send back. As good practice,
24 * keep callback methods as short as possible.
25 *
26 * @author Andrew Brown <andrew.brown@intel.com>
27 */
28public interface DynamicServer extends Server {
29
30 /**
31 * Set the callback method to run when an {@link Interest} packet is passed to
32 * this server. This method should either return a {@link Data} packet that
33 * satisfies the Interest or throw an Exception to avoid sending. Calling this
34 * method a second time should replace the callback.
35 *
36 * @param callback the callback instance
37 * @throws java.io.IOException if the server fails to register a prefix
38 */
39 public void respondUsing(RespondWithData callback) throws IOException;
40}