KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > spice > netserve > connection > SocketAcceptorManager


1 /*
2  * Copyright (C) The Spice Group. All rights reserved.
3  *
4  * This software is published under the terms of the Spice
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.spice.netserve.connection;
9
10 import java.net.ServerSocket JavaDoc;
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     /**
25      * Start accepting connections from a socket and passing connections
26      * to specified handler.
27      *
28      * @param name the name of connection. This serves as a key used to
29      * shutdown acceptor.
30      * @param socket the ServerSocket from which connections are accepted
31      * @throws java.lang.Exception if unable to initiate connection management. This could
32      * be due to the key already being used for another acceptor,
33      * the serversocket being closed, the handler being null etc.
34      */

35     void connect( String JavaDoc name,
36                   ServerSocket JavaDoc socket,
37                   RequestHandler handler )
38         throws Exception JavaDoc;
39
40     /**
41      * This shuts down the named acceptor.
42      * NOTE: It is the responsibility of the caller to make
43      * sure that the ServerSocket has been closed.
44      *
45      * @param name the name of connection
46      * @throws java.lang.IllegalArgumentException if no connection with specified name
47      */

48     void disconnect( String JavaDoc name );
49
50     /**
51      * Return true if acceptor with specified name exists.
52      *
53      * @param name the name
54      * @return true if acceptor with specified name exists.
55      */

56     boolean isConnected( String JavaDoc name );
57 }
58
Popular Tags