01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.net.core;
05:
06: import com.tc.net.TCSocketAddress;
07: import com.tc.net.protocol.ProtocolAdaptorFactory;
08: import com.tc.net.protocol.TCProtocolAdaptor;
09:
10: import java.io.IOException;
11:
12: /**
13: * Manages connections and listeners. The connection manager also provides default implementations of connection event
14: * handlers. Specifically, the default behaviour is close connections upon any error event
15: *
16: * @author teck
17: */
18: public interface TCConnectionManager {
19:
20: /**
21: * Create a new non-connected connection
22: *
23: * @param adaptor protocol adaptor to use for incoming network data
24: */
25: public TCConnection createConnection(TCProtocolAdaptor adaptor);
26:
27: /**
28: * Create a new listening socket (ie. java.net.ServerSocket) on the given socket address. A default accept queue depth
29: * will be used, and reuseAddress will be true
30: *
31: * @param addr the address to bind the listener to
32: * @param factory protocol adaptor factory used to attach protocol adaptors to newly accpted connections
33: */
34: public TCListener createListener(TCSocketAddress addr,
35: ProtocolAdaptorFactory factory) throws IOException;
36:
37: /**
38: * Create a new listening socket (ie. java.net.ServerSocket) on the given socket address with the given accect queue
39: * depth
40: *
41: * @param addr the address to bind the listener to
42: * @param factory protocol adaptor factory used to attach protocol adaptors to newly accpted connections
43: * @param backlog accept queue backlog depth
44: * @param reuseAddr whether the bind port will be reused if in use by open sockets
45: */
46: public TCListener createListener(TCSocketAddress addr,
47: ProtocolAdaptorFactory factory, int backlog,
48: boolean reuseAddr) throws IOException;
49:
50: /**
51: * Close any open connections created through this connection manager instance
52: */
53: public void asynchCloseAllConnections();
54:
55: public void closeAllConnections(long timeout);
56:
57: /**
58: * Close all listeners created through this connection manager instance
59: */
60: public void closeAllListeners();
61:
62: /**
63: * Shutdown this connection manager. Shutdown will call <code>closeAllConnections()</code> and
64: * <code>closeAllListeners()</code> on your behalf. A shutdown connection manager can be reused or restarted
65: */
66: public void shutdown();
67:
68: /**
69: * Get all non-closed connection instances created by this manager
70: */
71: public TCConnection[] getAllConnections();
72:
73: /**
74: * Get all active listener instances created by this manager
75: */
76: public TCListener[] getAllListeners();
77:
78: }
|