org.osesb.objectpools
Class MessageRouterPoolFactory

java.lang.Object
  extended by org.osesb.objectpools.ObjectPoolFactory
      extended by org.osesb.objectpools.MessageRouterPoolFactory

public class MessageRouterPoolFactory
extends ObjectPoolFactory

This class is a factory for homogeneous object pools of org.osesb.msgrouting.MessageRouter(s). This class is is a thread-safe singleton, so only one instance of MessageRouterPoolFactory and its associated ObjectPool instance can exist per application.

MessageRouter(s) are configured by transport handlers to route incoming messages to org.osesb.messagepipeline.MessagePipeline(s) for processing. Transport handlers are Message Driven and Stateless Session Beans configured to receive messages over JMS and SOAP, respectively. See the 'transport-handler' module. So, transport handlers configure pools of MessageRouter(s) during ejbCreate(), where bean instances obtain a MessageRouter from the configured pool in order to route an incoming XML message. See org.osesb.objectpools.MessageRouterPoolFactory.

See the org.osesb.messagepipeline package. See the org.osesb.transporthandlers package in the transport-handlers module.

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.

This factory uses a configuration file to load a MessageRouter pool. The configuration contains a pool content model, which defines the characteristics of the pool and repeating org.osesb.msgrouting.configuration.MessageRouterConfiguration(s), one for each MessageRouter in the keyed pool.

There is no default configuration file for a MessageRouter pool. So, set the System property defined by org.osesb.objectpools.ObjectPoolConstants.MESSAGEROUTERPOOLCONFIGFILE_PROPERTY to the pool configuration file or set a MESSAGEROUTERPOOLCONFIGFILE_PROPERTY entry in a properties file named ObjectPoolConstants.OBJECTPOOLCONFIGURATIONS_PROPERTIES_FILE. Generally, a single MessageRouter pool is configured for a integration project.

Object pool configurations must be stand-alone configuration files with all configurations specified in-line.

Object pool configurations cannot be embedded in another configuration file and then referenced externally using XPath. In addition, all pooled object configurations must be specified in-line and cannot use the 'configFile' attribute to redirect the configuration to an external file.


Nested Class Summary
protected static class MessageRouterPoolFactory.MessageRouterPoolableObjectFactory
          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 MessageRouterConfiguration messageRouterConfiguration
          The configuration for the JAXP DOM Parsers in the pool.
protected static ObjectPoolConfiguration poolConfiguration
          The configuration for the object pool.
protected static MessageRouterPoolFactory 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 MessageRouterPoolFactory()
          Singleton pattern - cannot be instantiated directly.
 
Method Summary
static ObjectPoolFactory getInstance()
          Singleton pattern - - returns the instance of this class.
 ObjectPool getPool()
          Construct (if necessary) and return the single instance of the homogeneous MessageRouter pool using the following plan to load the DOMPoolFactory configuration file:

The configuration file given by the System property named ObjectPoolConstants.MESSAGEROUTERPOOLCONFIGFILE_PROPERTY. The configuration file given by the ObjectPoolConstants.MESSAGEROUTERPOOLCONFIGFILE_PROPERTY entry in a properties file named ObjectPoolConstants.OBJECTPOOLCONFIGURATIONS_PROPERTIES_FILE.

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

poolInstance

protected static ObjectPool poolInstance
The instance of the objectpool we will create.


poolConfiguration

protected static ObjectPoolConfiguration poolConfiguration
The configuration for the object pool.


thisClassName

protected static java.lang.String thisClassName
The full name of this class


poolFactoryInstance

protected static MessageRouterPoolFactory poolFactoryInstance
Singleton pattern - thread-safe construction.


messageRouterConfiguration

protected static MessageRouterConfiguration messageRouterConfiguration
The configuration for the JAXP DOM Parsers in the pool.

Constructor Detail

MessageRouterPoolFactory

protected MessageRouterPoolFactory()
Singleton pattern - cannot be instantiated directly.

Method Detail

getInstance

public static ObjectPoolFactory getInstance()
Singleton pattern - - returns the instance of this class. Callers can then call getPool() to get the object pool.

Returns:
the singleton instance of this class.

getPool

public ObjectPool getPool()
                   throws java.lang.Exception
Construct (if necessary) and return the single instance of the homogeneous MessageRouter pool using the following plan to load the DOMPoolFactory configuration file:

  1. The configuration file given by the System property named ObjectPoolConstants.MESSAGEROUTERPOOLCONFIGFILE_PROPERTY.
  2. The configuration file given by the ObjectPoolConstants.MESSAGEROUTERPOOLCONFIGFILE_PROPERTY entry in a properties file named ObjectPoolConstants.OBJECTPOOLCONFIGURATIONS_PROPERTIES_FILE.

Specified by:
getPool in class ObjectPoolFactory
Returns:
an instance of the configured homogeneous object pool.
Throws:
java.lang.Exception - if a fatal error is encountered while instantiating the object pool.

resetPoolInstance

public void resetPoolInstance()
Close the pool and reset the poolInstance.

Specified by:
resetPoolInstance in class ObjectPoolFactory

main

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

Parameters:
args -