uk.co.lakesidetech.springxmldb.connectionpool
Class PoolableCollectionFactory

java.lang.Object
  extended byuk.co.lakesidetech.springxmldb.connectionpool.PoolableCollectionFactory
All Implemented Interfaces:
org.apache.commons.pool.KeyedPoolableObjectFactory

public class PoolableCollectionFactory
extends java.lang.Object
implements org.apache.commons.pool.KeyedPoolableObjectFactory

The PoolableCollectionFactory creates instances of the PoolableCollection

Author:
Stuart Eccles

Constructor Summary
PoolableCollectionFactory()
          Default Constructor
PoolableCollectionFactory(java.lang.String databaseImpl, java.lang.String databaseURI)
          Constructor given only the database URI and the driver classname
PoolableCollectionFactory(java.lang.String databaseImpl, java.lang.String databaseURI, java.lang.String username, java.lang.String password)
          Constructor given the database URI, driver classname, and user connection details
 
Method Summary
 void activateObject(java.lang.Object key, java.lang.Object obj)
          activate object when returning from the pool
 void destroyObject(java.lang.Object key, java.lang.Object obj)
          destroy an existing object from the pool.
 java.lang.String getDatabaseImpl()
           
 java.lang.String getDatabaseInstanceURI()
           
 java.lang.String getPassword()
           
 org.apache.commons.pool.KeyedObjectPool getPool()
           
 java.lang.String getUsername()
           
 java.lang.Object makeObject(java.lang.Object key)
          make the collection object to be returned from the pool
 void passivateObject(java.lang.Object key, java.lang.Object obj)
          passivate the object when returning to the pool
 void registerDriver()
          register the XML:DB class driver.
 void setDatabaseImpl(java.lang.String string)
           
 void setDatabaseInstanceURI(java.lang.String string)
           
 void setPassword(java.lang.String string)
           
 void setPool(org.apache.commons.pool.KeyedObjectPool pool)
           
 void setUsername(java.lang.String string)
           
 boolean validateObject(java.lang.Object key, java.lang.Object obj)
          Validate the object is still ok to be returned by the pool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PoolableCollectionFactory

public PoolableCollectionFactory()
Default Constructor


PoolableCollectionFactory

public PoolableCollectionFactory(java.lang.String databaseImpl,
                                 java.lang.String databaseURI)
Constructor given only the database URI and the driver classname


PoolableCollectionFactory

public PoolableCollectionFactory(java.lang.String databaseImpl,
                                 java.lang.String databaseURI,
                                 java.lang.String username,
                                 java.lang.String password)
Constructor given the database URI, driver classname, and user connection details

Method Detail

getPool

public org.apache.commons.pool.KeyedObjectPool getPool()
Returns:
Returns the pool.

setPool

public void setPool(org.apache.commons.pool.KeyedObjectPool pool)
Parameters:
pool - The pool to set.

registerDriver

public void registerDriver()
                    throws java.lang.Exception
register the XML:DB class driver. Strictly speaking there shouldnt be any issues with re-registering if registration has allready happened

Throws:
java.lang.Exception - if anything goes wrong

makeObject

public java.lang.Object makeObject(java.lang.Object key)
                            throws java.lang.Exception
make the collection object to be returned from the pool

Specified by:
makeObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Parameters:
key - the collection path to connect to
Returns:
the underlying object (which should be a poolable connection). returns null if no collection
Throws:
java.lang.Exception - if anything goes wrong (is defined by org.apache.commons.pool.KeyedPoolableObjectFactory) XMLDBException will be thrown if the uri/collection can not be found
See Also:
KeyedPoolableObjectFactory.makeObject(java.lang.Object)

destroyObject

public void destroyObject(java.lang.Object key,
                          java.lang.Object obj)
                   throws java.lang.Exception
destroy an existing object from the pool. In this case close down the underlying collection to the XML database

Specified by:
destroyObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Parameters:
key - The key which should be the collection path
obj - The object created which should be a PoolableCollection
Throws:
java.lang.Exception
See Also:
KeyedPoolableObjectFactory.destroyObject(java.lang.Object, java.lang.Object)

validateObject

public boolean validateObject(java.lang.Object key,
                              java.lang.Object obj)
Validate the object is still ok to be returned by the pool

Specified by:
validateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Parameters:
key - the pool key, in this case the collection path
obj - The object created which should be a PoolableCollection
Returns:
true if the object is still valid to be used
See Also:
KeyedPoolableObjectFactory.validateObject(java.lang.Object, java.lang.Object)

activateObject

public void activateObject(java.lang.Object key,
                           java.lang.Object obj)
                    throws java.lang.Exception
activate object when returning from the pool

Specified by:
activateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Parameters:
key -
obj -
Throws:
java.lang.Exception
See Also:
KeyedPoolableObjectFactory.activateObject(java.lang.Object, java.lang.Object)

passivateObject

public void passivateObject(java.lang.Object key,
                            java.lang.Object obj)
                     throws java.lang.Exception
passivate the object when returning to the pool

Specified by:
passivateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Parameters:
key -
obj -
Throws:
java.lang.Exception
See Also:
KeyedPoolableObjectFactory.passivateObject(java.lang.Object, java.lang.Object)

getDatabaseImpl

public java.lang.String getDatabaseImpl()
Returns:

getDatabaseInstanceURI

public java.lang.String getDatabaseInstanceURI()
Returns:

setDatabaseImpl

public void setDatabaseImpl(java.lang.String string)
Parameters:
string -

setDatabaseInstanceURI

public void setDatabaseInstanceURI(java.lang.String string)
Parameters:
string -

getPassword

public java.lang.String getPassword()
Returns:

getUsername

public java.lang.String getUsername()
Returns:

setPassword

public void setPassword(java.lang.String string)
Parameters:
string -

setUsername

public void setUsername(java.lang.String string)
Parameters:
string -