View Javadoc

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