KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > core > TCConnectionManager


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.net.core;
5
6 import com.tc.net.TCSocketAddress;
7 import com.tc.net.protocol.ProtocolAdaptorFactory;
8 import com.tc.net.protocol.TCProtocolAdaptor;
9
10 import java.io.IOException JavaDoc;
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   // TODO: There should be a way to enumerate existing listeners and connections
20

21   /**
22    * Create a new non-connected connection
23    *
24    * @param adaptor protocol adaptor to use for incoming network data
25    */

26   public TCConnection createConnection(TCProtocolAdaptor adaptor);
27
28   /**
29    * Create a new listening socket (ie. java.net.ServerSocket) on the given socket address. A default accept queue depth
30    * will be used, and reuseAddress will be true
31    *
32    * @param addr the address to bind the listener to
33    * @param factory protocol adaptor factory used to attach protocol adaptors to newly accpted connections
34    */

35   public TCListener createListener(TCSocketAddress addr, ProtocolAdaptorFactory factory) throws IOException JavaDoc;
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, ProtocolAdaptorFactory factory, int backlog, boolean reuseAddr)
47       throws IOException JavaDoc;
48
49   /**
50    * Close any open connections created through this connection manager instance
51    */

52   public void asynchCloseAllConnections();
53
54   public void closeAllConnections(long timeout);
55   
56   /**
57    * Close all listeners created through this connection manager instance
58    */

59   public void closeAllListeners();
60
61   /**
62    * Shutdown this connection manager. Shutdown will call <code>closeAllConnections()</code> and
63    * <code>closeAllListeners()</code> on your behalf. A shutdown connection manager can be reused or restarted
64    */

65   public void shutdown();
66   
67   /**
68    * Get all non-closed connection instances created by this manager
69    */

70   public TCConnection[] getAllConnections();
71   
72   /**
73    * Get all active listener instances created by this manager
74    */

75   public TCListener[] getAllListeners();
76   
77 }
Popular Tags