Purpose: TransactionController implementation for JTA 1.0
Description: Implements the required behavior for controlling JTA 1.0 transactions. Specific JTA implementations may need to extend this class when special controller behavior is necessary.
The JTA TransactionManager must be obtained and set on the instance in order for a Synchronization listener to be registered against the transaction. This can be done either by extending this class and defining acquireTransactionManager() to return the manager for the server, or by using this class and explicitly calling the setTransactionManager() method on it after the fact. e.g. TransactionManager mgr = controller.jndiLookup("java:comp/TransactionManager"); controller.setTransactionManager(mgr);
If a different listener needs to be used for synchronization, the SynchronizationListenerFactory should be set on the controller instance. The listener subclass should implement the factory interface, so that setting the factory is simply a matter of assigning an instance of the listener. e.g. controller.setSynchronizationListenerFactory( new DifferentServerSynchronizationListener()); The default listener factory creates instances of JTATransactionListener.
JTASynchronizationListener, AbstractTransactionController
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static String[] | codes
INTERNAL: Convert the status to a string for tracing. |
| protected static TransactionManager | |
| protected TransactionManager |
| Access | Constructor and Description |
|---|---|
| public | JTATransactionController()
PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager. |
| public | JTATransactionController(TransactionManager transactionManager)
PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager. |
| Modifier and Type | Method and Description |
|---|---|
| protected TransactionManager | Returns: The TransactionManager for the transaction systemINTERNAL: Obtain and return the JTA TransactionManager on this platform. |
| protected void | beginTransaction_impl()
Implements abstract org. |
| protected boolean | Returns: true if the current state allows for a transaction to be startedThe current transaction status status)Implements abstract org. |
| protected boolean | Returns: true if the current state allows for a transaction to be committedThe current transaction status status)Implements abstract org. |
| protected boolean | Returns: true if the current state allows for the SQL to be sent to the databaseThe current transaction status status)Implements abstract org. |
| protected boolean | Returns: true if the current state dictates that the unit of work should be mergedThe current transaction status status)Implements abstract org. |
| protected boolean | Returns: true if the current state allows for a transaction to be rolled backThe current transaction status status)Implements abstract org. |
| protected void | commitTransaction_impl()
Implements abstract org. |
| public static TransactionManager | |
| protected int | getIntStatus(Object status)
INTERNAL: Convenience method to return the int value of the transaction status. |
| protected Object | Returns: The active transaction object or id, or null if no transaction is activeImplements abstract org. |
| protected Object | Returns: A key for the passed in transaction, or null if no transaction specifiedThe transaction to which the returned key applies (may be null) transaction)Implements abstract org. |
| public TransactionManager | Returns: The JTA TransactionManager that is used to obtain transaction state information and control the active transaction.PUBLIC: Return the transaction manager used to control the JTA transactions. |
| protected Object | Returns: The current transaction statusImplements abstract org. |
| public boolean | isRolledBack_impl(Object status)
Implements abstract org. |
| protected void | markTransactionForRollback_impl()
Implements abstract org. |
| protected void | registerSynchronization_impl(AbstractSynchronizationListener
The synchronization listener created for this transaction listener, Object The active transaction for which notification is being requested txn)Implements abstract org. |
| protected void | rollbackTransaction_impl()
Implements abstract org. |
| public static void | setDefaultTransactionManager(TransactionManager defaultTransactionManager)
PUBLIC: Set the JTA transaction manager to be used. |
| public void | setTransactionManager(TransactionManager
A valid JTA TransactionManager that can be
accessed by this controller to obtain transaction state information and
control the active transaction. mgr)PUBLIC: Set the transaction manager used to control the JTA transactions. |
| protected String | statusToString_impl(Object status)
Implements abstract org. |
| codes | back to summary |
|---|---|
| pack-priv static String[] codes INTERNAL: Convert the status to a string for tracing. | |
| defaultTransactionManager | back to summary |
|---|---|
| protected static TransactionManager defaultTransactionManager | |
| transactionManager | back to summary |
|---|---|
| protected TransactionManager transactionManager | |
| JTATransactionController | back to summary |
|---|---|
| public JTATransactionController() PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager. | |
| JTATransactionController | back to summary |
|---|---|
| public JTATransactionController(TransactionManager transactionManager) PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager. | |
| acquireTransactionManager | back to summary |
|---|---|
| protected TransactionManager acquireTransactionManager() throws Exception INTERNAL: Obtain and return the JTA TransactionManager on this platform. By default try java:comp JNDI lookup. This method can be can be overridden by subclasses to obtain the transaction manager by whatever means is appropriate to the server. This method is invoked by the constructor to initialize the transaction manager at instance-creation time. Alternatively the transaction manager can be set directly on the controller instance using the setTransactionManager() method after the instance has been created.
| |
| beginTransaction_impl | back to summary |
|---|---|
| protected void beginTransaction_impl() throws Exception Implements abstract org. INTERNAL: Begin an external transaction.
| |
| canBeginTransaction_impl | back to summary |
|---|---|
| protected boolean canBeginTransaction_impl(Object status) Implements abstract org. INTERNAL: Return true if the status indicates that a transaction can be started. This would normally mean that no transaction is currently active. | |
| canCommitTransaction_impl | back to summary |
|---|---|
| protected boolean canCommitTransaction_impl(Object status) Implements abstract org. INTERNAL: Return true if the status indicates that a transaction can be committed. This would normally mean that a transaction is currently active. | |
| canIssueSQLToDatabase_impl | back to summary |
|---|---|
| protected boolean canIssueSQLToDatabase_impl(Object status) Implements abstract org. INTERNAL: Return true if the status indicates that the SQL should be issued to the db. This would normally mean that a transaction was active. | |
| canMergeUnitOfWork_impl | back to summary |
|---|---|
| protected boolean canMergeUnitOfWork_impl(Object status) Implements abstract org. INTERNAL: Return true if the status indicates that the unit of work should be merged into the shared cache. This would normally mean that the transaction was committed successfully. | |
| canRollbackTransaction_impl | back to summary |
|---|---|
| protected boolean canRollbackTransaction_impl(Object status) Implements abstract org. INTERNAL: Return true if the status indicates that a transaction can be rolled back. This would normally mean that a transaction is currently active. | |
| commitTransaction_impl | back to summary |
|---|---|
| protected void commitTransaction_impl() throws Exception Implements abstract org. INTERNAL: Commit the external transaction.
| |
| getDefaultTransactionManager | back to summary |
|---|---|
| public static TransactionManager getDefaultTransactionManager() | |
| getIntStatus | back to summary |
|---|---|
| protected int getIntStatus(Object status) INTERNAL: Convenience method to return the int value of the transaction status. Assumes that the status object is an Integer. | |
| getTransaction_impl | back to summary |
|---|---|
| protected Object getTransaction_impl() throws Exception Implements abstract org. INTERNAL: Return the active external transaction, or null if none is currently active for this thread. | |
| getTransactionKey_impl | back to summary |
|---|---|
| protected Object getTransactionKey_impl(Object transaction) throws Exception Implements abstract org. INTERNAL: Return a key for the specified external transaction object. The key is just something that can be inserted into a hashtable (must support hashCode() and equals() methods). | |
| getTransactionManager | back to summary |
|---|---|
| public TransactionManager getTransactionManager() PUBLIC: Return the transaction manager used to control the JTA transactions.
| |
| getTransactionStatus_impl | back to summary |
|---|---|
| protected Object getTransactionStatus_impl() throws Exception Implements abstract org. INTERNAL: Return the transaction status as an object. We will pass around Integers that wrap the int JTA status values. | |
| isRolledBack_impl | back to summary |
|---|---|
| public boolean isRolledBack_impl(Object status) Implements abstract org. INTERNAL: Return true if the transaction is rolled back.
| |
| markTransactionForRollback_impl | back to summary |
|---|---|
| protected void markTransactionForRollback_impl() throws Exception Implements abstract org. INTERNAL: Mark the external transaction for rollback.
| |
| registerSynchronization_impl | back to summary |
|---|---|
| protected void registerSynchronization_impl(AbstractSynchronizationListener listener, Object txn) throws Exception Implements abstract org. INTERNAL: Register the specified synchronization listener with the given active transaction.
| |
| rollbackTransaction_impl | back to summary |
|---|---|
| protected void rollbackTransaction_impl() throws Exception Implements abstract org. INTERNAL: Roll back the external transaction.
| |
| setDefaultTransactionManager | back to summary |
|---|---|
| public static void setDefaultTransactionManager(TransactionManager defaultTransactionManager) PUBLIC: Set the JTA transaction manager to be used. This can be called directly before login to configure JTA integration manually, or using Spring injection. | |
| setTransactionManager | back to summary |
|---|---|
| public void setTransactionManager(TransactionManager mgr) PUBLIC: Set the transaction manager used to control the JTA transactions.
| |
| statusToString_impl | back to summary |
|---|---|
| protected String statusToString_impl(Object status) Implements abstract org. Doc from org. INTERNAL: Convert the status to a string for tracing.
| |