|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.osesb.objectpools.ObjectPoolFactory
org.osesb.objectpools.SAXPoolFactory
public class SAXPoolFactory
This class is a factory for homogeneous object pools of JAXP compliant SAX Parsers, all with the same configuration. This class is is a thread-safe singleton, so only one instance of SAXPoolFactory and its associated ObjectPool 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 parsers, clients call getObject() on a pool of SAX Parsers and call returnObject() when finished parsing. This class uses org.apache.commons.pool.impl.GenericObjectPool as the pool implementation. It is a good model for creating other homogeneous object pools, which are pools that contain the same 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:<pooled-jaxp-parser>
<!-- The pool configuration. These are the properties for jakarta-commons-pooling. -->
<pool-configuration>
<!-- an optional name for the pool -->
<poolName>osESB Test Non-Keyed 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 DocumentBuilder or SAX parser configuration -->
<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-jaxp-parser>
To use this Class:
| Nested Class Summary | |
|---|---|
protected static class |
SAXPoolFactory.JAXPSAXPoolableObjectFactory
Inner class that implements org.apache.commons.pool.PoolableObjectFactory, which is instantiated by the enclosing class and passed to GenericObjectPool's constructor. |
| Field Summary | |
|---|---|
protected static JAXPParserConfiguration |
jaxpConfiguration
The configuration for the JAXP SAX Parsers in the pool. |
protected static ObjectPoolConfiguration |
poolConfiguration
The configuration for the object pool. |
protected static SAXPoolFactory |
poolFactoryInstance
Singleton pattern - thread-safe construction. |
protected static ObjectPool |
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.ObjectPoolFactory |
|---|
log |
| Constructor Summary | |
|---|---|
protected |
SAXPoolFactory()
Singleton pattern - cannot be instantiated directly. |
| Method Summary | |
|---|---|
static ObjectPoolFactory |
getInstance()
Singleton pattern - - returns the instance of this class. |
ObjectPool |
getPool()
There is no default configuration file for a homogeneous pool of SAX parsers. |
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.ObjectPoolFactory |
|---|
getPoolConfig |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static ObjectPool poolInstance
protected static ObjectPoolConfiguration poolConfiguration
protected static java.lang.String thisClassName
protected static SAXPoolFactory poolFactoryInstance
protected static JAXPParserConfiguration jaxpConfiguration
| Constructor Detail |
|---|
protected SAXPoolFactory()
| Method Detail |
|---|
public static ObjectPoolFactory getInstance()
public ObjectPool getPool()
throws java.lang.Exception
getPool in class ObjectPoolFactoryjava.lang.Exception - if a fatal error is encountered while instantiating the object pool.public void resetPoolInstance()
resetPoolInstance in class ObjectPoolFactorypublic static void main(java.lang.String[] args)
args -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||