KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > cornerstone > services > connection > ConnectionManager


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.cornerstone.services.connection;
19
20 import java.net.ServerSocket JavaDoc;
21 import org.apache.excalibur.thread.ThreadPool;
22
23 /**
24  * This is the service through which ConnectionManagement occurs.
25  *
26  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
27  */

28 public interface ConnectionManager
29 {
30     String JavaDoc ROLE = ConnectionManager.class.getName();
31
32     /**
33      * Start managing a connection.
34      * Management involves accepting connections and farming them out to threads
35      * from pool to be handled.
36      *
37      * @param name the name of connection
38      * @param socket the ServerSocket from which to
39      * @param handlerFactory the factory from which to aquire handlers
40      * @param threadPool the thread pool to use
41      * @exception Exception if an error occurs
42      */

43     void connect( String JavaDoc name,
44                   ServerSocket JavaDoc socket,
45                   ConnectionHandlerFactory handlerFactory,
46                   ThreadPool threadPool )
47         throws Exception JavaDoc;
48
49     /**
50      * Start managing a connection.
51      * This is similar to other connect method except that it uses default thread pool.
52      *
53      * @param name the name of connection
54      * @param socket the ServerSocket from which to
55      * @param handlerFactory the factory from which to aquire handlers
56      * @exception Exception if an error occurs
57      */

58     void connect( String JavaDoc name,
59                   ServerSocket JavaDoc socket,
60                   ConnectionHandlerFactory handlerFactory )
61         throws Exception JavaDoc;
62
63     /**
64      * This shuts down all handlers and socket, waiting for each to gracefully shutdown.
65      *
66      * @param name the name of connection
67      * @exception Exception if an error occurs
68      */

69     void disconnect( String JavaDoc name )
70         throws Exception JavaDoc;
71
72     /**
73      * This shuts down all handlers and socket.
74      * If tearDown is true then it will forcefully shutdown all connections and try
75      * to return as soon as possible. Otherwise it will behave the same as
76      * void disconnect( String name );
77      *
78      * @param name the name of connection
79      * @param tearDown if true will forcefully tear down all handlers
80      * @exception Exception if an error occurs
81      */

82     void disconnect( String JavaDoc name, boolean tearDown )
83         throws Exception JavaDoc;
84 }
85
Popular Tags