org.apache.commons.messenger
Class SessionFactory

java.lang.Object
  extended by org.apache.commons.messenger.SessionFactory
Direct Known Subclasses:
JNDISessionFactory

public class SessionFactory
extends Object

SessionFactory is a Factory of JMS Session objects. It can be configured with a JMS Connection object to use or can use a JMS ConnectionFactory instance to create the JMS Connection lazily

Version:
$Revision: 155459 $
Author:
James Strachan

Field Summary
protected  Properties properties
          the properties used to create the connection
 
Constructor Summary
SessionFactory()
           
 
Method Summary
 void addProperty(String name, String value)
           
 void close()
          Closes the JMS Connection that this object is using, if any
 javax.jms.Connection createConnection()
          Factory method used to create a connection
protected  javax.jms.ConnectionFactory createConnectionFactory()
          Factory method used to create a connection factory.
protected  Properties createProperties()
          Factory method used to create the initial JNDI context properties.
protected  javax.jms.QueueConnection createQueueConnection(javax.jms.QueueConnectionFactory queueConnectionFactory)
           
 javax.jms.ServerSessionPool createServerSessionPool(javax.jms.MessageListener messageListener, int maxThreads)
           
 javax.jms.Session createSession()
          Creates a new Session instance
 javax.jms.Session createSession(javax.jms.Connection connection)
          Creates a new Session instance
protected  javax.jms.TopicConnection createTopicConnection(javax.jms.TopicConnectionFactory topicConnectionFactory)
           
 int getAcknowledgeMode()
          Returns the JMS acknowledge mode used by the JMS sessions created by this session
 String getClientID()
          Returns the clientID used on the current connection.
 javax.jms.Connection getConnection()
          Returns the JMS connection used to create new sessions
 javax.jms.ConnectionFactory getConnectionFactory()
          Returns the JMS ConnectionFactory used to create a new connection
 String getPassword()
          Returns the optional password used when creating a new JMS connection via a JMS ConnectionFactory
 Properties getProperties()
          Returns the Properties that can be used to configure the connection creation
 String getUsername()
          Returns the optional username used when creating a new JMS connection via a JMS ConnectionFactory
 boolean isTopic()
           
 boolean isTransacted()
          Returns true if sessions created by this factory should be transacted
 void setAcknowledge(String value)
          A String based setter method to allow this property to be defined easily from within the digester XML file.
 void setAcknowledgeMode(int acknowlegeMode)
           
 void setClientID(String clientID)
          Sets the clientID used on the current connection.
 void setConnection(javax.jms.Connection connection)
           
 void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
           
 void setPassword(String password)
           
 void setProperties(Properties properties)
           
 void setTopic(boolean topic)
          Sets whether to use a Topic or Queue connection/session
 void setTransacted(boolean transacted)
           
 void setUsername(String username)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

protected Properties properties
the properties used to create the connection

Constructor Detail

SessionFactory

public SessionFactory()
Method Detail

createSession

public javax.jms.Session createSession(javax.jms.Connection connection)
                                throws javax.jms.JMSException
Creates a new Session instance

Throws:
javax.jms.JMSException

createSession

public javax.jms.Session createSession()
                                throws javax.jms.JMSException
Creates a new Session instance

Throws:
javax.jms.JMSException

createServerSessionPool

public javax.jms.ServerSessionPool createServerSessionPool(javax.jms.MessageListener messageListener,
                                                           int maxThreads)
                                                    throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createConnection

public javax.jms.Connection createConnection()
                                      throws javax.jms.JMSException
Factory method used to create a connection

Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Closes the JMS Connection that this object is using, if any

Throws:
javax.jms.JMSException

getConnection

public javax.jms.Connection getConnection()
                                   throws javax.jms.JMSException
Returns the JMS connection used to create new sessions

Throws:
javax.jms.JMSException

setConnection

public void setConnection(javax.jms.Connection connection)
                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getConnectionFactory

public javax.jms.ConnectionFactory getConnectionFactory()
                                                 throws javax.jms.JMSException
Returns the JMS ConnectionFactory used to create a new connection

Throws:
javax.jms.JMSException

setConnectionFactory

public void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)

isTransacted

public boolean isTransacted()
Returns true if sessions created by this factory should be transacted


setTransacted

public void setTransacted(boolean transacted)

getAcknowledgeMode

public int getAcknowledgeMode()
Returns the JMS acknowledge mode used by the JMS sessions created by this session


setAcknowledgeMode

public void setAcknowledgeMode(int acknowlegeMode)

setAcknowledge

public void setAcknowledge(String value)
A String based setter method to allow this property to be defined easily from within the digester XML file.

Parameters:
value - is either "auto", "client" or "dups_ok"
Throws:
IllegalArgumentException - if the value is not one of the correct values

getUsername

public String getUsername()
Returns the optional username used when creating a new JMS connection via a JMS ConnectionFactory


setUsername

public void setUsername(String username)

getPassword

public String getPassword()
Returns the optional password used when creating a new JMS connection via a JMS ConnectionFactory


setPassword

public void setPassword(String password)

getProperties

public Properties getProperties()
Returns the Properties that can be used to configure the connection creation


setProperties

public void setProperties(Properties properties)

addProperty

public void addProperty(String name,
                        String value)

isTopic

public boolean isTopic()
Returns:
whether to use a Topic or Queue connection/session

setTopic

public void setTopic(boolean topic)
Sets whether to use a Topic or Queue connection/session


getClientID

public String getClientID()
Returns the clientID used on the current connection.

Returns:
String

setClientID

public void setClientID(String clientID)
Sets the clientID used on the current connection.

Parameters:
clientID - The clientID to set

createQueueConnection

protected javax.jms.QueueConnection createQueueConnection(javax.jms.QueueConnectionFactory queueConnectionFactory)
                                                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createTopicConnection

protected javax.jms.TopicConnection createTopicConnection(javax.jms.TopicConnectionFactory topicConnectionFactory)
                                                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createConnectionFactory

protected javax.jms.ConnectionFactory createConnectionFactory()
                                                       throws javax.jms.JMSException
Factory method used to create a connection factory. Derived classes may wish to use JNDI to load the ConnectionFactory

Throws:
javax.jms.JMSException

createProperties

protected Properties createProperties()
Factory method used to create the initial JNDI context properties. Derived classes may wish to overload this method to provide different properties



Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.