org.osesb.objectpools.configuration
Class ObjectPoolConfiguration

java.lang.Object
  extended by org.osesb.configuration.XMLConfiguration
      extended by org.osesb.objectpools.configuration.ObjectPoolConfiguration

public class ObjectPoolConfiguration
extends XMLConfiguration

The framework uses the Apache Pool Package (org.apache.commons.pool) to:

The object pools defined in org.osesb.objectpools are configured in two sections of a XML configuration file. The first section <pool-configuration> configures the pool itself, the second section configures the objects in the pool. While the pool configuration is mostly the same across object pool implementations, the pooled object configuration(s) are specific to the object being pooled. For example, 1) JMS connection properties for pooled JMS clients, and 2) SAX parser properties for pooled SAX parsers.

This Class is the configuration for the pool and is used by all pool factories. The pool configuration includes properties defined in the Apache Pool API documentation, which can be found at http://jakarta.apache.org/commons/pool/apidocs. The framework uses mostly the same pool configuration properties for all object pool implementations.

Object pool configurations must be stand-alone configuration files. Although XML Configuration framework supports XPath expressions to content model root elements, object pool configurations cannot be included in another configuration file and then referenced using XPath.

The example, below, is a configuration for a pool of homogenous DOM parsers, all with namespaceAware=true and validating=false. DOMPoolFactory uses a configuration like this to construct the pool. This Class, ObjectPoolConfiguration, encapsulates the <pool-configuration> content model, which contains properties for configuring the pool, which in this example will be org.apache.commons.pool.impl.GenericObjectPool. org.apache.commons.pool.impl.GenericObjectPool is the Apache pool class for homogenous object pools.

<pooled-dom-parser>
          <pool-configuration>
              <!-- an optional name for the pool -->
              <poolName>osESB Non-Keyed DOM Parser Pool</poolName>
              <!-- display a pool heartbeat message every heartbeatInterval seconds -->
              <heartbeatInterval>300</heartbeatInterval>
              <!-- debugFlag -->
              <debugFlag>true</debugFlag>
              <!-- parameters that are specific to the pool implementation go here -->
              <!-- these are the config properties for jakarta-commons-pooling -->
              <!-- GenericObjectPool Config -->
              <maxIdle></maxIdle>
              <!-- No limit to the number of objects -->
              <maxActive>-1</maxActive>
              <maxWait>-1</maxWait>
              <!-- Grow the pool when a borrowobject() fails -->
              <whenExhaustedAction>2</whenExhaustedAction>
              <testOnBorrow>false</testOnBorrow>
              <testOnReturn>false</testOnReturn>
              <testWhileIdle>false</testWhileIdle>
              <!-- check for idle objects every 6 minutes (normally) -->
              <timeBetweenEvictionRunsMillis>360000</timeBetweenEvictionRunsMillis>
              <numTestsPerEvictionRun></numTestsPerEvictionRun>
              <!-- evict objects idle more than 5 minutes (normally) -->
              <minEvictableIdleTimeMillis>300000</minEvictableIdleTimeMillis>
              <!-- display pool startup message -->
              <displayStartupMessageFlag>true</displayStartupMessageFlag>
          </pool-configuration>
          <!-- the pooled SAX parsers configuration using JAXP -->
          <jaxp-configuration>
              <!-- use parser factory defaults - ignore parser property elements -->
              <useDefaultParserConfigurationFlag>false</useDefaultParserConfigurationFlag>
              <!-- do not use parser factory defaults - set these properties excplicitly -->
              <!-- used when validating against schems -->
              <!-- namespaceAware should always be true, validating or not -->
              <namespaceAware>true</namespaceAware>
              <validating>false</validating>
              <!-- null for dtd -->
              <schemaLanguage>http://www.w3.org/2001/XMLSchema</schemaLanguage>
          </jaxp-configuration>
      </pooled-dom-parser>
 

Since:
Version .9

Field Summary
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
ObjectPoolConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of ObjectPoolConfiguration given the content model Element.
ObjectPoolConfiguration(java.lang.String configFile)
          Creates a new instance of ObjectPoolConfiguration given a XML configuration file.
ObjectPoolConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of ObjectPoolConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 boolean getDisplayStartupMessageFlag()
          Returns the displayStartupMessageFlag for the pool configuration.
 long getHeartbeatInterval()
          Returns optional the heartbeatInterval, which defines the number of seconds between "health" messages that a pool may write or send to a log provider, like log4j.
 java.lang.String getName()
          Returns the optional name for this pool.
 java.lang.String getPooledClassName()
          Returns the className of the pooled object from the configuration.
