org.osesb.objectpools
Class JAXRPCClientKeyedPoolFactory

java.lang.Object
  extended by org.osesb.objectpools.KeyedObjectPoolFactory
      extended by org.osesb.objectpools.JAXRPCClientKeyedPoolFactory

public class JAXRPCClientKeyedPoolFactory
extends KeyedObjectPoolFactory

This class is a factory for an object pool of jax-rpc clients, with different configurations (heterogeneous). The framewok jax-rpc clients are in the org.osesb.connectors.jaxrpc package.

This class is is a thread-safe singleton, so only one instance of JAXRPCProducerKeyedPoolFactory and its associated KeyedObjectPool instance will exist per class loader.

Object pools of jax-rpc clients are useful in multi-threaded environments, where there are multiple clients using a jax-rpc Call. Instead of repeatedly creating the Call object, clients call getObject() on a pool of SOAP message producers and returnObject() after a message has been sent.

PooledJAXRPCClientAccessHelper is a helper class for accessing pooled jax-rpc clients.

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 jax-rpc client pool. The configuration contains a pool content model, which defines the characteristics of the pool and repeating org.osesb.configuration.JAXRPCClientConfiguration(s), one for each jax-rpc client in the keyed pool.

There is no default configuration file for a jax-rpc client pool. So, set the System property defined by org.osesb.objectpools.ObjectPoolConstants.JAXRPCKEYEDPOOLCONFIGFILE_PROPERTY to the pool configuration file or set a JAXRPCKEYEDPOOLCONFIGFILE_PROPERTY entry in a properties file named ObjectPoolConstants.OBJECTPOOLCONFIGURATIONS_PROPERTIES_FILE. Generally, a single jax-rpc client pool is configured for an 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.

A jax-rpc client pool configuration looks like:

<key-pooled-jaxrpc-clients>
          <pool-configuration>
              <!-- an optional name for the pool -->
              <poolName>TestKeyedWSProducerPool</poolName>
              <!-- display a pool heartbeat message every heartbeatInterval seconds -->
              <heartbeatInterval>60</heartbeatInterval>
              <!-- 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 -->
              <timeBetweenEvictionRunsMillis>360000</timeBetweenEvictionRunsMillis>
              <numTestsPerEvictionRun></numTestsPerEvictionRun>
              <!-- evict objects idle more than 5 minutes -->
              <minEvictableIdleTimeMillis>300000</minEvictableIdleTimeMillis>
          </pool-configuration>
          <!-- the JAXP configurations for the pooled classes -->
          <jaxrpc-configuration poolKey="asynchmsgprocessor">
             <!--
                  JAXRPCClientConfiguration for web service backed by a JMS Queue; usually wls.jms.inqueue.
                  Queue is configured in WEB-INF/web-services.xml.
              -->
              <!-- the class that is pooled -->
              <pooled-class>org.osesb.connectors.jaxrpc.JAXRPCDynamicSendMessageClient</pooled-class>
              <!-- for pooled object's, do not display the startup message -->
              <displayStartupMessageFlag>false</displayStartupMessageFlag>
              <!-- a debug flag -->
              <debugFlag>true</debugFlag>
              <!-- standard properties -->
              <javax.xml.rpc.ServiceFactory>weblogic.webservice.core.rpc.ServiceFactoryImpl</javax.xml.rpc.ServiceFactory>
              <targetNamespace>http://www.osesb.org/webservices/wls/asynchmsgprocessor</targetNamespace>
              <serviceName>AsynchMsgProcessorService</serviceName>
              <portName>AsynchMsgProcessorServicePort</portName>
              <operationName>onMessage</operationName>
              <wsdlLocation>http://localhost:7001/asynch-mp/AsynchMsgProcessorService?wsdl</wsdlLocation>
              <!-- implementation-specific properties that can be loaded via System properties -->
              <system-properties></system-properties>
              <!-- client side handler chain -->
              <!-- executed in order -->
              <handler-chain>
                  <handler>
                      <handler-class>org.osesb.connectors.jaxrpc.test.MyTestClientHandler</handler-class>
                  </handler>
              </handler-chain>
          </jaxrpc-configuration>
          <jaxrpc-configuration poolKey="echomessage-MyTestClientHandler">
              <!--
                  JAXRPCClientConfiguration for org.osesb.test.synchwebservice.ejb.EchoMessageWSBean and
                  a client-side handler.
              -->
              <!-- the class that is pooled -->
              <pooled-class>org.osesb.connectors.jaxrpc.JAXRPCDynamicSendMessageClient</pooled-class>
              <!-- for pooled object's, do not display the startup message -->
              <displayStartupMessageFlag>false</displayStartupMessageFlag>
              <!-- a debug flag -->
              <debugFlag>true</debugFlag>
              <!-- standard jax-rpc properties -->
              <javax.xml.rpc.ServiceFactory>weblogic.webservice.core.rpc.ServiceFactoryImpl</javax.xml.rpc.ServiceFactory>
              <targetNamespace>http://www.osesb.org/test/webservices/wls/echomessage/ejb</targetNamespace>
              <serviceName>EchoMessageService</serviceName>
              <portName>EchoMessageServicePort</portName>
              <operationName>onMessage</operationName>
              <wsdlLocation>http://localhost:7001/echo-message/EchoMessageService?wsdl</wsdlLocation>
             <!-- implementation-specific properties that can be loaded via System properties -->
              <system-properties></system-properties>
              <!-- client side handler chain -->
              <!-- executed in order -->
              <handler-chain>
                  <handler>
                      <handler-class>org.osesb.connectors.jaxrpc.test.MyTestClientHandler</handler-class>
                  </handler>
              </handler-chain>
          </jaxrpc-configuration>
      </key-pooled-jaxrpc-clients>
 

Since:
Version .9

Nested Class Summary
protected static class JAXRPCClientKeyedPoolFactory.JAXRPCClientPoolableObjectFactory
          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 JAXRPCClientKeyedPoolFactory 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 JAXRPCClientKeyedPoolFactory()
          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()
          Returns the object pool instance.
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

poolInstance

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


keyedObjectPoolConfiguration

protected static KeyedObjectPoolConfiguration keyedObjectPoolConfiguration
The pool configuration as a whole including the ObjectPoolConfiguration and the pooled object configuration(s).


thisClassName

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


poolFactoryInstance

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

Constructor Detail

JAXRPCClientKeyedPoolFactory

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

Method Detail

getInstance

public static KeyedObjectPoolFactory 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 KeyedObjectPool getPool()
                        throws java.lang.Exception
Returns the object pool instance.

There is no default configuration file for a JAXRPC client pool, so load the JAXRPCClientKeyedPoolFactory configuration file according to the following plan:

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

Specified by:
getPool in class KeyedObjectPoolFactory
Returns:
an instance of the heterogeneous object pool.
Throws:
java.lang.Exception

getKeyedObjectPoolConfiguration

public KeyedObjectPoolConfiguration getKeyedObjectPoolConfiguration()
Return the pool configuration as a whole including the ObjectPoolConfiguration and the pooled object configuration(s). Note that keyedObjectPoolConfiguration is null until getPool() is invoked on the concrete implementation of this class.

Specified by:
getKeyedObjectPoolConfiguration in class KeyedObjectPoolFactory

resetPoolInstance

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

Specified by:
resetPoolInstance in class KeyedObjectPoolFactory

main

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

Parameters:
args -