org.otfeed
Class OTPooledConnectionFactory

java.lang.Object
  extended by org.otfeed.OTPooledConnectionFactory
All Implemented Interfaces:
IConnectionFactory

public class OTPooledConnectionFactory
extends java.lang.Object
implements IConnectionFactory

Class that facilitates connection pooling (sharing). This class maintains (at most) one connection to the Opentick server and routes all connect(IConnectionStateListener) requests to this single connection. This is convenient as all clients can view their copy of connection as an independant one. This is efficient, because only minimal number of system resources is consumed. It is recommended that this class should be used whenever there is a chance that factory's connect(IConnectionStateListener) method can be called more than once.


Constructor Summary
OTPooledConnectionFactory()
           
 
Method Summary
 IConnection connect(IConnectionStateListener listener)
          Connects to the server.
 IConnectionFactory getConnectionFactory()
           
 void setConnectionFactory(IConnectionFactory engine)
          The factory of shared connection (typically an instance of OTConnectionFactory).
 void shutdownAll()
          Forces the shutdown of the pooled connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OTPooledConnectionFactory

public OTPooledConnectionFactory()
Method Detail

setConnectionFactory

public void setConnectionFactory(IConnectionFactory engine)
The factory of shared connection (typically an instance of OTConnectionFactory).

Parameters:
engine -

getConnectionFactory

public IConnectionFactory getConnectionFactory()

connect

public IConnection connect(IConnectionStateListener listener)
Description copied from interface: IConnectionFactory
Connects to the server. This call does not block, the connection process is started asynchronously, in a separate thread (event-dispatching thread).

To monitor connection progress, use listener parameter.

Specified by:
connect in interface IConnectionFactory
Parameters:
listener - listener to receive connection state events. This parameter may be null, to indicate that there is no interest in monitoring connection status.

shutdownAll

public void shutdownAll()
Forces the shutdown of the pooled connection. Useful for hooking to the Spring's "deinit" bean lifecycle to make sure that even if users of this bean did not shutdown their clones of the connection, this method will actually disconnect from Opentick and release all resources.



Copyright © 2007 Mike Kroutikov. All Rights Reserved.