View Javadoc

1   /************************************************************************
2    * Copyright (c) 2000-2006 The Apache Software Foundation.             *
3    * All rights reserved.                                                *
4    * ------------------------------------------------------------------- *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you *
6    * may not use this file except in compliance with the License. You    *
7    * may obtain a copy of the License at:                                *
8    *                                                                     *
9    *     http://www.apache.org/licenses/LICENSE-2.0                      *
10   *                                                                     *
11   * Unless required by applicable law or agreed to in writing, software *
12   * distributed under the License is distributed on an "AS IS" BASIS,   *
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
14   * implied.  See the License for the specific language governing       *
15   * permissions and limitations under the License.                      *
16   ***********************************************************************/
17  
18  
19  package org.apache.james.services;
20  
21  
22  import org.apache.avalon.cornerstone.services.connection.ConnectionManager;
23  import java.net.ServerSocket;
24  import org.apache.excalibur.thread.ThreadPool;
25  import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
26  
27  /***
28   * This interface extends the standard ConnectionManager interface to allow
29   * connectionLimits to be specified on a per service basis
30   **/
31  public interface JamesConnectionManager extends ConnectionManager
32  {
33      /***
34       * The component role used by components implementing this service
35       */
36      String ROLE = "org.apache.james.services.JamesConnectionManager";
37  
38      /***
39       * Returns the default maximum number of open connections supported by this
40       * SimpleConnectionManager
41       *
42       * @return the maximum number of connections
43       */
44      int getMaximumNumberOfOpenConnections();
45  
46      /***
47       * Start managing a connection.
48       * Management involves accepting connections and farming them out to threads
49       * from pool to be handled.
50       *
51       * @param name the name of connection
52       * @param socket the ServerSocket from which to
53       * @param handlerFactory the factory from which to acquire handlers
54       * @param threadPool the thread pool to use
55       * @param maxOpenConnections the maximum number of open connections allowed for this server socket.
56       * @exception Exception if an error occurs
57       */
58      void connect( String name,
59                    ServerSocket socket,
60                    ConnectionHandlerFactory handlerFactory,
61                    ThreadPool threadPool,
62                    int maxOpenConnections )
63          throws Exception;
64      
65      /***
66       * Start managing a connection.
67       * This is similar to other connect method except that it uses default thread pool.
68       *
69       * @param name the name of connection
70       * @param socket the ServerSocket from which to
71       * @param handlerFactory the factory from which to acquire handlers
72       * @param maxOpenConnections the maximum number of open connections allowed for this server socket.
73       * @exception Exception if an error occurs
74       */
75      void connect( String name,
76                    ServerSocket socket,
77                    ConnectionHandlerFactory handlerFactory,
78                    int maxOpenConnections )
79          throws Exception;
80  
81      /***
82       * Start managing a connection.
83       * Management involves accepting connections and farming them out to threads
84       * from pool to be handled.
85       *
86       * @param name the name of connection
87       * @param socket the ServerSocket from which to
88       * @param handlerFactory the factory from which to acquire handlers
89       * @param threadPool the thread pool to use
90       * @exception Exception if an error occurs
91       */
92      void connect( String name,
93                    ServerSocket socket,
94                    ConnectionHandlerFactory handlerFactory,
95                    ThreadPool threadPool )
96          throws Exception;
97      
98      /***
99       * Start managing a connection.
100      * Management involves accepting connections and farming them out to threads
101      * from pool to be handled.
102      *
103      * @param name the name of connection
104      * @param socket the ServerSocket from which to
105      * @param handlerFactory the factory from which to acquire handlers
106      * @exception Exception if an error occurs
107      */
108     void connect( String name,
109                   ServerSocket socket,
110                   ConnectionHandlerFactory handlerFactory )
111         throws Exception;
112     
113 
114 }