public class JmsResourceHolder extends ResourceHolderSupport
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.
JmsTransactionManager
,
JmsTemplate
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnection(Connection connection)
Add the given Connection to this resource holder.
|
void |
addSession(Session session)
Add the given Session to this resource holder.
|
void |
addSession(Session session,
Connection connection)
Add the given Session to this resource holder,
registered for a specific Connection.
|
void |
closeAll()
Close all of this resource holder's Sessions and clear its state.
|
void |
commitAll()
Commit all of this resource holder's Sessions.
|
boolean |
containsSession(Session session)
Determine whether the given Session is registered
with this resource holder.
|
Connection |
getConnection()
Return this resource holder's default Connection,
or
null if none. |
<C extends Connection> |
getConnection(Class<C> connectionType)
Return this resource holder's Connection of the given type,
or
null if none. |
Session |
getSession()
Return this resource holder's default Session,
or
null if none. |
<S extends Session> |
getSession(Class<S> sessionType)
Return this resource holder's Session of the given type,
or
null if none. |
<S extends Session> |
getSession(Class<S> sessionType,
Connection connection)
Return this resource holder's Session of the given type
for the given connection, or
null if none. |
boolean |
isFrozen()
Return whether this resource holder is frozen, i.e.
|
clear, getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
public JmsResourceHolder()
public JmsResourceHolder(@Nullable ConnectionFactory connectionFactory)
connectionFactory
- the JMS ConnectionFactory that this
resource holder is associated with (may be null
)public JmsResourceHolder(Session session)
session
- the JMS Sessionpublic JmsResourceHolder(Connection connection, Session session)
connection
- the JMS Connectionsession
- the JMS Sessionpublic JmsResourceHolder(@Nullable ConnectionFactory connectionFactory, Connection connection, Session session)
connectionFactory
- the JMS ConnectionFactory that this
resource holder is associated with (may be null
)connection
- the JMS Connectionsession
- the JMS Sessionpublic final boolean isFrozen()
public final void addConnection(Connection connection)
public final void addSession(Session session)
public final void addSession(Session session, @Nullable Connection connection)
public boolean containsSession(Session session)
@Nullable public Connection getConnection()
null
if none.@Nullable public <C extends Connection> C getConnection(Class<C> connectionType)
null
if none.@Nullable public Session getSession()
null
if none.@Nullable public <S extends Session> S getSession(Class<S> sessionType)
null
if none.@Nullable public <S extends Session> S getSession(Class<S> sessionType, @Nullable Connection connection)
null
if none.public void commitAll() throws JMSException
JMSException
- if thrown from a Session commit attemptSession.commit()
public void closeAll()
Session.close()