The Spring Framework

org.springframework.transaction.jta
Class WebLogicJtaTransactionManager

java.lang.Object
  extended by org.springframework.transaction.support.AbstractPlatformTransactionManager
      extended by org.springframework.transaction.jta.JtaTransactionManager
          extended by org.springframework.transaction.jta.WebLogicJtaTransactionManager
All Implemented Interfaces:
Serializable, InitializingBean, PlatformTransactionManager

public class WebLogicJtaTransactionManager
extends JtaTransactionManager

Special JtaTransactionManager version for BEA WebLogic (7.0, 8.1 and higher). Supports the full power of Spring's transaction definitions on WebLogic's transaction coordinator, beyond standard JTA: transaction names, per-transaction isolation levels, and proper resuming of transactions in all cases.

Uses WebLogic's special begin(name) method to start a JTA transaction, to make Spring-driven transactions visible in WebLogic's transaction monitor. In case of Spring's declarative transactions, the exposed name will (by default) be the fully-qualified class name + "." + method name.

Supports a per-transaction isolation level through WebLogic's corresponding JTA transaction property "ISOLATION LEVEL". This will apply the specified isolation level (e.g. ISOLATION_SERIALIZABLE) to all JDBC connections that participate in the given transaction.

Invokes WebLogic's special forceResume method if standard JTA resume failed, to also resume if the target transaction was marked rollback-only. If you're not relying on this feature of transaction suspension in the first place, Spring's standard JtaTransactionManager will behave properly too.

Automatically detects WebLogic Server 7.0 or 8.1+ and adapts accordingly. Usage on a WebLogic client is also supported, although with restricted functionality: transaction names cannot be applied there.

By default, the JTA UserTransaction and TransactionManager handles are fetched directly from WebLogic's TransactionHelper (on 8.1+) or TxHelper (on 7.0). This can be overridden by specifying "userTransaction"/"userTransactionName" and "transactionManager"/"transactionManagerName", passing in existing handles or specifying corresponding JNDI locations to look up.

Since:
1.1
Author:
Juergen Hoeller
See Also:
TransactionDefinition.getName(), weblogic.transaction.UserTransaction#begin(String), TransactionDefinition.getIsolationLevel(), weblogic.transaction.Transaction#setProperty, weblogic.transaction.TransactionManager#forceResume, weblogic.transaction.TransactionHelper, weblogic.transaction.TxHelper, Serialized Form

Field Summary
 
Fields inherited from class org.springframework.transaction.jta.JtaTransactionManager
DEFAULT_USER_TRANSACTION_NAME, FALLBACK_TRANSACTION_MANAGER_NAMES
 
Fields inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION
 
Constructor Summary
WebLogicJtaTransactionManager()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  void doJtaBegin(JtaTransactionObject txObject, TransactionDefinition definition)
          Perform a JTA begin on the JTA UserTransaction or TransactionManager.
protected  void doJtaResume(JtaTransactionObject txObject, Object suspendedTransaction)
          Perform a JTA resume on the JTA TransactionManager.
protected  TransactionManager retrieveTransactionManager()
          Allows subclasses to retrieve the JTA TransactionManager in a vendor-specific manner.
protected  UserTransaction retrieveUserTransaction()
          Allows subclasses to retrieve the JTA UserTransaction in a vendor-specific manner.
 
Methods inherited from class org.springframework.transaction.jta.JtaTransactionManager
applyIsolationLevel, applyTimeout, doBegin, doCommit, doGetJtaTransaction, doGetTransaction, doJtaSuspend, doRegisterAfterCompletionWithJtaTransaction, doResume, doRollback, doSetRollbackOnly, doSuspend, findTransactionManager, getJndiEnvironment, getJndiTemplate, getTransactionManager, getUserTransaction, isExistingTransaction, lookupTransactionManager, lookupUserTransaction, registerAfterCompletionWithExistingTransaction, setAllowCustomIsolationLevels, setAutodetectTransactionManager, setCacheUserTransaction, setJndiEnvironment, setJndiTemplate, setTransactionManager, setTransactionManagerName, setUserTransaction, setUserTransactionName, shouldCommitOnGlobalRollbackOnly, useSavepointForNestedTransaction
 
