|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.osesb.objectpools.KeyedObjectPoolFactory
org.osesb.objectpools.SAXKeyedPoolFactory
public class SAXKeyedPoolFactory
This class is a factory for object pools of JAXP compliant SAX Parsers, with different configurations (heterogeneous). This class is is a thread-safe singleton, so only one instance of SAXKeyedPoolFactory and its associated KeyedObjectPool instance will exist per class loader.
Pools of SAX parsers are useful in multi-threaded environments, such as MDBs, where there are multiple clients using SAX parsers. Instead of repeatedly creating SAX parsers, clients call getObject() on a pool of SAX Parsers and call returnObject() when finished parsing. PooledParserAccessHelper is a helper class for accessing pooled SAX and DOM parsers. This class uses org.apache.commons.pool.impl.GenericKeyedObjectPool as the pool implementation.It is a good model for creating other heterogeneous object pools, which are pools that contain different kinds of objects. There is a known issue with validating against XML schemas using parsers from a pool implemented using the org.apache.commons.pool package. See org.osesb.objectpools.test.ThreadedPooledValidatingSAXParserTest. For now, the framework uses non-pooled SAX parsers for:<key-pooled-sax-parsers>
<pool-configuration>
<!-- an optional name for the pool -->
<poolName>osESB Keyed SAX Parser Pool</poolName>
<!-- a heartbeatInterval for the pool in 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>
<!-- non-validating, namespaceaware is false -->
<jaxp-configuration poolKey="namespaceaware-false">
<!-- the class that is pooled, not required for XML Parser pools -->
<!-- The pooled class is determined by the parser implementation in the class path.-->
<pooled-class></pooled-class>
<!-- 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>false</namespaceAware>
<validating>false</validating>
<!-- null for dtd -->
<schemaLanguage>http://www.w3.org/2001/XMLSchema</schemaLanguage>
</jaxp-configuration>
<!-- non-validating, namespaceaware is true -->
<jaxp-configuration poolKey="namespaceaware-true">
<!-- the class that is pooled, not required for XML Parser pools -->
<!-- The pooled class is determined by the parser implementation in the class path.-->
<pooled-class></pooled-class>
<!-- 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>
<jaxp-configuration poolKey="validating">
<!-- The class that is pooled, not required for XML Parser pools. -->
<!-- The pooled class is determined by the parser implementation in the class path.-->
<pooled-class></pooled-class>
<!-- 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>true</validating>
<!-- null for dtd -->
<schemaLanguage>http://www.w3.org/2001/XMLSchema</schemaLanguage>
</jaxp-configuration>
</key-pooled-sax-parsers>
| Nested Class Summary | |
|---|---|
protected static class |
SAXKeyedPoolFactory.JAXPSAXPoolableObjectFactory
Inner class that implements org.apache.commons.pool.KeyedPoolableObjectFactory, which is instantiated by the enclosing class and passed to GenericObjectPool's constructor. |
| Field Summary | |
|---|---|
protected static KeyedObjectPoolConfiguration |
keyedObjectPoolConfiguration
The pool configuration as a whole including the ObjectPoolConfiguration and the pooled object configuration(s). |
protected static SAXKeyedPoolFactory |
poolFactoryInstance
Singleton pattern - thread-safe construction. |
protected static KeyedObjectPool |
poolInstance
The instance of the objectpool we will create. |
protected static java.lang.String |
thisClassName
The full name of this class |
| Fields inherited from class org.osesb.objectpools.KeyedObjectPoolFactory |
|---|
log |
| Constructor Summary | |
|---|---|
protected |
SAXKeyedPoolFactory()
Singleton pattern - cannot be instantiated directly. |
| Method Summary | |
|---|---|
static KeyedObjectPoolFactory |
getInstance()
Singleton pattern - - returns the instance of this class. |
KeyedObjectPoolConfiguration |
getKeyedObjectPoolConfiguration()
Return the pool configuration as a whole including the ObjectPoolConfiguration and the pooled object configuration(s). |
KeyedObjectPool |
getPool()
Construct (if necessary) and return the single instance of the heterogeneous SAX parser pool using the following plan to load the SAXKeyedPoolFactory configuration file: The configuration file given by the System property named ObjectPoolConstants.SAXKEYEDPOOLCONFIGFILE_PROPERTY. The configuration file given by the ObjectPoolConstants.SAXKEYEDPOOLCONFIGFILE_PROPERTY entry in a properties file named ObjectPoolConstants.OBJECTPOOLCONFIGURATIONS_PROPERTIES_FILE. The default configuration file given by ObjectPoolConstants.DEFAULT_KEYEDPOOLEDSAXPARSER_CONFIGFILE. |
static void |
main(java.lang.String[] args)
Main method for testing and sandboxing. |
void |
resetPoolInstance()
Close the pool and reset the poolInstance. |
| Methods inherited from class org.osesb.objectpools.KeyedObjectPoolFactory |
|---|
getPoolConfig |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static KeyedObjectPool poolInstance
protected static KeyedObjectPoolConfiguration keyedObjectPoolConfiguration
protected static java.lang.String thisClassName
protected static SAXKeyedPoolFactory poolFactoryInstance
| Constructor Detail |
|---|
protected SAXKeyedPoolFactory()
| Method Detail |
|---|
public static KeyedObjectPoolFactory getInstance()
public KeyedObjectPool getPool()
throws java.lang.Exception
getPool in class KeyedObjectPoolFactoryjava.lang.Exception - if a fatal error is encountered while instantiating the object pool.public KeyedObjectPoolConfiguration getKeyedObjectPoolConfiguration()
getKeyedObjectPoolConfiguration in class KeyedObjectPoolFactorypublic void resetPoolInstance()
resetPoolInstance in class KeyedObjectPoolFactorypublic static void main(java.lang.String[] args)
args -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||