xmlBlaster 2.2.0 API

org.xmlBlaster.protocol.jdbc
Class NamedConnectionPool.UnnamedConnectionPool

java.lang.Object
  extended by org.xmlBlaster.protocol.jdbc.NamedConnectionPool.UnnamedConnectionPool
All Implemented Interfaces:
I_Timeout, I_PoolManager
Enclosing class:
NamedConnectionPool

private class NamedConnectionPool.UnnamedConnectionPool
extends java.lang.Object
implements I_PoolManager, I_Timeout

Inner class, every user of the Named pool has its own connection pool.

If the resource pool is exhausted, the request will poll for a connection 5 times, with 1 sec sleeping in between.
This feature is adjustable in xmlBlaster.properties with:

   JdbcPool.maxResourceExhaustRetries=5
   JdbcPool.resourceExhaustSleepGap=1000
 


Field Summary
private  NamedConnectionPool boss
           
private  java.lang.String dbPasswd
           
private  java.lang.String dbUrl
           
private  java.lang.String dbUser
           
private  long eraseUnusedPoolTimeout
           
private  int maxResourceExhaustRetries
          If the pool is exhausted, we poll the given times
private static java.lang.String ME
           
private  java.lang.Object meetingPoint
           
(package private)  PoolManager poolManager
           
private  long resourceExhaustSleepGap
          If the pool is exhausted, we poll every given millis
Please note that the current request thread will block for maxResourceExhaustRetries*resourceExhaustSleepGap millis.
private  Timestamp timeoutHandle
           
private  java.lang.Object timeoutMonitor
           
 
Constructor Summary
NamedConnectionPool.UnnamedConnectionPool(NamedConnectionPool boss, java.lang.String dbUrl, java.lang.String dbUser, java.lang.String dbPasswd, long eraseUnusedPoolTimeout, int maxInstances, long busyToIdle, long idleToErase)
           
 
Method Summary
 void busyToIdle(java.lang.Object resource)
          This callback does nothing (enforced by interface I_PoolManager
(package private)  void destroy()
          Destroy the complete unnamed pool
(package private)  void erase(java.sql.Connection con)
          Destroy a JDBC connection (from busy or idle to undef).
 void idleToBusy(java.lang.Object resource)
          This callback does nothing (enforced by interface I_PoolManager)
(package private)  void release(java.sql.Connection con)
          Use this method to release a JDBC connection.
(package private)  java.sql.Connection reserve()
          Use this method to get a JDBC connection.
 void timeout(java.lang.Object o)
          Timeout callback enforced by I_Timeout.
 java.lang.Object toCreate(java.lang.String instanceId)
          Create a new JDBC connection, the driver must be registered already.
 void toErased(java.lang.Object resource)
          Destroy the JDBC connection.
 java.lang.String toXml()
          Dump state of this object into a XML ASCII string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

boss

private NamedConnectionPool boss

poolManager

PoolManager poolManager

dbUrl

private java.lang.String dbUrl

dbUser

private java.lang.String dbUser

dbPasswd

private java.lang.String dbPasswd

eraseUnusedPoolTimeout

private long eraseUnusedPoolTimeout

maxResourceExhaustRetries

private int maxResourceExhaustRetries
If the pool is exhausted, we poll the given times


resourceExhaustSleepGap

private long resourceExhaustSleepGap
If the pool is exhausted, we poll every given millis
Please note that the current request thread will block for maxResourceExhaustRetries*resourceExhaustSleepGap millis.


timeoutHandle

private Timestamp timeoutHandle

timeoutMonitor

private final java.lang.Object timeoutMonitor

meetingPoint

private final java.lang.Object meetingPoint
Constructor Detail

NamedConnectionPool.UnnamedConnectionPool

public NamedConnectionPool.UnnamedConnectionPool(NamedConnectionPool boss,
                                                 java.lang.String dbUrl,
                                                 java.lang.String dbUser,
                                                 java.lang.String dbPasswd,
                                                 long eraseUnusedPoolTimeout,
                                                 int maxInstances,
                                                 long busyToIdle,
                                                 long idleToErase)
Parameters:
boss - My manager
eraseUnusedPoolTimeout - This pool is erased after given millis without activity of the owning user
0 switches it off, -1 looks into env JdbcPool.eraseUnusedPoolTimeout setting (and defaults to one hour)
maxInstances - Max. number of resources in this pool. -1 uses default of 20 (xmlBlaster.properties)
busyToIdleTimeout - Max. busy time of this resource in milli seconds
On timeout it changes state from 'busy' to 'idle'.
You can overwrite this value for each resource instance
0 switches it off
-1 uses default (switched off)
You get called back through I_PoolManager.busyToIdle() on timeout allowing you to code some specific handling.
idleToEraseTimeout - Max. idle time span of this resource in milli seconds
On timeout it changes state from 'idle' to 'undef' (it is deleted).
You can overwrite this value for each resource instance
0 switches it off
-1 uses default (10 min) (xmlBlaster.properties)
You get called back through I_PoolManager.toErased() on timeout allowing you to code some specific handling.
Method Detail

idleToBusy

public void idleToBusy(java.lang.Object resource)
This callback does nothing (enforced by interface I_PoolManager)

Specified by:
idleToBusy in interface I_PoolManager

busyToIdle

public void busyToIdle(java.lang.Object resource)
This callback does nothing (enforced by interface I_PoolManager

Specified by:
busyToIdle in interface I_PoolManager

toCreate

public java.lang.Object toCreate(java.lang.String instanceId)
                          throws XmlBlasterException
Create a new JDBC connection, the driver must be registered already.

Specified by:
toCreate in interface I_PoolManager
Returns:
A new Resource which will be managed
Throws:
XmlBlasterException

toErased

public void toErased(java.lang.Object resource)
Destroy the JDBC connection. The driver remains.

Specified by:
toErased in interface I_PoolManager
Parameters:
The - Connection object

reserve

java.sql.Connection reserve()
                      throws XmlBlasterException
Use this method to get a JDBC connection.

Throws:
XmlBlasterException

release

void release(java.sql.Connection con)
       throws XmlBlasterException
Use this method to release a JDBC connection.

Throws:
XmlBlasterException

erase

void erase(java.sql.Connection con)
     throws XmlBlasterException
Destroy a JDBC connection (from busy or idle to undef).

Throws:
XmlBlasterException

timeout

public void timeout(java.lang.Object o)
Timeout callback enforced by I_Timeout. Destroys pool of a user with all its connections

Specified by:
timeout in interface I_Timeout
Parameters:
o - You get bounced back your userData which you passed with Timeout.addTimeoutListener()

destroy

void destroy()
Destroy the complete unnamed pool


toXml

public final java.lang.String toXml()
Dump state of this object into a XML ASCII string.


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.