org.osesb.objectpools
Class PooledJMSClientAccessHelper

java.lang.Object
  extended by org.osesb.objectpools.PooledJMSClientAccessHelper

public class PooledJMSClientAccessHelper
extends java.lang.Object

This class encapsulates access to a configured Keyed Pool of JMS clients, which is managed by JMSClientKeyedPoolFactory. JMS client pools can include the following classes from the org.osesb.connectors.jms package.

Since:
Version .9

Field Summary
protected static org.apache.commons.logging.Log log
          The logging implementation for this class.
protected static java.lang.String thisClassName
          The full name of this class.
 
Constructor Summary
PooledJMSClientAccessHelper()
           
 
Method Summary
static java.lang.Object getPooledJMSClient(javax.jms.Destination jmsDestination)
          Gets a pooled JMS client from the configured keyed pool of JMS clients using a JMS Destination.
static java.lang.Object getPooledJMSClient(java.lang.String poolKey)
          Gets a pooled JMS client from the configured keyed pool of JMS clients using a poolKey.
static void main(java.lang.String[] args)
          Main method for testing and sandboxing.
static void returnPooledJMSClient(java.lang.String poolKey, java.lang.Object jmsClient)
          Returns a JMS client object to the configured keyed pool of JMS clients.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thisClassName

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


log

protected static org.apache.commons.logging.Log log
The logging implementation for this class.

Constructor Detail

PooledJMSClientAccessHelper

public PooledJMSClientAccessHelper()
Method Detail

getPooledJMSClient

public static java.lang.Object getPooledJMSClient(java.lang.String poolKey)
                                           throws java.lang.Exception
Gets a pooled JMS client from the configured keyed pool of JMS clients using a poolKey.

Parameters:
poolKey - The key to the target JMS client in the configured heterogeneous pool of JMS clients.
Returns:
a org.osesb.connectors.jms.JMSProducerBase or a org.osesb.connectors.jms.JMSConsumerBase object. The caller is responsible for casting to the appropriate type of JMS client.
Throws:
java.lang.Exception - if a JMS client cannot be obtained from the pool.

getPooledJMSClient

public static java.lang.Object getPooledJMSClient(javax.jms.Destination jmsDestination)
                                           throws java.lang.Exception
Gets a pooled JMS client from the configured keyed pool of JMS clients using a JMS Destination.

Use this method in order to retrieve a pooled JMS client when the JMS Destination is known but the poolKey is not. For example, when replying to a message using the ReplyTo JMS property to determine the pooled JMS client.

The disadvantage of this method is that framework keyed object pools use poolKey as the index. This method searches the pooledObjectConfigurations for a matching Destination by performing a JNDI lookup on the <queue> and <topic> properties of a JMS client pool entry. Once a JNDI lookup is performed, the pool entry is modified (in memory) to include a 'destinationName' property, so that subsequent invocations of this method do not repeatedly perform JNDI lookups for a given Destination.

Parameters:
jmsDestination - The JMS Destination for the target JMS client in the configured heterogeneous pool of JMS clients.
Returns:
a org.osesb.connectors.jms.JMSProducerBase or a org.osesb.connectors.jms.JMSConsumerBase object. The caller is responsible for casting to the appropriate type of JMS client.
Throws:
java.lang.Exception - if a JMS client cannot be obtained from the pool.

returnPooledJMSClient

public static void returnPooledJMSClient(java.lang.String poolKey,
                                         java.lang.Object jmsClient)
Returns a JMS client object to the configured keyed pool of JMS clients.

Parameters:
poolKey - The key to the target JMS client in the configured heterogeneous pool of JMS clients.
jmsClient - The JMS client to return. JMS clients extend org.osesb.connectors.jms.JMSProducerBase or org.osesb.connectors.jms.JMSConsumerBase.

main

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

Parameters:
args -