Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.net.spi
Class AbstractConnectionManager

java.lang.Object
  extended by com.jivesoftware.forum.net.spi.AbstractConnectionManager
All Implemented Interfaces:
JiveManager, ConnectionManager
Direct Known Subclasses:
NNTPConnectionManager

public abstract class AbstractConnectionManager
extends java.lang.Object
implements ConnectionManager, JiveManager

A basic connection manager implementation.

The abstract connection manager handles all of the house keeping and configuration associated with the Connection Manager. Most implementations need only extend and implement the getReaderFactory() method to specialize the connection manager to handle a particular protocol.


Constructor Summary
AbstractConnectionManager()
          Constructs a manager with default values.
 
Method Summary
 void addConnection(Connection con)
          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.
 void destroy()
          Notifies the manager to release any resources that may be holding on too.
 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.
 void initialize()
          Initialize the manager.
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnectionManager

public AbstractConnectionManager()
Constructs a manager with default values.

Method Detail

initialize

public void initialize()
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches). Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager

destroy

public void destroy()
Description copied from interface: JiveManager
Notifies the manager to release any resources that may be holding on too. This could also be used to clear out the managers caches, etc.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
destroy in interface JiveManager

getMaxConnections

public int getMaxConnections()
Description copied from interface: ConnectionManager
Returns the maximum number of connections allowed in the server.

Specified by:
getMaxConnections in interface ConnectionManager
Returns:
the max number of connections.

setMaxConnections

public void setMaxConnections(int maxConnections)
Description copied from interface: ConnectionManager
Sets the maximum number of connections allowed in the server.

Specified by:
setMaxConnections in interface ConnectionManager
Parameters:
maxConnections - max number of connections.

getConnectionCount

public int getConnectionCount()
Description copied from interface: ConnectionManager
Obtain the number of connections currently managed by this manager.

Specified by:
getConnectionCount in interface ConnectionManager
Returns:
the number of connections in the manager.

getConnections

public java.util.Iterator getConnections()
Description copied from interface: ConnectionManager
Obtain an iterator of all connections managed by this manager.

Specified by:
getConnections in interface ConnectionManager
Returns:
an iterator of Connection objects in the manager.

getConnections

public java.util.Iterator getConnections(BasicResultFilter filter)
Description copied from interface: ConnectionManager
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().

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

getConnection

public Connection getConnection(int id)
                         throws NotFoundException
Description copied from interface: ConnectionManager
Obtain a connection by it's ID.

Specified by:
getConnection in interface ConnectionManager
Parameters:
id - the ID of the connection to retrieve.
Returns:
the connection found.
Throws:
NotFoundException

createConnection

public Connection createConnection(java.net.Socket socket,
                                   boolean acceptCreated,
                                   boolean secure)
                            throws java.io.IOException
Description copied from interface: ConnectionManager

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.

Specified by:
createConnection in interface ConnectionManager
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

public void addConnection(Connection con)
Description copied from interface: ConnectionManager

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.

Specified by:
addConnection in interface ConnectionManager
Parameters:
con - the connection to add to this manager for active management

removeConnection

public void removeConnection(Connection conn)
                      throws java.lang.IllegalStateException
Description copied from interface: ConnectionManager
Remove the given connection from the manager.

Specified by:
removeConnection in interface ConnectionManager
Parameters:
conn - the connection to remove from the manager.
Throws:
java.lang.IllegalStateException

getConnectedMonitor

public ConnectionMonitor getConnectedMonitor()
Description copied from interface: ConnectionManager
Obtain a monitor that watches the connections as they are added to the manager.

Specified by:
getConnectedMonitor in interface ConnectionManager
Returns:
the connection monitor of the manager.

getConfigMonitor

public ConnectionMonitor getConfigMonitor()
Description copied from interface: ConnectionManager

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.

Specified by:
getConfigMonitor in interface ConnectionManager
Returns:
the configuration monitor of the manager.

getDisconnectedMonitor

public ConnectionMonitor getDisconnectedMonitor()
Description copied from interface: ConnectionManager
Obtain a monitor that watches the connections as they are removed from the manager.

Specified by:
getDisconnectedMonitor in interface ConnectionManager
Returns:
the disconnection monitor.

registerCloseListener

public java.lang.Object registerCloseListener(ConnectionCloseListener listener,
                                              java.lang.Object handbackMessage)
                                       throws UnauthorizedException
Description copied from interface: ConnectionManager
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.

Specified by:
registerCloseListener in interface ConnectionManager
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

public java.lang.Object removeCloseListener(ConnectionCloseListener listener)
                                     throws UnauthorizedException
Description copied from interface: ConnectionManager
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.)

Specified by:
removeCloseListener in interface ConnectionManager
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

public void stop()
Description copied from interface: ConnectionManager
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.

Specified by:
stop in interface ConnectionManager

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.