uk.co.lakesidetech.springxmldb.datasource
Class BasicXMLDBDataSource

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

public class BasicXMLDBDataSource
extends java.lang.Object
implements XMLDBDataSource

A data source for XML:DB collections which uses a poolable collection factory to create pooled collections to an XML datasource

The data source follows the normal paradigms in creating connections and can be configured in the Spring context.

Im unsure as to the exact perforance increase provided by pooling collections to XML databases but it cant hurt. Because underlying connections can either be based on embedded access to the database or throught XML-RPC connections to remote databases performance can also be improved by using a pooling HttpClient such as the Apache Commons HttpClient

Author:
Stuart Eccles

Field Summary
protected  java.lang.String driverClassName
          The fully qualified XMLDB class name of the XMLDB driver to be used.
protected  int initialSize
          The initial number of default collection connections that are created when the pool is started.
protected  int maxActive
          The maximum number of active connections that can be allocated from this pool at the same time, or zero for no limit.
protected  int maxIdle
          The maximum number of active connections that can remain idle in the pool, without extra ones being released, or zero for no limit.
protected  long maxWait
          The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.
protected  long minEvictableIdleTimeMillis
          The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).
protected  int numTestsPerEvictionRun
          The number of objects to examine during each run of the idle object evictor thread (if any).
protected  java.lang.String password
          The connection password to be passed to our JDBC driver to establish a connection.
protected  boolean testOnBorrow
          The indication of whether objects will be validated before being borrowed from the pool.
protected  boolean testOnReturn
          The indication of whether objects will be validated before being returned to the pool.
protected  boolean testWhileIdle
          The indication of whether objects will be validated by the idle object evictor (if any).
protected  long timeBetweenEvictionRunsMillis
          The number of milliseconds to sleep between runs of the idle object evictor thread.
protected  java.lang.String url
          The connection URL to be passed to our JDBC driver to establish a connection.
protected  java.lang.String username
          The connection username to be passed to our JDBC driver to establish a connection.
 
Constructor Summary
BasicXMLDBDataSource()
           
 
Method Summary
 org.xmldb.api.base.Collection getCollection()
          get a collection with the default collection path
 org.xmldb.api.base.Collection getCollection(java.lang.String collectionPath)
          get a collection connection to the XML database given the collection path
 org.xmldb.api.base.Collection getCollection(java.lang.String username, java.lang.String password, java.lang.String collectionPath)
          get a collection connection to the XML database given a collectionpath and connect using supplied login details
 java.lang.String getDefaultCollectionPath()
           
 java.lang.String getDriverClassName()
           
 int getInitialSize()
           
 int getMaxActive()
           
 int getMaxIdle()
           
 long getMaxWait()
           
 long getMinEvictableIdleTimeMillis()
           
 int getNumActive()
          [Read Only] The current number of active connections that have been allocated from this data source.
 int getNumIdle()
          [Read Only] The current number of idle connections that are waiting to be allocated from this data source.
 int getNumTestsPerEvictionRun()
           
 java.lang.String getPassword()
           
 boolean getTestOnBorrow()
           
 boolean getTestOnReturn()
           
 boolean getTestWhileIdle()
           
 long getTimeBetweenEvictionRunsMillis()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 void setDefaultCollectionPath(java.lang.String defaultCollectionPath)
           
 void setDriverClassName(java.lang.String driverClassName)
           
 void setInitialSize(int initialSize)
           
 void setMaxActive(int maxActive)
           
 void setMaxIdle(int maxIdle)
           
 void setMaxWait(long maxWait)
           
 void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
           
 void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
           
 void setPassword(java.lang.String password)
           
 void setTestOnBorrow(boolean testOnBorrow)
           
 void setTestOnReturn(boolean testOnReturn)
           
 void setTestWhileIdle(boolean testWhileIdle)
           
 void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
           
 void setUrl(java.lang.String url)
           
 void setUsername(java.lang.String username)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driverClassName

protected java.lang.String driverClassName
The fully qualified XMLDB class name of the XMLDB driver to be used.


