org.w3c.tools.jdbc
Class ConnectionManager

java.lang.Object
  |
  +--org.w3c.tools.jdbc.ConnectionManager

public class ConnectionManager
extends java.lang.Object
implements PropertyMonitoring


Field Summary
protected  int conn_count
           
protected  int conn_max
           
protected  LRUList connectionsLru
          The LRU list of connections.
static boolean debug
           
 
Method Summary
protected  JdbcConnection allocateConnection(JdbcServer server)
          Connections management - Allocate a new connection for this server.
protected  void deleteConnection(JdbcConnection conn)
           
protected  JdbcConnection getConnection(JdbcServer server)
          Get a connection to the given server.
static ConnectionManager getManager()
           
static ConnectionManager getManager(java.util.Properties p)
          Get an instance of the Jdbc manager.
protected  boolean negotiateConnection(JdbcServer server)
           
protected  void notifyConnection(JdbcConnection conn)
          A new connection has just been created.
 void notifyIdle(JdbcConnection conn)
          The given connection can be reused, but is now idle.
 void notifyUse(JdbcConnection conn)
          The given connection is about to be used.
 boolean propertyChanged(java.lang.String name)
          PropertyMonitoring implementation.
protected  void waitForConnection(JdbcServer server)
          Wait for a connection to come up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static final boolean debug

conn_count

protected int conn_count

conn_max

protected int conn_max

connectionsLru

protected LRUList connectionsLru
The LRU list of connections.
Method Detail

propertyChanged

public boolean propertyChanged(java.lang.String name)
PropertyMonitoring implementation.
Specified by:
propertyChanged in interface PropertyMonitoring
Tags copied from interface: PropertyMonitoring
Parameters:
name - The name of the property that changed.
Returns:
A boolean, if true, accept the new property value, otherwise, reject it and reset the property to its old value.

getConnection

protected JdbcConnection getConnection(JdbcServer server)
Get a connection to the given server.
Parameters:
server - the jdbc server.
Returns:
a JdbcConnection or null if there is no connection available.

allocateConnection

protected JdbcConnection allocateConnection(JdbcServer server)
Connections management - Allocate a new connection for this server.
Parameters:
server - the JdbcServer
Returns:
a newly created connection or null

negotiateConnection

protected boolean negotiateConnection(JdbcServer server)

deleteConnection

protected void deleteConnection(JdbcConnection conn)

notifyConnection

protected void notifyConnection(JdbcConnection conn)
A new connection has just been created.
Parameters:
conn - the new connection

notifyUse

public void notifyUse(JdbcConnection conn)
The given connection is about to be used. Update our list of available servers.
Parameters:
conn - The idle connection.

notifyIdle

public void notifyIdle(JdbcConnection conn)
The given connection can be reused, but is now idle.
Parameters:
conn - The connection that is now idle.

waitForConnection

protected void waitForConnection(JdbcServer server)
                          throws java.lang.InterruptedException
Wait for a connection to come up.
Parameters:
server, - the target server.
Throws:
java.lang.InterruptedException - If interrupted..

getManager

public static ConnectionManager getManager(java.util.Properties p)
Get an instance of the Jdbc manager. This method returns an actual instance of the Jdbc manager. It may return different managers, if it decides to distribute the load on different managers (avoid the ConnectionManager being a bottleneck).
Returns:
An application wide instance of the Jdbc manager.

getManager

public static ConnectionManager getManager()