Methods inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
commit, doCleanupAfterCompletion, getTransaction, getTransactionSynchronization, invokeAfterCompletion, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, newTransactionStatus, rollback, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionSynchronization, setTransactionSynchronizationName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebLogicJtaTransactionManager

public WebLogicJtaTransactionManager()
                              throws TransactionSystemException
Throws:
TransactionSystemException
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws TransactionSystemException
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class JtaTransactionManager
Throws:
TransactionSystemException

retrieveUserTransaction

protected UserTransaction retrieveUserTransaction()
                                           throws TransactionSystemException
Description copied from class: JtaTransactionManager
Allows subclasses to retrieve the JTA UserTransaction in a vendor-specific manner. Only called if no "userTransaction" or "userTransactionName" specified.

The default implementation simply returns null.

Overrides:
retrieveUserTransaction in class JtaTransactionManager
Returns:
the JTA UserTransaction handle to use, or null if none found
Throws:
TransactionSystemException - in case of errors
See Also:
JtaTransactionManager.setUserTransaction(javax.transaction.UserTransaction), JtaTransactionManager.setUserTransactionName(java.lang.String)

retrieveTransactionManager

protected TransactionManager retrieveTransactionManager()
                                                 throws TransactionSystemException
Description copied from class: JtaTransactionManager
Allows subclasses to retrieve the JTA TransactionManager in a vendor-specific manner. Only called if no "transactionManager" or "transactionManagerName" specified.

The default implementation simply returns null.

Overrides:
retrieveTransactionManager in class JtaTransactionManager
Returns:
the JTA TransactionManager handle to use, or null if none found
Throws:
TransactionSystemException - in case of errors
See Also:
JtaTransactionManager.setTransactionManager(javax.transaction.TransactionManager), JtaTransactionManager.setTransactionManagerName(java.lang.String)

doJtaBegin

protected void doJtaBegin(JtaTransactionObject txObject,
                          TransactionDefinition definition)
                   throws NotSupportedException,
                          SystemException
Description copied from class: JtaTransactionManager
Perform a JTA begin on the JTA UserTransaction or TransactionManager.

This implementation only supports standard JTA functionality: that is, no per-transaction isolation levels and no transaction names. Can be overridden in subclasses, for specific JTA implementations.

Calls applyIsolationLevel and applyTimeout before invoking the UserTransaction's begin method.

Overrides:
doJtaBegin in class JtaTransactionManager
Parameters:
txObject - the JtaTransactionObject containing the UserTransaction
definition - TransactionDefinition instance, describing propagation behavior, isolation level, read-only flag, timeout, and transaction name
Throws:
NotSupportedException - if thrown by JTA methods
SystemException - if thrown by JTA methods
See Also:
JtaTransactionManager.getUserTransaction(), JtaTransactionManager.getTransactionManager(), JtaTransactionManager.applyIsolationLevel(org.springframework.transaction.jta.JtaTransactionObject, int), JtaTransactionManager.applyTimeout(org.springframework.transaction.jta.JtaTransactionObject, int), JtaTransactionObject.getUserTransaction(), UserTransaction.setTransactionTimeout(int), UserTransaction.begin()

doJtaResume

protected void doJtaResume(JtaTransactionObject txObject,
                           Object suspendedTransaction)
                    throws InvalidTransactionException,
                           SystemException
Description copied from class: JtaTransactionManager
Perform a JTA resume on the JTA TransactionManager.

Can be overridden in subclasses, for specific JTA implementations.

Overrides:
doJtaResume in class JtaTransactionManager
Parameters:
txObject - the JtaTransactionObject containing the UserTransaction
suspendedTransaction - the suspended JTA Transaction object
Throws:
InvalidTransactionException - if thrown by JTA methods
SystemException - if thrown by JTA methods
See Also:
JtaTransactionManager.getTransactionManager(), TransactionManager.resume(javax.transaction.Transaction)

The Spring Framework

Copyright © 2002-2006 The Spring Framework.