static void main(java.lang.String[] args)
          Main method for testing.
 void setPooledClassName(java.lang.String pooledClassName)
          Sets the className of the pooled object.
 
Methods inherited from class org.osesb.configuration.XMLConfiguration
checkXMLConfigurationClass, clear, doEncryptionInstructions, getBooleanConfigurationProperty, getBooleanRootConfigurationAttribute, getConfigFilePath, getConfigurationAttribute, getConfigurationAttributes, getConfigurationElement, getConfigurationElements, getConfigurationProperties, getConfigurationProperty, getConfigurationProperty, getContentModelElement, getDebugFlag, getDocument, getEncryptionInstructions, getFTPClientConfiguration, getIntConfigurationProperty, getIntRootConfigurationAttribute, getJAXRPCClientConfiguration, getJDBCConfiguration, getJMSClientConfiguration, getLongConfigurationProperty, getLongRootConfigurationAttribute, getRootConfigurationAttribute, getRootConfigurationAttributes, getSMTPClientConfiguration, getSystemProperties, getSystemProperty, isConfigurationElementEmpty, loadConfiguration, loadExternalConfiguration, loadFTPClientConfiguration, loadJAXRPCClientConfiguration, loadJDBCConfiguration, loadJMSClientConfiguration, loadPropertiesFromContentModel, loadSMTPClientConfiguration, loadSystemProperties, mergeConfigurationProperties, setConfigFilePath, setConfigurationProperty, setDebugFlag, setFTPClientConfiguration, setJAXRPCClientConfiguration, setJDBCConfiguration, setJMSClientConfiguration, setName, setRootConfigurationAttribute, setSMTPClientConfiguration, setSystemProperties, setSystemProperty, toString, writeConfigurationFile, writeConfigurationFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectPoolConfiguration

public ObjectPoolConfiguration(java.lang.String configFile)
                        throws java.lang.Exception
Creates a new instance of ObjectPoolConfiguration given a XML configuration file. The root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

ObjectPoolConfiguration

public ObjectPoolConfiguration(java.lang.String configFile,
                               java.lang.String xpathExpression)
                        throws java.lang.Exception
Creates a new instance of ObjectPoolConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.

An empty xpathExpression implies that the root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
xpathExpression - A XPath expression that evaluates to the element that marks the beginning of the configuration. If following the framework convention for ObjectPoolConfiguration(s), xpathExpression should have 'pool-configuration' as the last Element in the path.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

ObjectPoolConfiguration

public ObjectPoolConfiguration(org.w3c.dom.Element contentModelElement)
                        throws java.lang.Exception
Creates a new instance of ObjectPoolConfiguration given the content model Element. Use this constructor to instantiate a ObjectPoolConfiguration when the configuration file has already been read and parsed by another Class.

Parameters:
contentModelElement - The top level Element for the for the configuration.
Throws:
java.lang.Exception - if there is a fatal error transversing the configuration content model enclosed by contentModelElement.
Method Detail

getPooledClassName

public java.lang.String getPooledClassName()
Returns the className of the pooled object from the configuration.

Returns:
the className of the pooled object.

setPooledClassName

public void setPooledClassName(java.lang.String pooledClassName)
Sets the className of the pooled object. The className of the pooled object is usually known in advance. This method supports run time determination of an underlying implementation that is returned by a factory. For example, the parser implementaion returned by JAXP is not known until the factory returns a parser object.

Parameters:
pooledClassName - The className of the pooled object.

getName

public java.lang.String getName()
Returns the optional name for this pool.

Overrides:
getName in class XMLConfiguration
Returns:
the pool name.

getHeartbeatInterval

public long getHeartbeatInterval()
Returns optional the heartbeatInterval, which defines the number of seconds between "health" messages that a pool may write or send to a log provider, like log4j.

Returns:
the heartbeatInterval for the pool.

getDisplayStartupMessageFlag

public boolean getDisplayStartupMessageFlag()
Returns the displayStartupMessageFlag for the pool configuration.

Returns:
the displayStartupMessageFlag for the pooled object.

main

public static void main(java.lang.String[] args)
Main method for testing.

Parameters:
args -