public class TransactionContext
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.sql.Connection |
sharedConnection |
private java.lang.ref.WeakReference |
transactionRef |
private TransactionRegistry |
transactionRegistry |
Constructor and Description |
---|
TransactionContext(TransactionRegistry transactionRegistry,
javax.transaction.Transaction transaction)
Creates a TransactionContext for the specified Transaction and TransactionRegistry.
|
Modifier and Type | Method and Description |
---|---|
void |
addTransactionContextListener(TransactionContextListener listener)
Adds a listener for transaction completion events.
|
java.sql.Connection |
getSharedConnection()
Gets the connection shared by all ManagedConnections in the transaction.
|
private javax.transaction.Transaction |
getTransaction() |
boolean |
isActive()
True if the transaction is active or marked for rollback only.
|
void |
setSharedConnection(java.sql.Connection sharedConnection)
Sets the shared connection for this transaction.
|
private final TransactionRegistry transactionRegistry
private final java.lang.ref.WeakReference transactionRef
private java.sql.Connection sharedConnection
public TransactionContext(TransactionRegistry transactionRegistry, javax.transaction.Transaction transaction)
transactionRegistry
- the TransactionRegistry used to obtain the XAResource for the
shared connectiontransaction
- the transactionpublic java.sql.Connection getSharedConnection()
public void setSharedConnection(java.sql.Connection sharedConnection) throws java.sql.SQLException
sharedConnection
- the shared connectionjava.sql.SQLException
- if a shared connection is already set, if XAResource for the connection
could not be found in the transaction registry, or if there was a problem enlisting the
connection in the transactionpublic void addTransactionContextListener(TransactionContextListener listener) throws java.sql.SQLException
listener
- the listener to addjava.sql.SQLException
- if a problem occurs adding the listener to the transactionpublic boolean isActive() throws java.sql.SQLException
java.sql.SQLException
- if a problem occurs obtaining the transaction statusprivate javax.transaction.Transaction getTransaction() throws java.sql.SQLException
java.sql.SQLException