|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -81,29 +81,28 @@ import org.springframework.util.StringUtils; |
|
|
|
* Almost all Java EE servers expose it, but do so as extension to EE. There might be some |
|
|
|
* Almost all Java EE servers expose it, but do so as extension to EE. There might be some |
|
|
|
* issues with compatibility, despite the TransactionManager interface being part of JTA. |
|
|
|
* issues with compatibility, despite the TransactionManager interface being part of JTA. |
|
|
|
* As a consequence, Spring provides various vendor-specific PlatformTransactionManagers, |
|
|
|
* As a consequence, Spring provides various vendor-specific PlatformTransactionManagers, |
|
|
|
* which are recommended to be used if appropriate: {@link WebLogicJtaTransactionManager}, |
|
|
|
* which are recommended to be used if appropriate: {@link WebLogicJtaTransactionManager} |
|
|
|
* {@link WebSphereUowTransactionManager} and {@link OC4JJtaTransactionManager}. |
|
|
|
* and {@link WebSphereUowTransactionManager}. For all other Java EE servers, the |
|
|
|
* For all other Java EE servers, the standard JtaTransactionManager is sufficient. |
|
|
|
* standard JtaTransactionManager is sufficient. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>This pure JtaTransactionManager class supports timeouts but not per-transaction |
|
|
|
* <p>This pure JtaTransactionManager class supports timeouts but not per-transaction |
|
|
|
* isolation levels. Custom subclasses may override the {@link #doJtaBegin} method for |
|
|
|
* isolation levels. Custom subclasses may override the {@link #doJtaBegin} method for |
|
|
|
* specific JTA extensions in order to provide this functionality; Spring includes |
|
|
|
* specific JTA extensions in order to provide this functionality; Spring includes a |
|
|
|
* corresponding {@link WebLogicJtaTransactionManager} and {@link OC4JJtaTransactionManager} |
|
|
|
* corresponding {@link WebLogicJtaTransactionManager} class for WebLogic Server. Such |
|
|
|
* classes, for BEA's WebLogic Server and Oracle's OC4J, respectively. Such adapters |
|
|
|
* adapters for specific Java EE transaction coordinators may also expose transaction |
|
|
|
* for specific Java EE transaction coordinators may also expose transaction names for |
|
|
|
* names for monitoring; with standard JTA, transaction names will simply be ignored. |
|
|
|
* monitoring; with standard JTA, transaction names will simply be ignored. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p><b>Consider using Spring's {@code tx:jta-transaction-manager} configuration |
|
|
|
* <p><b>Consider using Spring's {@code tx:jta-transaction-manager} configuration |
|
|
|
* element for automatically picking the appropriate JTA platform transaction manager |
|
|
|
* element for automatically picking the appropriate JTA platform transaction manager |
|
|
|
* (automatically detecting WebLogic, WebSphere and OC4J).</b> |
|
|
|
* (automatically detecting WebLogic and WebSphere).</b> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>JTA 1.1 adds the TransactionSynchronizationRegistry facility, as public Java EE 5 |
|
|
|
* <p>JTA 1.1 adds the TransactionSynchronizationRegistry facility, as public Java EE 5 |
|
|
|
* API in addition to the standard JTA UserTransaction handle. As of Spring 2.5, this |
|
|
|
* API in addition to the standard JTA UserTransaction handle. As of Spring 2.5, this |
|
|
|
* JtaTransactionManager autodetects the TransactionSynchronizationRegistry and uses |
|
|
|
* JtaTransactionManager autodetects the TransactionSynchronizationRegistry and uses |
|
|
|
* it for registering Spring-managed synchronizations when participating in an existing |
|
|
|
* it for registering Spring-managed synchronizations when participating in an existing |
|
|
|
* JTA transaction (e.g. controlled by EJB CMT). If no TransactionSynchronizationRegistry |
|
|
|
* JTA transaction (e.g. controlled by EJB CMT). If no TransactionSynchronizationRegistry |
|
|
|
* is available (or the JTA 1.1 API isn't available), then such synchronizations |
|
|
|
* is available (or the JTA 1.1 API isn't available), then such synchronizations will be |
|
|
|
* will be registered via the (non-EE) JTA TransactionManager handle. |
|
|
|
* registered via the (non-EE) JTA TransactionManager handle. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>This class is serializable. However, active synchronizations do not survive serialization. |
|
|
|
* <p>This class is serializable. However, active synchronizations do not survive serialization. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -346,7 +345,7 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the JTA TransactionManager that this transaction manager uses. |
|
|
|
* Return the JTA TransactionManager that this transaction manager uses, if any. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public TransactionManager getTransactionManager() { |
|
|
|
public TransactionManager getTransactionManager() { |
|
|
|
return this.transactionManager; |
|
|
|
return this.transactionManager; |
|
|
|
@ -449,7 +448,7 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Autodetect UserTransaction object that implements TransactionManager,
|
|
|
|
// Autodetect UserTransaction object that implements TransactionManager,
|
|
|
|
// and check fallback JNDI locations else.
|
|
|
|
// and check fallback JNDI locations otherwise.
|
|
|
|
if (this.transactionManager == null && this.autodetectTransactionManager) { |
|
|
|
if (this.transactionManager == null && this.autodetectTransactionManager) { |
|
|
|
this.transactionManager = findTransactionManager(this.userTransaction); |
|
|
|
this.transactionManager = findTransactionManager(this.userTransaction); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -738,8 +737,7 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager |
|
|
|
} |
|
|
|
} |
|
|
|
catch (NamingException ex) { |
|
|
|
catch (NamingException ex) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug( |
|
|
|
logger.debug("No JTA TransactionSynchronizationRegistry found at default JNDI location [" + jndiName + "]", ex); |
|
|
|
"No JTA TransactionSynchronizationRegistry found at default JNDI location [" + jndiName + "]", ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -825,12 +823,12 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
// assume nested transaction not supported
|
|
|
|
// assume nested transaction not supported
|
|
|
|
throw new NestedTransactionNotSupportedException( |
|
|
|
throw new NestedTransactionNotSupportedException( |
|
|
|
"JTA implementation does not support nested transactions", ex); |
|
|
|
"JTA implementation does not support nested transactions", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (UnsupportedOperationException ex) { |
|
|
|
catch (UnsupportedOperationException ex) { |
|
|
|
// assume nested transaction not supported
|
|
|
|
// assume nested transaction not supported
|
|
|
|
throw new NestedTransactionNotSupportedException( |
|
|
|
throw new NestedTransactionNotSupportedException( |
|
|
|
"JTA implementation does not support nested transactions", ex); |
|
|
|
"JTA implementation does not support nested transactions", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (SystemException ex) { |
|
|
|
catch (SystemException ex) { |
|
|
|
throw new CannotCreateTransactionException("JTA failure on begin", ex); |
|
|
|
throw new CannotCreateTransactionException("JTA failure on begin", ex); |
|
|
|
@ -885,8 +883,8 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager |
|
|
|
|
|
|
|
|
|
|
|
if (!this.allowCustomIsolationLevels && isolationLevel != TransactionDefinition.ISOLATION_DEFAULT) { |
|
|
|
if (!this.allowCustomIsolationLevels && isolationLevel != TransactionDefinition.ISOLATION_DEFAULT) { |
|
|
|
throw new InvalidIsolationLevelException( |
|
|
|
throw new InvalidIsolationLevelException( |
|
|
|
"JtaTransactionManager does not support custom isolation levels by default - " + |
|
|
|
"JtaTransactionManager does not support custom isolation levels by default - " + |
|
|
|
"switch 'allowCustomIsolationLevels' to 'true'"); |
|
|
|
"switch 'allowCustomIsolationLevels' to 'true'"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|