public class

WebSphereUowTransactionManager

extends JtaTransactionManager
implements CallbackPreferringPlatformTransactionManager
java.lang.Object
   ↳ org.springframework.transaction.support.AbstractPlatformTransactionManager
     ↳ org.springframework.transaction.jta.JtaTransactionManager
       ↳ org.springframework.transaction.jta.WebSphereUowTransactionManager

Class Overview

WebSphere-specific PlatformTransactionManager implementation that delegates to a com.ibm.wsspi.uow.UOWManager instance, obtained from WebSphere's JNDI environment. This allows Spring to leverage the full power of the WebSphere transaction coordinator, including transaction suspension, in a manner that is perfectly compliant with officially supported WebSphere API.

The CallbackPreferringPlatformTransactionManager interface implemented by this class indicates that callers should preferably pass in a TransactionCallback through the execute(TransactionDefinition, TransactionCallback) method, which will be handled through the callback-based WebSphere UOWManager API instead of through standard JTA API (UserTransaction / TransactionManager). This avoids the use of the non-public javax.transaction.TransactionManager API on WebSphere, staying within supported WebSphere API boundaries.

This transaction manager implementation derives from Spring's standard JtaTransactionManager, inheriting the capability to support programmatic transaction demarcation via getTransaction / commit / rollback calls through a JTA UserTransaction handle, for callers that do not use the TransactionCallback-based execute(TransactionDefinition, TransactionCallback) method. However, transaction suspension is not supported in this getTransaction style (unless you explicitly specify a setTransactionManager(TransactionManager) reference, despite the official WebSphere recommendations). Use the execute(TransactionDefinition, TransactionCallback) style for any code that might require transaction suspension.

This transaction manager is compatible with WebSphere 6.1.0.9 and above. The default JNDI location for the UOWManager is "java:comp/websphere/UOWManager". If the location happens to differ according to your WebSphere documentation, simply specify the actual location through this transaction manager's "uowManagerName" bean property.

See Also

Summary

Constants
String DEFAULT_UOW_MANAGER_NAME Default JNDI location for the WebSphere UOWManager.
[Expand]
Inherited Constants
From class org.springframework.transaction.jta.JtaTransactionManager
From class org.springframework.transaction.support.AbstractPlatformTransactionManager
[Expand]
Inherited Fields
From class org.springframework.transaction.jta.JtaTransactionManager
From class org.springframework.transaction.support.AbstractPlatformTransactionManager
Public Constructors
WebSphereUowTransactionManager()
Create a new WebSphereUowTransactionManager.
WebSphereUowTransactionManager(UOWManager uowManager)
Create a new WebSphereUowTransactionManager for the given UOWManager.
Public Methods
void afterPropertiesSet()
Initialize the UserTransaction as well as the TransactionManager handle.
<T> T execute(TransactionDefinition definition, TransactionCallback<T> callback)
Execute the action specified by the given callback object within a transaction.
void setUowManager(UOWManager uowManager)
Set the WebSphere UOWManager to use as direct reference.
void setUowManagerName(String uowManagerName)
Set the JNDI name of the WebSphere UOWManager.
boolean supportsResourceAdapterManagedTransactions()
Returns true since WebSphere ResourceAdapters (as exposed in JNDI) implicitly perform transaction enlistment if the MessageEndpointFactory's isDeliveryTransacted method returns true.
Protected Methods
void doRegisterAfterCompletionWithJtaTransaction(JtaTransactionObject txObject, List<TransactionSynchronization> synchronizations)
Registers the synchronizations as interposed JTA Synchronization on the UOWManager.
UOWManager lookupDefaultUowManager()
Obtain the WebSphere UOWManager from the default JNDI location "java:comp/websphere/UOWManager".
UOWManager lookupUowManager(String uowManagerName)
Look up the WebSphere UOWManager in JNDI via the configured name.
[Expand]
Inherited Methods
From class org.springframework.transaction.jta.JtaTransactionManager
From class org.springframework.transaction.support.AbstractPlatformTransactionManager
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.transaction.PlatformTransactionManager
From interface org.springframework.transaction.jta.TransactionFactory
From interface org.springframework.transaction.support.CallbackPreferringPlatformTransactionManager

Constants

public static final String DEFAULT_UOW_MANAGER_NAME

Default JNDI location for the WebSphere UOWManager.

Constant Value: "java:comp/websphere/UOWManager"

Public Constructors

public WebSphereUowTransactionManager ()

Create a new WebSphereUowTransactionManager.

public WebSphereUowTransactionManager (UOWManager uowManager)

Create a new WebSphereUowTransactionManager for the given UOWManager.

Parameters
uowManager the WebSphere UOWManager to use as direct reference

Public Methods

public void afterPropertiesSet ()

Initialize the UserTransaction as well as the TransactionManager handle.

public T execute (TransactionDefinition definition, TransactionCallback<T> callback)

Execute the action specified by the given callback object within a transaction.

Allows for returning a result object created within the transaction, that is, a domain object or a collection of domain objects. A RuntimeException thrown by the callback is treated as a fatal exception that enforces a rollback. Such an exception gets propagated to the caller of the template.

Parameters
definition the definition for the transaction to wrap the callback in
callback the callback object that specifies the transactional action
Returns
  • a result object returned by the callback, or null if none

public void setUowManager (UOWManager uowManager)

Set the WebSphere UOWManager to use as direct reference.

Typically just used for test setups; in a J2EE environment, the UOWManager will always be fetched from JNDI.

public void setUowManagerName (String uowManagerName)

Set the JNDI name of the WebSphere UOWManager. The default "java:comp/websphere/UOWManager" is used if not set.

public boolean supportsResourceAdapterManagedTransactions ()

Returns true since WebSphere ResourceAdapters (as exposed in JNDI) implicitly perform transaction enlistment if the MessageEndpointFactory's isDeliveryTransacted method returns true. In that case we'll simply skip the createTransaction(String, int) call.

See Also

Protected Methods

protected void doRegisterAfterCompletionWithJtaTransaction (JtaTransactionObject txObject, List<TransactionSynchronization> synchronizations)

Registers the synchronizations as interposed JTA Synchronization on the UOWManager.

Parameters
txObject the current transaction object
synchronizations List of TransactionSynchronization objects

protected UOWManager lookupDefaultUowManager ()

Obtain the WebSphere UOWManager from the default JNDI location "java:comp/websphere/UOWManager".

Returns
  • the UOWManager object
Throws
TransactionSystemException if the JNDI lookup failed

protected UOWManager lookupUowManager (String uowManagerName)

Look up the WebSphere UOWManager in JNDI via the configured name.

Parameters
uowManagerName the JNDI name of the UOWManager
Returns
  • the UOWManager object
Throws
TransactionSystemException if the JNDI lookup failed