org.apache.axis2.transport.jms
Class JMSConnectionFactory

java.lang.Object
  extended by org.apache.axis2.transport.jms.JMSConnectionFactory

public class JMSConnectionFactory
extends java.lang.Object

Encapsulate a JMS Connection factory definition within an Axis2.xml

More than one JMS connection factory could be defined within an Axis2 XML specifying the JMSListener as the transportReceiver.

These connection factories are created at the initialization of the transportReceiver, and any service interested in using any of these could specify the name of the factory and the destination through Parameters named JMSConstants.CONFAC_PARAM and JMSConstants.DEST_PARAM as shown below.

myQueueConnectionFactory TestQueue

If a connection factory is defined by a parameter named JMSConstants.DEFAULT_CONFAC_NAME in the Axis2 XML, services which does not explicitly specify a connection factory will be defaulted to it - if it is defined in the Axis2 configuration.

e.g. org.apache.activemq.jndi.ActiveMQInitialContextFactory tcp://localhost:61616 TopicConnectionFactory myTopicOne, myTopicTwo org.apache.activemq.jndi.ActiveMQInitialContextFactory tcp://localhost:61616 QueueConnectionFactory myQueueOne, myQueueTwo org.apache.activemq.jndi.ActiveMQInitialContextFactory tcp://localhost:61616 ConnectionFactory myDestinationOne, myDestinationTwo


Method Summary
 void addDestination(java.lang.String destinationJndi, java.lang.String serviceName)
          Add a listen destination on this connection factory on behalf of the given service
 void addProperty(java.lang.String key, java.lang.String value)
          Add a property to the connection factory
 void connect()
          Connect to the actual JMS connection factory specified by the JNDI name
 javax.jms.ConnectionFactory getConFactory()
          Get the actual underlying connection factory
 java.lang.String getDestinationName(java.lang.String destinationJndi)
          Return the provider specific Destination name if any for the destination with the given JNDI name
 java.util.Map getDestinations()
          Get the list of destinations (JNDI) associated with this connection factory
 EndpointReference getEPRForDestination(java.lang.String destination)
          Return the EPR for the JMS Destination with the given JNDI name and using this connection factory
 java.lang.String getJndiName()
          Get the JNDI name of the actual factory
 java.lang.String getJndiPass()
          Get the JNDI name of the actual factory password
 java.lang.String getJndiUser()
          Get the JNDI name of the actual factory username
 java.lang.String getName()
          Return the name of the connection factory
 java.lang.String getPass()
          This is the real password for the connection factory after the JNDI lookup
 java.util.Hashtable getProperties()
          Get the connection factory properties
 java.lang.String getServiceByDestination(java.lang.String destinationName)
           
 java.lang.String getServiceNameForDestination(java.lang.String destination)
          Return the service name using this destination
 java.lang.String getUser()
          This is the real username for the connection factory after the JNDI lookup
 void listen(JMSMessageReceiver msgRcvr)
          Begin listening for messages on the list of destinations associated with this connection factory.
 void listenOnDestination(java.lang.String destinationJndi)
          Listen on the given destination from this connection factory.
 void removeDestination(java.lang.String destinationJndi)
          Remove listen destination on this connection factory
 void setJndiName(java.lang.String jndiName)
          Set the JNDI connection factory name
 void setJndiPass(java.lang.String jndiPass)
          Get the JNDI name of the actual factory password
 void setJndiUser(java.lang.String jndiUser)
          Get the JNDI name of the actual factory username
 void stop()
          Close all connections, sessions etc..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

connect

public void connect()
             throws javax.naming.NamingException
Connect to the actual JMS connection factory specified by the JNDI name

Throws:
javax.naming.NamingException - if the connection factory cannot be found

setJndiName

public void setJndiName(java.lang.String jndiName)
Set the JNDI connection factory name

Parameters:
jndiName -

setJndiUser

public void setJndiUser(java.lang.String jndiUser)
Get the JNDI name of the actual factory username


setJndiPass

public void setJndiPass(java.lang.String jndiPass)
Get the JNDI name of the actual factory password


addDestination

public void addDestination(java.lang.String destinationJndi,
                           java.lang.String serviceName)
Add a listen destination on this connection factory on behalf of the given service

Parameters:
destinationJndi - destination JNDI name
serviceName - the service to which it belongs

removeDestination

public void removeDestination(java.lang.String destinationJndi)
                       throws javax.jms.JMSException
Remove listen destination on this connection factory

Parameters:
destinationJndi - the JMS destination to be removed
Throws:
if - an error occurs trying to stop listening for messages before removal
javax.jms.JMSException

addProperty

public void addProperty(java.lang.String key,
                        java.lang.String value)
Add a property to the connection factory

Parameters:
key -
value -

getName

public java.lang.String getName()
Return the name of the connection factory

Returns:
the Axis2 name of this factory

getJndiName

public java.lang.String getJndiName()
Get the JNDI name of the actual factory

Returns:
the jndi name of the actual connection factory

getJndiUser

public java.lang.String getJndiUser()
Get the JNDI name of the actual factory username

Returns:
the jndi name of the actual connection factory username

getJndiPass

public java.lang.String getJndiPass()
Get the JNDI name of the actual factory password

Returns:
the jndi name of the actual connection factory password

getPass

public java.lang.String getPass()
This is the real password for the connection factory after the JNDI lookup

Returns:
the real password for the connection factory after the JNDI lookup

getUser

public java.lang.String getUser()
This is the real username for the connection factory after the JNDI lookup

Returns:
the eal username for the connection factory after the JNDI lookup

getConFactory

public javax.jms.ConnectionFactory getConFactory()
Get the actual underlying connection factory

Returns:
actual connection factory

getDestinations

public java.util.Map getDestinations()
Get the list of destinations (JNDI) associated with this connection factory

Returns:
destinations to service maping

getProperties

public java.util.Hashtable getProperties()
Get the connection factory properties

Returns:
properties

listen

public void listen(JMSMessageReceiver msgRcvr)
            throws javax.jms.JMSException
Begin listening for messages on the list of destinations associated with this connection factory. (Called during Axis2 initialization of the Transport receivers)

Parameters:
msgRcvr - the message receiver which will process received messages
Throws:
javax.jms.JMSException - on exceptions

listenOnDestination

public void listenOnDestination(java.lang.String destinationJndi)
                         throws javax.jms.JMSException
Listen on the given destination from this connection factory. Used to start listening on a destination associated with a newly deployed service

Parameters:
destinationJndi - the JMS destination to listen on
Throws:
javax.jms.JMSException - on exception

getServiceNameForDestination

public java.lang.String getServiceNameForDestination(java.lang.String destination)
Return the service name using this destination

Parameters:
destination - the destination name
Returns:
the service which uses the given destination, or null

stop

public void stop()
Close all connections, sessions etc.. and stop this connection factory


getDestinationName

public java.lang.String getDestinationName(java.lang.String destinationJndi)
Return the provider specific Destination name if any for the destination with the given JNDI name

Parameters:
destinationJndi - the JNDI name of the destination
Returns:
the provider specific Destination name or null if cannot be found

getEPRForDestination

public EndpointReference getEPRForDestination(java.lang.String destination)
Return the EPR for the JMS Destination with the given JNDI name and using this connection factory

Parameters:
destination - the JNDI name of the JMS Destionation
Returns:
the EPR

getServiceByDestination

public java.lang.String getServiceByDestination(java.lang.String destinationName)


Copyright © 2007 Apache Web Services Project. All Rights Reserved.