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
22
23 package org.apache.james.socket;
24
25
26 import org.apache.avalon.cornerstone.services.connection.ConnectionManager;
27 import java.net.ServerSocket;
28 import org.apache.excalibur.thread.ThreadPool;
29 import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
30
31 /**
32 * This interface extends the standard ConnectionManager interface to allow
33 * connectionLimits to be specified on a per service basis
34 **/
35 public interface JamesConnectionManager extends ConnectionManager
36 {
37 /**
38 * The component role used by components implementing this service
39 */
40 String ROLE = "org.apache.james.socket.JamesConnectionManager";
41
42 /**
43 * Returns the default maximum number of open connections supported by this
44 * SimpleConnectionManager
45 *
46 * @return the maximum number of connections
47 */
48 int getMaximumNumberOfOpenConnections();
49
50 /**
51 * Start managing a connection.
52 * Management involves accepting connections and farming them out to threads
53 * from pool to be handled.
54 *
55 * @param name the name of connection
56 * @param socket the ServerSocket from which to
57 * @param handlerFactory the factory from which to acquire handlers
58 * @param threadPool the thread pool to use
59 * @param maxOpenConnections the maximum number of open connections allowed for this server socket.
60 * @exception Exception if an error occurs
61 */
62 void connect( String name,
63 ServerSocket socket,
64 ConnectionHandlerFactory handlerFactory,
65 ThreadPool threadPool,
66 int maxOpenConnections )
67 throws Exception;
68
69 /**
70 * Start managing a connection.
71 * This is similar to other connect method except that it uses default thread pool.
72 *
73 * @param name the name of connection
74 * @param socket the ServerSocket from which to
75 * @param handlerFactory the factory from which to acquire handlers
76 * @param maxOpenConnections the maximum number of open connections allowed for this server socket.
77 * @exception Exception if an error occurs
78 */
79 void connect( String name,
80 ServerSocket socket,
81 ConnectionHandlerFactory handlerFactory,
82 int maxOpenConnections )
83 throws Exception;
84
85 /**
86 * Start managing a connection.
87 * Management involves accepting connections and farming them out to threads
88 * from pool to be handled.
89 *
90 * @param name the name of connection
91 * @param socket the ServerSocket from which to
92 * @param handlerFactory the factory from which to acquire handlers
93 * @param threadPool the thread pool to use
94 * @exception Exception if an error occurs
95 */
96 void connect( String name,
97 ServerSocket socket,
98 ConnectionHandlerFactory handlerFactory,
99 ThreadPool threadPool )
100 throws Exception;
101
102 /**
103 * Start managing a connection.
104 * Management involves accepting connections and farming them out to threads
105 * from pool to be handled.
106 *
107 * @param name the name of connection
108 * @param socket the ServerSocket from which to
109 * @param handlerFactory the factory from which to acquire handlers
110 * @exception Exception if an error occurs
111 */
112 void connect( String name,
113 ServerSocket socket,
114 ConnectionHandlerFactory handlerFactory )
115 throws Exception;
116
117 /**
118 * Start managing a connection.
119 * Management involves accepting connections and farming them out to threads
120 * from pool to be handled.
121 *
122 * @param name the name of connection
123 * @param socket the ServerSocket from which to
124 * @param handlerFactory the factory from which to acquire handlers
125 * @param threadPool the thread pool to use
126 * @param maxOpenConnections the maximum number of open connections allowed for this server socket.
127 * @param maxOpenConnectionsPerIP the maximum number of open connections per IP allowed for this server socket.
128 * @throws Exception
129 */
130 void connect( String name,
131 ServerSocket socket,
132 ConnectionHandlerFactory handlerFactory,
133 ThreadPool threadPool,
134 int maxOpenConnections,
135 int maxOpenConnectionsPerIP)
136 throws Exception;
137
138 /**
139 * Start managing a connection.
140 * Management involves accepting connections and farming them out to threads
141 * from pool to be handled.
142 *
143 * @param name the name of connection
144 * @param socket the ServerSocket from which to
145 * @param handlerFactory the factory from which to acquire handlers
146 * @param maxOpenConnections the maximum number of open connections allowed for this server socket.
147 * @param maxOpenConnectionsPerIP the maximum number of open connections per IP allowed for this server socket.
148 * @throws Exception
149 */
150 void connect( String name,
151 ServerSocket socket,
152 ConnectionHandlerFactory handlerFactory,
153 int maxOpenConnections,
154 int maxOpenConnectionsPerIP)
155 throws Exception;
156
157 /**
158 * Returns the default maximum number of open connections per IP supported by this
159 * SimpleConnectionManager
160 *
161 * @return the maximum number of connections
162 */
163 int getMaximumNumberOfOpenConnectionsPerIP();
164 }