01: /*
02: * Copyright (C) The Spice Group. All rights reserved.
03: *
04: * This software is published under the terms of the Spice
05: * Software License version 1.1, a copy of which has been included
06: * with this distribution in the LICENSE.txt file.
07: */
08: package org.codehaus.spice.netserve.connection;
09:
10: import java.net.ServerSocket;
11: import org.codehaus.spice.netserve.connection.RequestHandler;
12:
13: /**
14: * This service is used to manage network acceptors.
15: * The service takes a ServerSocket and RequestHandler and
16: * anytime a new connection is accepted the handler is called
17: * with the new socket connection.
18: *
19: * @author Peter Donald
20: * @version $Revision: 1.2 $ $Date: 2004/03/21 23:43:00 $
21: */
22: public interface SocketAcceptorManager {
23: /**
24: * Start accepting connections from a socket and passing connections
25: * to specified handler.
26: *
27: * @param name the name of connection. This serves as a key used to
28: * shutdown acceptor.
29: * @param socket the ServerSocket from which connections are accepted
30: * @throws java.lang.Exception if unable to initiate connection management. This could
31: * be due to the key already being used for another acceptor,
32: * the serversocket being closed, the handler being null etc.
33: */
34: void connect(String name, ServerSocket socket,
35: RequestHandler handler) throws Exception;
36:
37: /**
38: * This shuts down the named acceptor.
39: * NOTE: It is the responsibility of the caller to make
40: * sure that the ServerSocket has been closed.
41: *
42: * @param name the name of connection
43: * @throws java.lang.IllegalArgumentException if no connection with specified name
44: */
45: void disconnect(String name);
46:
47: /**
48: * Return true if acceptor with specified name exists.
49: *
50: * @param name the name
51: * @return true if acceptor with specified name exists.
52: */
53: boolean isConnected(String name);
54: }
|