uk.co.lakesidetech.springxmldb.datasource
Class PoolingXMLDBDataSource

java.lang.Object
  extended byuk.co.lakesidetech.springxmldb.datasource.PoolingXMLDBDataSource
All Implemented Interfaces:
XMLDBDataSource

public class PoolingXMLDBDataSource
extends java.lang.Object
implements XMLDBDataSource

An implementation of the XMLDBDataSource which uses pooling collections

Author:
Stuart Eccles

Field Summary
protected  java.io.PrintWriter logWriter
          My log writer.
protected  org.apache.commons.pool.KeyedObjectPool pool
           
 
Constructor Summary
PoolingXMLDBDataSource()
          default constructor
PoolingXMLDBDataSource(org.apache.commons.pool.KeyedObjectPool pool)
          Constructor with a configured pool
 
Method Summary
 org.xmldb.api.base.Collection getCollection()
          Get an XML:DB collection for the default collection path.
 org.xmldb.api.base.Collection getCollection(java.lang.String collectionPath)
          return a XML:DB collection object given the collection path.
 org.xmldb.api.base.Collection getCollection(java.lang.String username, java.lang.String password, java.lang.String collectionPath)
          not supported for pooling collections
 java.lang.String getDefaultCollectionPath()
           
 int getLoginTimeout()
          Throws UnsupportedOperationException.
 java.io.PrintWriter getLogWriter()
          Returns my log writer.
 boolean isAccessToUnderlyingCollectionAllowed()
          Returns the value of the accessToUnderlyingConnectionAllowed property.
 void setAccessToUnderlyingCollectionAllowed(boolean allow)
          Sets the value of the accessToUnderlyingConnectionAllowed property.
 void setDefaultCollectionPath(java.lang.String defaultCollectionPath)
           
 void setLoginTimeout(int seconds)
          Throws UnsupportedOperationException.
 void setLogWriter(java.io.PrintWriter out)
          Sets my log writer.
 void setPool(org.apache.commons.pool.KeyedObjectPool pool)
          Set the KeyedObjectPool used in this datasource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logWriter

protected java.io.PrintWriter logWriter
My log writer.


pool

protected org.apache.commons.pool.KeyedObjectPool pool
Constructor Detail

PoolingXMLDBDataSource

public PoolingXMLDBDataSource()
default constructor


PoolingXMLDBDataSource

public PoolingXMLDBDataSource(org.apache.commons.pool.KeyedObjectPool pool)
Constructor with a configured pool

Parameters:
pool - commons KeyedObjectPool
Method Detail

setPool

public void setPool(org.apache.commons.pool.KeyedObjectPool pool)
             throws java.lang.IllegalStateException,
                    java.lang.NullPointerException
Set the KeyedObjectPool used in this datasource

Parameters:
pool -
Throws:
java.lang.IllegalStateException
java.lang.NullPointerException

getDefaultCollectionPath

public java.lang.String getDefaultCollectionPath()
Returns:
Returns the defaultCollectionPath.

setDefaultCollectionPath

public void setDefaultCollectionPath(java.lang.String defaultCollectionPath)
Parameters:
defaultCollectionPath - The defaultCollectionPath to set.

isAccessToUnderlyingCollectionAllowed

public boolean isAccessToUnderlyingCollectionAllowed()
Returns the value of the accessToUnderlyingConnectionAllowed property.

Returns:
true if access to the underlying is allowed, false otherwise.

setAccessToUnderlyingCollectionAllowed

public void setAccessToUnderlyingCollectionAllowed(boolean allow)
Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to the underlying connection. (Default: false)

Parameters:
allow - Access to the underlying connection is granted when true.

getLogWriter

public java.io.PrintWriter getLogWriter()
Returns my log writer.

Returns:
my log writer
See Also:
DataSource#getLogWriter

getLoginTimeout

public int getLoginTimeout()
Throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException - As this implementation does not support this feature.

setLoginTimeout

public void setLoginTimeout(int seconds)
Throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException - As this implementation does not support this feature.

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
Sets my log writer.


getCollection

public org.xmldb.api.base.Collection getCollection()
                                            throws org.xmldb.api.base.XMLDBException
Get an XML:DB collection for the default collection path. This will borrow a an object from the pool which should be a poolable collection

Specified by:
getCollection in interface XMLDBDataSource
Returns:
The XML:DB collection.
Throws:
org.xmldb.api.base.XMLDBException - if collection cannot be found
See Also:
XMLDBDataSource.getCollection()

getCollection

public org.xmldb.api.base.Collection getCollection(java.lang.String collectionPath)
                                            throws org.xmldb.api.base.XMLDBException
return a XML:DB collection object given the collection path. Will return a pooling collection

Specified by:
getCollection in interface XMLDBDataSource
Parameters:
collectionPath -
Returns:
a XML:DB collection object
Throws:
org.xmldb.api.base.XMLDBException - if the collection cannot be connected
See Also:
XMLDBDataSource.getCollection(java.lang.String)

getCollection

public org.xmldb.api.base.Collection getCollection(java.lang.String username,
                                                   java.lang.String password,
                                                   java.lang.String collectionPath)
                                            throws org.xmldb.api.base.XMLDBException
not supported for pooling collections

Specified by:
getCollection in interface XMLDBDataSource
Parameters:
username - the connection username
password - the connection password
collectionPath - the collection path to return the collection
Returns:
a XML:DB collection object
Throws:
org.xmldb.api.base.XMLDBException - if the collection cannot be connected
See Also:
XMLDBDataSource.getCollection(java.lang.String, java.lang.String, java.lang.String)