maxActive

protected int maxActive
The maximum number of active connections that can be allocated from this pool at the same time, or zero for no limit.


maxIdle

protected int maxIdle
The maximum number of active connections that can remain idle in the pool, without extra ones being released, or zero for no limit.


initialSize

protected int initialSize
The initial number of default collection connections that are created when the pool is started.


maxWait

protected long maxWait
The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.


testOnBorrow

protected boolean testOnBorrow
The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.


testOnReturn

protected boolean testOnReturn
The indication of whether objects will be validated before being returned to the pool.


timeBetweenEvictionRunsMillis

protected long timeBetweenEvictionRunsMillis
The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.


numTestsPerEvictionRun

protected int numTestsPerEvictionRun
The number of objects to examine during each run of the idle object evictor thread (if any).


minEvictableIdleTimeMillis

protected long minEvictableIdleTimeMillis
The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).


testWhileIdle

protected boolean testWhileIdle
The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.


password

protected java.lang.String password
The connection password to be passed to our JDBC driver to establish a connection.


url

protected java.lang.String url
The connection URL to be passed to our JDBC driver to establish a connection.


username

protected java.lang.String username
The connection username to be passed to our JDBC driver to establish a connection.

Constructor Detail

BasicXMLDBDataSource

public BasicXMLDBDataSource()
Method Detail

getDriverClassName

public java.lang.String getDriverClassName()

setDriverClassName

public void setDriverClassName(java.lang.String driverClassName)

getMaxActive

public int getMaxActive()

setMaxActive

public void setMaxActive(int maxActive)

getMaxIdle

public int getMaxIdle()

setMaxIdle

public void setMaxIdle(int maxIdle)

getInitialSize

public int getInitialSize()

setInitialSize

public void setInitialSize(int initialSize)

getMaxWait

public long getMaxWait()

setMaxWait

public void setMaxWait(long maxWait)

getTestOnBorrow

public boolean getTestOnBorrow()

setTestOnBorrow

public void setTestOnBorrow(boolean testOnBorrow)

getTestOnReturn

public boolean getTestOnReturn()

setTestOnReturn

public void setTestOnReturn(boolean testOnReturn)

getTimeBetweenEvictionRunsMillis

public long getTimeBetweenEvictionRunsMillis()

setTimeBetweenEvictionRunsMillis

public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)

getNumTestsPerEvictionRun

public int getNumTestsPerEvictionRun()

setNumTestsPerEvictionRun

public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)

getMinEvictableIdleTimeMillis

public long getMinEvictableIdleTimeMillis()

setMinEvictableIdleTimeMillis

public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)

getTestWhileIdle

public boolean getTestWhileIdle()

setTestWhileIdle

public void setTestWhileIdle(boolean testWhileIdle)

getNumActive

public int getNumActive()
[Read Only] The current number of active connections that have been allocated from this data source.


getNumIdle

public int getNumIdle()
[Read Only] The current number of idle connections that are waiting to be allocated from this data source.


getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getUsername

public java.lang.String getUsername()

setUsername

public void setUsername(java.lang.String username)

getCollection

public org.xmldb.api.base.Collection getCollection(java.lang.String collectionPath)
                                            throws org.xmldb.api.base.XMLDBException
get a collection connection to the XML database given the collection path

Specified by:
getCollection in interface XMLDBDataSource
Parameters:
collectionPath - the collection path to get a collection connection for
Returns:
The collection object
Throws:
org.xmldb.api.base.XMLDBException - if collection cant be connected to
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
get a collection connection to the XML database given a collectionpath and connect using supplied login details

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

getCollection

public org.xmldb.api.base.Collection getCollection()
                                            throws org.xmldb.api.base.XMLDBException
get a collection with the default collection path

Specified by:
getCollection in interface XMLDBDataSource
Returns:
Throws:
org.xmldb.api.base.XMLDBException
See Also:
XMLDBDataSource.getCollection()

getDefaultCollectionPath

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

setDefaultCollectionPath

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