|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.transaction.support.AbstractPlatformTransactionManager org.springframework.transaction.jta.JtaTransactionManager org.springframework.transaction.jta.WebSphereUowTransactionManager
public class WebSphereUowTransactionManager
WebSphere-specific PlatformTransactionManager implementation that delegates
to a 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(org.springframework.transaction.TransactionDefinition, org.springframework.transaction.support.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(org.springframework.transaction.TransactionDefinition, org.springframework.transaction.support.TransactionCallback)
method. However,
transaction suspension is not supported in this getTransaction
style (unless you explicitly specify a JtaTransactionManager.setTransactionManager(javax.transaction.TransactionManager)
reference,
despite the official WebSphere recommendations). Use the execute(org.springframework.transaction.TransactionDefinition, org.springframework.transaction.support.TransactionCallback)
style
for any code that might require transaction suspension.
This transaction manager is compatible with WebSphere 7.0 as well as recent
WebSphere 6.0.x and 6.1.x versions. Check the documentation for your specific
WebSphere version to find out whether UOWManager support is available. If it
is not available, consider using Spring's standard JtaTransactionManager
class, if necessary specifying the WebSphereTransactionManagerFactoryBean
as "transactionManager" through the corresponding bean property. However, note
that transaction suspension is not officially supported in such a scenario
(despite it being known to work properly).
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.
setUowManager(com.ibm.wsspi.uow.UOWManager)
,
setUowManagerName(java.lang.String)
,
UOWManager
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager |
---|
AbstractPlatformTransactionManager.SuspendedResourcesHolder |
Field Summary | |
---|---|
static String |
DEFAULT_UOW_MANAGER_NAME
Default JNDI location for the WebSphere UOWManager. |
Fields inherited from class org.springframework.transaction.jta.JtaTransactionManager |
---|
DEFAULT_TRANSACTION_SYNCHRONIZATION_REGISTRY_NAME, 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 | |
---|---|
WebSphereUowTransactionManager()
Create a new WebSphereUowTransactionManager. |
|
WebSphereUowTransactionManager(com.ibm.wsspi.uow.UOWManager uowManager)
Create a new WebSphereUowTransactionManager for the given UOWManager. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
Initialize the UserTransaction as well as the TransactionManager handle. |
Object |
execute(TransactionDefinition definition,
TransactionCallback callback)
Execute the action specified by the given callback object within a transaction. |
protected com.ibm.wsspi.uow.UOWManager |
lookupUowManager(String uowManagerName)
Look up the WebSphere UOWManager in JNDI via the configured name. |
void |
setUowManager(com.ibm.wsspi.uow.UOWManager uowManager)
Set the WebSphere UOWManager to use as direct reference. |
void |
setUowManagerName(String uowManagerName)
Set the JNDI name of the WebSphere UOWManager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.transaction.PlatformTransactionManager |
---|
commit, getTransaction, rollback |
Field Detail |
---|
public static final String DEFAULT_UOW_MANAGER_NAME
Constructor Detail |
---|
public WebSphereUowTransactionManager()
public WebSphereUowTransactionManager(com.ibm.wsspi.uow.UOWManager uowManager)
uowManager
- the WebSphere UOWManager to use as direct referenceMethod Detail |
---|
public void setUowManager(com.ibm.wsspi.uow.UOWManager uowManager)
Typically just used for test setups; in a J2EE environment, the UOWManager will always be fetched from JNDI.
public void setUowManagerName(String uowManagerName)
public void afterPropertiesSet() throws TransactionSystemException
JtaTransactionManager
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class JtaTransactionManager
protected com.ibm.wsspi.uow.UOWManager lookupUowManager(String uowManagerName) throws TransactionSystemException
afterPropertiesSet
if no direct UOWManager reference was set.
Can be overridden in subclasses to provide a different UOWManager object.
uowManagerName
- the JNDI name of the UOWManager
TransactionSystemException
- if the JNDI lookup failedJtaTransactionManager.setJndiTemplate(org.springframework.jndi.JndiTemplate)
,
setUowManagerName(java.lang.String)
public Object execute(TransactionDefinition definition, TransactionCallback callback) throws TransactionException
CallbackPreferringPlatformTransactionManager
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.
execute
in interface CallbackPreferringPlatformTransactionManager
definition
- the definition for the transaction to wrap the callback incallback
- the callback object that specifies the transactional action
null
if none
TransactionException
- in case of initialization, rollback, or system errors
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |