org.apache.commons.messenger
Class MessengerSession

java.lang.Object
  extended byorg.apache.commons.messenger.MessengerSession

public class MessengerSession
extends java.lang.Object

MessengerSession represents all the local information for a single thread.

Version:
$Revision: 1.9 $
Author:
James Strachan

Field Summary
private  javax.jms.Session listenerSession
          the JMS Listener (async subscription) Session for this thread
private static org.apache.commons.logging.Log log
           
private  MessengerSupport messenger
          The current messenger to which I'm connected
private  javax.jms.MessageProducer producer
          The producer used to send messages using this session
private  javax.jms.MessageConsumer replyToConsumer
          the MessageConsumer for this threads reply to destination
private  javax.jms.Destination replyToDestination
          The inbox which is used for the call() methods
private  java.util.Map requestorsMap
          An optional cache of requestors
private  javax.jms.Session session
          the JMS Session for this thread
private  SessionFactory sessionFactory
          The factory used to create each thread's JMS Session
 
Constructor Summary
MessengerSession(MessengerSupport messenger, SessionFactory sessionFactory)
           
 
Method Summary
 void close()
          Closes any sessions or producers open
protected  javax.jms.Session createSession()
          Factory method to create a new JMS Session
protected  javax.jms.Destination createTemporaryDestination()
          Factory method to create a new temporary destination
 javax.jms.Session getListenerSession()
           
 javax.jms.MessageProducer getMessageProducer(javax.jms.Destination destination)
           
 javax.jms.QueueRequestor getQueueRequestor(javax.jms.QueueSession session, javax.jms.Queue destination)
           
 javax.jms.MessageConsumer getReplyToConsumer()
           
protected  javax.jms.Destination getReplyToDestination()
           
protected  java.util.Map getRequestorsMap()
           
 javax.jms.Session getSession()
           
 SessionFactory getSessionFactory()
           
 javax.jms.TopicRequestor getTopicRequestor(javax.jms.TopicSession session, javax.jms.Topic destination)
           
 boolean isTopic()
           
 void setReplyToConsumer(javax.jms.MessageConsumer replyToConsumer)
           
protected  void setReplyToDestination(javax.jms.Destination replyToDestination)
          Sets the reply to destination to use
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

session

private javax.jms.Session session
the JMS Session for this thread


listenerSession

private javax.jms.Session listenerSession
the JMS Listener (async subscription) Session for this thread


replyToConsumer

private javax.jms.MessageConsumer replyToConsumer
the MessageConsumer for this threads reply to destination


sessionFactory

private SessionFactory sessionFactory
The factory used to create each thread's JMS Session


requestorsMap

private java.util.Map requestorsMap
An optional cache of requestors


replyToDestination

private javax.jms.Destination replyToDestination
The inbox which is used for the call() methods


messenger

private MessengerSupport messenger
The current messenger to which I'm connected


producer

private javax.jms.MessageProducer producer
The producer used to send messages using this session

Constructor Detail

MessengerSession

public MessengerSession(MessengerSupport messenger,
                        SessionFactory sessionFactory)
Method Detail

getSessionFactory

public SessionFactory getSessionFactory()

close

public void close()
           throws javax.jms.JMSException
Closes any sessions or producers open

Throws:
javax.jms.JMSException

getSession

public javax.jms.Session getSession()
                             throws javax.jms.JMSException
Returns:
the JMS Session for this thread for synchronous mode
Throws:
javax.jms.JMSException

getListenerSession

public javax.jms.Session getListenerSession()
                                     throws javax.jms.JMSException
Returns:
the JMS Session for this thread for asynchronous mode
Throws:
javax.jms.JMSException

getReplyToConsumer

public javax.jms.MessageConsumer getReplyToConsumer()
                                             throws javax.jms.JMSException
Returns:
the MessageConsumer for the ReplyTo Destination for this thread
Throws:
javax.jms.JMSException

setReplyToConsumer

public void setReplyToConsumer(javax.jms.MessageConsumer replyToConsumer)

getMessageProducer

public javax.jms.MessageProducer getMessageProducer(javax.jms.Destination destination)
                                             throws javax.jms.JMSException
Returns:
the MessageProducer for the given destination.
Throws:
javax.jms.JMSException

getReplyToDestination

protected javax.jms.Destination getReplyToDestination()
                                               throws javax.jms.JMSException
Returns:
the reply to destination (a temporary queue) used to reply to this thread and session
Throws:
javax.jms.JMSException

setReplyToDestination

protected void setReplyToDestination(javax.jms.Destination replyToDestination)
                              throws javax.jms.JMSException
Sets the reply to destination to use

Throws:
javax.jms.JMSException

getTopicRequestor

public javax.jms.TopicRequestor getTopicRequestor(javax.jms.TopicSession session,
                                                  javax.jms.Topic destination)
                                           throws javax.jms.JMSException
Returns:
either a cached TopicRequestor or creates a new one
Throws:
javax.jms.JMSException

getQueueRequestor

public javax.jms.QueueRequestor getQueueRequestor(javax.jms.QueueSession session,
                                                  javax.jms.Queue destination)
                                           throws javax.jms.JMSException
Returns:
either a cached QueueRequestor or creates a new one
Throws:
javax.jms.JMSException

isTopic

public boolean isTopic()
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createSession

protected javax.jms.Session createSession()
                                   throws javax.jms.JMSException
Factory method to create a new JMS Session

Throws:
javax.jms.JMSException

createTemporaryDestination

protected javax.jms.Destination createTemporaryDestination()
                                                    throws javax.jms.JMSException
Factory method to create a new temporary destination

Throws:
javax.jms.JMSException

getRequestorsMap

protected java.util.Map getRequestorsMap()
Returns:
the map of requestors, indexed by destination. The Map will be lazily constructed