Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.net
Interface ConnectionManager

All Superinterfaces:
JiveManager
All Known Implementing Classes:
AbstractConnectionManager, NNTPConnectionManager

public interface ConnectionManager
extends JiveManager

Manages and maintains server connections.

Beyond simple access to active connections on the server, the connection manager can ensure connections are alive, and boot connections that are idle according to an idle policy.


Method Summary
 void addConnection(Connection conn)
          Add a connection to the manager.
 Connection createConnection(java.net.Socket socket, boolean acceptCreated, boolean secure)
          Creates a connection in the manager by wrapping the given socket in an appropriate connection implementation.
 ConnectionMonitor getConfigMonitor()
          Connection configuration monitors records any changes in a connection's configuration for administration and use in determining runtime behavior.
 ConnectionMonitor getConnectedMonitor()
          Obtain a monitor that watches the connections as they are added to the manager.
 Connection getConnection(int id)
          Obtain a connection by it's ID.
 int getConnectionCount()
          Obtain the number of connections currently managed by this manager.
 java.util.Iterator getConnections()
          Obtain an iterator of all connections managed by this manager.
 java.util.Iterator getConnections(BasicResultFilter filter)
          Obtain an iterator of all connections managed by this manager after filtering with the given filter.
 ConnectionMonitor getDisconnectedMonitor()
          Obtain a monitor that watches the connections as they are removed from the manager.
 int getMaxConnections()
          Returns the maximum number of connections allowed in the server.
 java.lang.Object registerCloseListener(ConnectionCloseListener listener, java.lang.Object handbackMessage)
          Register a listener for close event notification.
 java.lang.Object removeCloseListener(ConnectionCloseListener listener)
          Remove a registered close event listener.
 void removeConnection(Connection conn)
          Remove the given connection from the manager.
 void setMaxConnections(int maxConnections)
          Sets the maximum number of connections allowed in the server.
 void stop()
          Stop the module.
 
Methods inherited from interface com.jivesoftware.base.JiveManager
destroy, initialize
 

Method Detail

getMaxConnections

int getMaxConnections()
Returns the maximum number of connections allowed in the server.

Returns:
the max number of connections.

setMaxConnections

void setMaxConnections(int maxConnections)
Sets the maximum number of connections allowed in the server.

Parameters:
maxConnections - max number of connections.

getConnectionCount

int getConnectionCount()
Obtain the number of connections currently managed by this manager.

Returns:
the number of connections in the manager.

getConnections

java.util.Iterator getConnections()
Obtain an iterator of all connections managed by this manager.

Returns:
an iterator of Connection objects in the manager.

getConnections

java.util.Iterator getConnections(BasicResultFilter filter)
Obtain an iterator of all connections managed by this manager after filtering with the given filter. The filter may not be null so if no filtering is required, use getConnections().

Parameters:
filter - the filter to restrict the connections to return.
Returns:
an iterator of Connection objects in the manager that pass the filter.

getConnection

Connection getConnection(int id)
                         throws NotFoundException
Obtain a connection by it's ID.

Parameters:
id - the ID of the connection to retrieve.
Returns:
the connection found.
Throws:
NotFoundException

createConnection

Connection createConnection(java.net.Socket socket,
                            boolean acceptCreated,
                            boolean secure)
                            throws java.io.IOException

Creates a connection in the manager by wrapping the given socket in an appropriate connection implementation.

Connections should hide their underlying socket implementation. However, in order for the ConnectionManager to properly detect new data for reading on it's connections, it must have the socket of the connection. This is especially important when using nio channels.

NOTE: the connection is created but not added to the connection manager with this method. The connection MUST be added before the connection manager actively manages the connection.

Parameters:
socket - the socket associated with this connection.
acceptCreated - true if the socket was created with accept.
secure - true if the connection is secure.
Returns:
the connection object representing the socket in the manager.
Throws:
java.io.IOException

addConnection

void addConnection(Connection conn)

Add a connection to the manager.

Connections added to the ConnectionManager are monitored for closing and are automatically added to the idle group by calling Connection.idle() on the added connection. Connections should use the idle() method to add themself to the idle group using addIdleSocket().

Connections should hide their underlying socket implementation. However, in order for the ConnectionManager to properly detect new data for reading on it's connections, it must have the socket of the connection. This is especially important when using nio channels.

Parameters:
conn - the connection to add to this manager for active management

removeConnection

void removeConnection(Connection conn)
                      throws java.lang.InterruptedException
Remove the given connection from the manager.

Parameters:
conn - the connection to remove from the manager.
Throws:
java.lang.InterruptedException - if a connection could not be removed because the manager was interrupted.

getConnectedMonitor

ConnectionMonitor getConnectedMonitor()
Obtain a monitor that watches the connections as they are added to the manager.

Returns:
the connection monitor of the manager.

getConfigMonitor

ConnectionMonitor getConfigMonitor()

Connection configuration monitors records any changes in a connection's configuration for administration and use in determining runtime behavior.

Samples are the number of connection changes and the rate is measured in connections per second. Although some administration events may change connection configurations, it is expected that the primary events recorded are in protocol-level connection state changes such as the establishment of TLS over a previously insecure connection via SASL.

Returns:
the configuration monitor of the manager.

getDisconnectedMonitor

ConnectionMonitor getDisconnectedMonitor()
Obtain a monitor that watches the connections as they are removed from the manager.

Returns:
the disconnection monitor.

registerCloseListener

java.lang.Object registerCloseListener(ConnectionCloseListener listener,
                                       java.lang.Object handbackMessage)
                                       throws UnauthorizedException
Register a listener for close event notification. Registrations after the Session is closed will be immediately notified before the registration call returns (within the context of the registration call). An optional handback object can be associated with the registration if the same listener is registered to listen for multiple connection closures.

Parameters:
listener - the listener to register for events.
handbackMessage - The object to send in the event notification.
Returns:
the message previously registered for this channel or null if no registration existed.
Throws:
UnauthorizedException - if caller doesn't have permission to access this resource.

removeCloseListener

java.lang.Object removeCloseListener(ConnectionCloseListener listener)
                                     throws UnauthorizedException
Remove a registered close event listener. Registered listeners must be able to receive close events up until the time this method returns. (i.e. It is possible to call unregister, receive a close event registration, and then have the unregister call return.)

Parameters:
listener - the listener to deregister for close events.
Returns:
the Message registered with this listener or null if the channel was never registered.
Throws:
UnauthorizedException - if caller doesn't have permission to access this resource.

stop

void stop()
Stop the module. The module should attempt to free up threads and prepare for either another call to initialize (reconfigure the module) or for destruction.


Jive Forums Project Page

Copyright © 1999-2006 Jive Software.