Class JmsResourceHolder
java.lang.Object
org.springframework.transaction.support.ResourceHolderSupport
org.springframework.jms.connection.JmsResourceHolder
- All Implemented Interfaces:
ResourceHolder
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:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new JmsResourceHolder that is open for resources to be added.JmsResourceHolder(@Nullable jakarta.jms.ConnectionFactory connectionFactory) Create a new JmsResourceHolder that is open for resources to be added.JmsResourceHolder(@Nullable jakarta.jms.ConnectionFactory connectionFactory, jakarta.jms.Connection connection, jakarta.jms.Session session) Create a new JmsResourceHolder for the given JMS resources.JmsResourceHolder(jakarta.jms.Connection connection, jakarta.jms.Session session) Create a new JmsResourceHolder for the given JMS resources.JmsResourceHolder(jakarta.jms.Session session) Create a new JmsResourceHolder for the given JMS Session. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddConnection(jakarta.jms.Connection connection) Add the given Connection to this resource holder.final voidaddSession(jakarta.jms.Session session) Add the given Session to this resource holder.final voidaddSession(jakarta.jms.Session session, @Nullable jakarta.jms.Connection connection) Add the given Session to this resource holder, registered for a specific Connection.voidcloseAll()Close all of this resource holder's Sessions and clear its state.voidCommit all of this resource holder's Sessions.booleancontainsSession(jakarta.jms.Session session) Determine whether the given Session is registered with this resource holder.@Nullable jakarta.jms.ConnectionReturn this resource holder's default Connection, ornullif none.<C extends jakarta.jms.Connection>
@Nullable CgetConnection(Class<C> connectionType) Return this resource holder's Connection of the given type, ornullif none.@Nullable jakarta.jms.SessionReturn this resource holder's default Session, ornullif none.<S extends jakarta.jms.Session>
@Nullable SgetSession(Class<S> sessionType) Return this resource holder's Session of the given type, ornullif none.<S extends jakarta.jms.Session>
@Nullable SgetSession(Class<S> sessionType, @Nullable jakarta.jms.Connection connection) Return this resource holder's Session of the given type for the given connection, ornullif none.final booleanisFrozen()Return whether this resource holder is frozen, i.e.Methods inherited from class ResourceHolderSupport
clear, getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
-
Constructor Details
-
JmsResourceHolder
public JmsResourceHolder()Create a new JmsResourceHolder that is open for resources to be added.- See Also:
-
JmsResourceHolder
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 benull)
-
JmsResourceHolder
public JmsResourceHolder(jakarta.jms.Session session) Create a new JmsResourceHolder for the given JMS Session.- Parameters:
session- the JMS Session
-
JmsResourceHolder
public JmsResourceHolder(jakarta.jms.Connection connection, jakarta.jms.Session session) Create a new JmsResourceHolder for the given JMS resources.- Parameters:
connection- the JMS Connectionsession- the JMS Session
-
JmsResourceHolder
public JmsResourceHolder(@Nullable jakarta.jms.ConnectionFactory connectionFactory, jakarta.jms.Connection connection, jakarta.jms.Session session) Create a new JmsResourceHolder for the given JMS resources.- Parameters:
connectionFactory- the JMS ConnectionFactory that this resource holder is associated with (may benull)connection- the JMS Connectionsession- the JMS Session
-
-
Method Details
-
isFrozen
public final boolean isFrozen()Return whether this resource holder is frozen, i.e. does not allow for adding further Connections and Sessions to it.- See Also:
-
addConnection
public final void addConnection(jakarta.jms.Connection connection) Add the given Connection to this resource holder. -
addSession
public final void addSession(jakarta.jms.Session session) Add the given Session to this resource holder. -
addSession
public final void addSession(jakarta.jms.Session session, @Nullable jakarta.jms.Connection connection) Add the given Session to this resource holder, registered for a specific Connection. -
containsSession
public boolean containsSession(jakarta.jms.Session session) Determine whether the given Session is registered with this resource holder. -
getConnection
Return this resource holder's default Connection, ornullif none. -
getConnection
-
getSession
Return this resource holder's default Session, ornullif none. -
getSession
-
getSession
-
commitAll
public void commitAll() throws jakarta.jms.JMSExceptionCommit all of this resource holder's Sessions.- Throws:
jakarta.jms.JMSException- if thrown from a Session commit attempt- See Also:
-
closeAll
public void closeAll()Close all of this resource holder's Sessions and clear its state.- See Also:
-