org.springframework.jms.connection
Class JmsResourceHolder

java.lang.Object
  extended by org.springframework.transaction.support.ResourceHolderSupport
      extended by org.springframework.jms.connection.JmsResourceHolder
All Implemented Interfaces:
ResourceHolder
Direct Known Subclasses:
LocallyExposedJmsResourceHolder

public class JmsResourceHolder
extends ResourceHolderSupport

JMS resource holder, wrapping a JMS Connection and a JMS Session. JmsTransactionManager binds instances of this class to the thread, for a given JMS ConnectionFactory.

Note: This is an SPI class, not intended to be used by applications.

Since:
1.1
Author:
Juergen Hoeller
See Also:
JmsTransactionManager, JmsTemplate

Field Summary
private  ConnectionFactory connectionFactory
           
private  java.util.List<Connection> connections
           
private  boolean frozen
           
private static Log logger
           
private  java.util.List<Session> sessions
           
private  java.util.Map<Connection,java.util.List<Session>> sessionsPerConnection
           
 
Constructor Summary
JmsResourceHolder()
          Create a new JmsResourceHolder that is open for resources to be added.
JmsResourceHolder(ConnectionFactory connectionFactory)
          Create a new JmsResourceHolder that is open for resources to be added.
JmsResourceHolder(ConnectionFactory connectionFactory, Connection connection, Session session)
          Create a new JmsResourceHolder for the given JMS resources.
JmsResourceHolder(Connection connection, Session session)
          Create a new JmsResourceHolder for the given JMS resources.
JmsResourceHolder(Session session)
          Create a new JmsResourceHolder for the given JMS Session.
 
Method Summary
 void addConnection(Connection connection)
           
 void addSession(Session session)
           
 void addSession(Session session, Connection connection)
           
 void closeAll()
           
 void commitAll()
           
 boolean containsSession(Session session)
           
 Connection getConnection()
           
 Connection getConnection(java.lang.Class<? extends Connection> connectionType)
           
 Session getSession()
           
 Session getSession(java.lang.Class<? extends Session> sessionType)
           
 Session getSession(java.lang.Class<? extends Session> sessionType, Connection connection)
           
 boolean isFrozen()
           
 
Methods inherited from class org.springframework.transaction.support.ResourceHolderSupport
clear, getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final Log logger

connectionFactory

private ConnectionFactory connectionFactory

frozen

private boolean frozen

connections

private final java.util.List<Connection> connections

sessions

private final java.util.List<Session> sessions

sessionsPerConnection

private final java.util.Map<Connection,java.util.List<Session>> sessionsPerConnection
Constructor Detail

JmsResourceHolder

public JmsResourceHolder()
Create a new JmsResourceHolder that is open for resources to be added.

See Also:
addConnection(Connection), addSession(Session)

JmsResourceHolder

public JmsResourceHolder(ConnectionFactory connectionFactory)
Create a new JmsResourceHolder that is open for resources to be added.

Parameters:
connectionFactory - the JMS ConnectionFactory that this resource holder is associated with (may be null)

JmsResourceHolder

public JmsResourceHolder(Session session)
Create a new JmsResourceHolder for the given JMS Session.

Parameters:
session - the JMS Session

JmsResourceHolder

public JmsResourceHolder(Connection connection,
                         Session session)
Create a new JmsResourceHolder for the given JMS resources.

Parameters:
connection - the JMS Connection
session - the JMS Session

JmsResourceHolder

public JmsResourceHolder(ConnectionFactory connectionFactory,
                         Connection connection,
                         Session session)
Create a new JmsResourceHolder for the given JMS resources.

Parameters:
connectionFactory - the JMS ConnectionFactory that this resource holder is associated with (may be null)
connection - the JMS Connection
session - the JMS Session
Method Detail

isFrozen

public final boolean isFrozen()

addConnection

public final void addConnection(Connection connection)

addSession

public final void addSession(Session session)

addSession

public final void addSession(Session session,
                             Connection connection)

containsSession

public boolean containsSession(Session session)

getConnection

public Connection getConnection()

getConnection

public Connection getConnection(java.lang.Class<? extends Connection> connectionType)

getSession

public Session getSession()

getSession

public Session getSession(java.lang.Class<? extends Session> sessionType)

getSession

public Session getSession(java.lang.Class<? extends Session> sessionType,
                          Connection connection)

commitAll

public void commitAll()
               throws JMSException
Throws:
JMSException

closeAll

public void closeAll()