| Method from org.springframework.transaction.jta.JtaTransactionManager Detail: |
public void afterPropertiesSet() throws TransactionSystemException {
initUserTransactionAndTransactionManager();
checkUserTransactionAndTransactionManager();
initTransactionSynchronizationRegistry();
}
Initialize the UserTransaction as well as the TransactionManager handle. |
protected void applyIsolationLevel(JtaTransactionObject txObject,
int isolationLevel) throws SystemException, InvalidIsolationLevelException {
if (!this.allowCustomIsolationLevels && isolationLevel != TransactionDefinition.ISOLATION_DEFAULT) {
throw new InvalidIsolationLevelException(
"JtaTransactionManager does not support custom isolation levels by default - " +
"switch 'allowCustomIsolationLevels' to 'true'");
}
}
Apply the given transaction isolation level. The default implementation
will throw an exception for any level other than ISOLATION_DEFAULT.
To be overridden in subclasses for specific JTA implementations,
as alternative to overriding the full #doJtaBegin method. |
protected void applyTimeout(JtaTransactionObject txObject,
int timeout) throws SystemException {
if (timeout > TransactionDefinition.TIMEOUT_DEFAULT) {
txObject.getUserTransaction().setTransactionTimeout(timeout);
}
}
Apply the given transaction timeout. The default implementation will call
UserTransaction.setTransactionTimeout for a non-default timeout value. |
protected UserTransaction buildUserTransaction(TransactionManager transactionManager) {
if (transactionManager instanceof UserTransaction) {
return (UserTransaction) transactionManager;
}
else {
return new UserTransactionAdapter(transactionManager);
}
}
Build a UserTransaction handle based on the given TransactionManager. |
protected void checkUserTransactionAndTransactionManager() throws IllegalStateException {
// We at least need the JTA UserTransaction.
if (this.userTransaction != null) {
if (logger.isInfoEnabled()) {
logger.info("Using JTA UserTransaction: " + this.userTransaction);
}
}
else {
throw new IllegalStateException("No JTA UserTransaction available - specify either " +
"'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManagerName'");
}
// For transaction suspension, the JTA TransactionManager is necessary too.
if (this.transactionManager != null) {
if (logger.isInfoEnabled()) {
logger.info("Using JTA TransactionManager: " + this.transactionManager);
}
}
else {
logger.warn("No JTA TransactionManager found: " +
"transaction suspension and synchronization with existing JTA transactions not available");
}
}
Check the UserTransaction as well as the TransactionManager handle,
assuming standard JTA requirements. |
public Transaction createTransaction(String name,
int timeout) throws SystemException, NotSupportedException {
TransactionManager tm = getTransactionManager();
Assert.state(tm != null, "No JTA TransactionManager available");
if (timeout >= 0) {
tm.setTransactionTimeout(timeout);
}
tm.begin();
return tm.getTransaction();
}
|
protected void doBegin(Object transaction,
TransactionDefinition definition) {
JtaTransactionObject txObject = (JtaTransactionObject) transaction;
try {
doJtaBegin(txObject, definition);
}
catch (NotSupportedException ex) {
// assume nested transaction not supported
throw new NestedTransactionNotSupportedException(
"JTA implementation does not support nested transactions", ex);
}
catch (UnsupportedOperationException ex) {
// assume nested transaction not supported
throw new NestedTransactionNotSupportedException(
"JTA implementation does not support nested transactions", ex);
}
catch (SystemException ex) {
throw new CannotCreateTransactionException("JTA failure on begin", ex);
}
}
|
protected void doCommit(DefaultTransactionStatus status) {
JtaTransactionObject txObject = (JtaTransactionObject) status.getTransaction();
try {
int jtaStatus = txObject.getUserTransaction().getStatus();
if (jtaStatus == Status.STATUS_NO_TRANSACTION) {
// Should never happen... would have thrown an exception before
// and as a consequence led to a rollback, not to a commit call.
// In any case, the transaction is already fully cleaned up.
throw new UnexpectedRollbackException("JTA transaction already completed - probably rolled back");
}
if (jtaStatus == Status.STATUS_ROLLEDBACK) {
// Only really happens on JBoss 4.2 in case of an early timeout...
// Explicit rollback call necessary to clean up the transaction.
// IllegalStateException expected on JBoss; call still necessary.
try {
txObject.getUserTransaction().rollback();
}
catch (IllegalStateException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Rollback failure with transaction already marked as rolled back: " + ex);
}
}
throw new UnexpectedRollbackException("JTA transaction already rolled back (probably due to a timeout)");
}
txObject.getUserTransaction().commit();
}
catch (RollbackException ex) {
throw new UnexpectedRollbackException(
"JTA transaction unexpectedly rolled back (maybe due to a timeout)", ex);
}
catch (HeuristicMixedException ex) {
throw new HeuristicCompletionException(HeuristicCompletionException.STATE_MIXED, ex);
}
catch (HeuristicRollbackException ex) {
throw new HeuristicCompletionException(HeuristicCompletionException.STATE_ROLLED_BACK, ex);
}
catch (IllegalStateException ex) {
throw new TransactionSystemException("Unexpected internal transaction state", ex);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on commit", ex);
}
}
|
protected JtaTransactionObject doGetJtaTransaction(UserTransaction ut) {
return new JtaTransactionObject(ut);
}
Get a JTA transaction object for the given current UserTransaction.
Subclasses can override this to provide a JtaTransactionObject
subclass, for example holding some additional JTA handle needed. |
protected Object doGetTransaction() {
UserTransaction ut = getUserTransaction();
if (ut == null) {
throw new CannotCreateTransactionException("No JTA UserTransaction available - " +
"programmatic PlatformTransactionManager.getTransaction usage not supported");
}
if (!this.cacheUserTransaction) {
ut = lookupUserTransaction(
this.userTransactionName != null ? this.userTransactionName : DEFAULT_USER_TRANSACTION_NAME);
}
return doGetJtaTransaction(ut);
}
This implementation returns a JtaTransactionObject instance for the
JTA UserTransaction.
The UserTransaction object will either be looked up freshly for the
current transaction, or the cached one looked up at startup will be used.
The latter is the default: Most application servers use a shared singleton
UserTransaction that can be cached. Turn off the "cacheUserTransaction"
flag to enforce a fresh lookup for every transaction. |
protected void doJtaBegin(JtaTransactionObject txObject,
TransactionDefinition definition) throws SystemException, NotSupportedException {
applyIsolationLevel(txObject, definition.getIsolationLevel());
int timeout = determineTimeout(definition);
applyTimeout(txObject, timeout);
txObject.getUserTransaction().begin();
}
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. |
protected void doJtaResume(JtaTransactionObject txObject,
Object suspendedTransaction) throws SystemException, InvalidTransactionException {
if (getTransactionManager() == null) {
throw new TransactionSuspensionNotSupportedException(
"JtaTransactionManager needs a JTA TransactionManager for suspending a transaction: " +
"specify the 'transactionManager' or 'transactionManagerName' property");
}
getTransactionManager().resume((Transaction) suspendedTransaction);
}
Perform a JTA resume on the JTA TransactionManager.
Can be overridden in subclasses, for specific JTA implementations. |
protected Object doJtaSuspend(JtaTransactionObject txObject) throws SystemException {
if (getTransactionManager() == null) {
throw new TransactionSuspensionNotSupportedException(
"JtaTransactionManager needs a JTA TransactionManager for suspending a transaction: " +
"specify the 'transactionManager' or 'transactionManagerName' property");
}
return getTransactionManager().suspend();
}
Perform a JTA suspend on the JTA TransactionManager.
Can be overridden in subclasses, for specific JTA implementations. |
protected void doRegisterAfterCompletionWithJtaTransaction(JtaTransactionObject txObject,
List synchronizations) throws SystemException, RollbackException {
int jtaStatus = txObject.getUserTransaction().getStatus();
if (jtaStatus == Status.STATUS_NO_TRANSACTION) {
throw new RollbackException("JTA transaction already completed - probably rolled back");
}
if (jtaStatus == Status.STATUS_ROLLEDBACK) {
throw new RollbackException("JTA transaction already rolled back (probably due to a timeout)");
}
if (this.transactionSynchronizationRegistry != null) {
// JTA 1.1 TransactionSynchronizationRegistry available - use it.
new InterposedSynchronizationDelegate().registerInterposedSynchronization(
new JtaAfterCompletionSynchronization(synchronizations));
}
else if (getTransactionManager() != null) {
// At least the JTA TransactionManager available - use that one.
Transaction transaction = getTransactionManager().getTransaction();
if (transaction == null) {
throw new IllegalStateException("No JTA Transaction available");
}
transaction.registerSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
}
else {
// No JTA TransactionManager available - log a warning.
logger.warn("Participating in existing JTA transaction, but no JTA TransactionManager available: " +
"cannot register Spring after-completion callbacks with outer JTA transaction - " +
"processing Spring after-completion callbacks with outcome status 'unknown'");
invokeAfterCompletion(synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
}
}
Register a JTA synchronization on the JTA TransactionManager, for calling
afterCompletion on the given Spring TransactionSynchronizations.
The default implementation registers the synchronizations on the
JTA 1.1 TransactionSynchronizationRegistry, if available, or on the
JTA TransactionManager's current Transaction - again, if available.
If none of the two is available, a warning will be logged.
Can be overridden in subclasses, for specific JTA implementations. |
protected void doResume(Object transaction,
Object suspendedResources) {
JtaTransactionObject txObject = (JtaTransactionObject) transaction;
try {
doJtaResume(txObject, suspendedResources);
}
catch (InvalidTransactionException ex) {
throw new IllegalTransactionStateException("Tried to resume invalid JTA transaction", ex);
}
catch (IllegalStateException ex) {
throw new TransactionSystemException("Unexpected internal transaction state", ex);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on resume", ex);
}
}
|
protected void doRollback(DefaultTransactionStatus status) {
JtaTransactionObject txObject = (JtaTransactionObject) status.getTransaction();
try {
int jtaStatus = txObject.getUserTransaction().getStatus();
if (jtaStatus != Status.STATUS_NO_TRANSACTION) {
try {
txObject.getUserTransaction().rollback();
}
catch (IllegalStateException ex) {
if (jtaStatus == Status.STATUS_ROLLEDBACK) {
// Only really happens on JBoss 4.2 in case of an early timeout...
if (logger.isDebugEnabled()) {
logger.debug("Rollback failure with transaction already marked as rolled back: " + ex);
}
}
else {
throw new TransactionSystemException("Unexpected internal transaction state", ex);
}
}
}
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on rollback", ex);
}
}
|
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
JtaTransactionObject txObject = (JtaTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Setting JTA transaction rollback-only");
}
try {
int jtaStatus = txObject.getUserTransaction().getStatus();
if (jtaStatus != Status.STATUS_NO_TRANSACTION && jtaStatus != Status.STATUS_ROLLEDBACK) {
txObject.getUserTransaction().setRollbackOnly();
}
}
catch (IllegalStateException ex) {
throw new TransactionSystemException("Unexpected internal transaction state", ex);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on setRollbackOnly", ex);
}
}
|
protected Object doSuspend(Object transaction) {
JtaTransactionObject txObject = (JtaTransactionObject) transaction;
try {
return doJtaSuspend(txObject);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on suspend", ex);
}
}
|
protected TransactionManager findTransactionManager(UserTransaction ut) {
if (ut instanceof TransactionManager) {
if (logger.isDebugEnabled()) {
logger.debug("JTA UserTransaction object [" + ut + "] implements TransactionManager");
}
return (TransactionManager) ut;
}
// Check fallback JNDI locations.
for (int i = 0; i < FALLBACK_TRANSACTION_MANAGER_NAMES.length; i++) {
String jndiName = FALLBACK_TRANSACTION_MANAGER_NAMES[i];
try {
TransactionManager tm = (TransactionManager) getJndiTemplate().lookup(jndiName, TransactionManager.class);
if (logger.isDebugEnabled()) {
logger.debug("JTA TransactionManager found at fallback JNDI location [" + jndiName + "]");
}
return tm;
}
catch (NamingException ex) {
if (logger.isDebugEnabled()) {
logger.debug("No JTA TransactionManager found at fallback JNDI location [" + jndiName + "]", ex);
}
}
}
// OK, so no JTA TransactionManager is available...
return null;
}
Find the JTA TransactionManager through autodetection: checking whether the
UserTransaction object implements the TransactionManager, and checking the
fallback JNDI locations. |
protected Object findTransactionSynchronizationRegistry(UserTransaction ut,
TransactionManager tm) throws TransactionSystemException {
try {
Class registryClass = ClassUtils.forName(TRANSACTION_SYNCHRONIZATION_REGISTRY_CLASS_NAME,
JtaTransactionManager.class.getClassLoader());
// If we came here, we might be on Java EE 5, since the JTA 1.1 API is present.
if (this.userTransactionObtainedFromJndi) {
// UserTransaction has already been obtained from JNDI, so the
// TransactionSynchronizationRegistry probably sits there as well.
String jndiName = DEFAULT_TRANSACTION_SYNCHRONIZATION_REGISTRY_NAME;
try {
Object tsr = getJndiTemplate().lookup(jndiName, registryClass);
if (logger.isDebugEnabled()) {
logger.debug("JTA TransactionSynchronizationRegistry found at default JNDI location [" + jndiName + "]");
}
return tsr;
}
catch (NamingException ex) {
if (logger.isDebugEnabled()) {
logger.debug(
"No JTA TransactionSynchronizationRegistry found at default JNDI location [" + jndiName + "]", ex);
}
}
}
// Check whether the UserTransaction or TransactionManager implements it...
if (registryClass.isInstance(ut)) {
return ut;
}
if (registryClass.isInstance(tm)) {
return tm;
}
// OK, so no JTA 1.1 TransactionSynchronizationRegistry is available,
// despite the API being present...
return null;
}
catch (ClassNotFoundException ex) {
logger.debug("JTA 1.1 [" + TRANSACTION_SYNCHRONIZATION_REGISTRY_CLASS_NAME + "] not available");
return null;
}
}
|
protected UserTransaction findUserTransaction() {
String jndiName = DEFAULT_USER_TRANSACTION_NAME;
try {
UserTransaction ut = (UserTransaction) getJndiTemplate().lookup(jndiName, UserTransaction.class);
if (logger.isDebugEnabled()) {
logger.debug("JTA UserTransaction found at default JNDI location [" + jndiName + "]");
}
this.userTransactionObtainedFromJndi = true;
return ut;
}
catch (NamingException ex) {
if (logger.isDebugEnabled()) {
logger.debug("No JTA UserTransaction found at default JNDI location [" + jndiName + "]", ex);
}
return null;
}
}
Find the JTA UserTransaction through a default JNDI lookup:
"java:comp/UserTransaction". |
public Properties getJndiEnvironment() {
return this.jndiTemplate.getEnvironment();
}
Return the JNDI environment to use for JNDI lookups. |
public JndiTemplate getJndiTemplate() {
return this.jndiTemplate;
}
Return the JndiTemplate used for JNDI lookups. |
public TransactionManager getTransactionManager() {
return this.transactionManager;
}
Return the JTA TransactionManager that this transaction manager uses. |
public UserTransaction getUserTransaction() {
return this.userTransaction;
}
Return the JTA UserTransaction that this transaction manager uses. |
protected void initTransactionSynchronizationRegistry() {
if (StringUtils.hasLength(this.transactionSynchronizationRegistryName)) {
this.transactionSynchronizationRegistry =
lookupTransactionSynchronizationRegistry(this.transactionSynchronizationRegistryName);
}
else {
this.transactionSynchronizationRegistry = retrieveTransactionSynchronizationRegistry();
if (this.transactionSynchronizationRegistry == null) {
this.transactionSynchronizationRegistry =
findTransactionSynchronizationRegistry(this.userTransaction, this.transactionManager);
}
}
if (this.transactionSynchronizationRegistry != null) {
if (logger.isInfoEnabled()) {
logger.info("Using JTA TransactionSynchronizationRegistry: " + this.transactionSynchronizationRegistry);
}
}
}
|
protected void initUserTransactionAndTransactionManager() throws TransactionSystemException {
// Fetch JTA UserTransaction from JNDI, if necessary.
if (this.userTransaction == null) {
if (StringUtils.hasLength(this.userTransactionName)) {
this.userTransaction = lookupUserTransaction(this.userTransactionName);
this.userTransactionObtainedFromJndi = true;
}
else {
this.userTransaction = retrieveUserTransaction();
}
}
// Fetch JTA TransactionManager from JNDI, if necessary.
if (this.transactionManager == null) {
if (StringUtils.hasLength(this.transactionManagerName)) {
this.transactionManager = lookupTransactionManager(this.transactionManagerName);
}
else {
this.transactionManager = retrieveTransactionManager();
}
}
// Autodetect UserTransaction at its default JNDI location.
if (this.userTransaction == null && this.autodetectUserTransaction) {
this.userTransaction = findUserTransaction();
}
// Autodetect UserTransaction object that implements TransactionManager,
// and check fallback JNDI locations else.
if (this.transactionManager == null && this.autodetectTransactionManager) {
this.transactionManager = findTransactionManager(this.userTransaction);
}
// If only JTA TransactionManager specified, create UserTransaction handle for it.
if (this.userTransaction == null && this.transactionManager != null) {
this.userTransaction = buildUserTransaction(this.transactionManager);
}
}
Initialize the UserTransaction as well as the TransactionManager handle. |
protected boolean isExistingTransaction(Object transaction) {
JtaTransactionObject txObject = (JtaTransactionObject) transaction;
try {
return (txObject.getUserTransaction().getStatus() != Status.STATUS_NO_TRANSACTION);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on getStatus", ex);
}
}
|
protected TransactionManager lookupTransactionManager(String transactionManagerName) throws TransactionSystemException {
try {
if (logger.isDebugEnabled()) {
logger.debug("Retrieving JTA TransactionManager from JNDI location [" + transactionManagerName + "]");
}
return (TransactionManager) getJndiTemplate().lookup(transactionManagerName, TransactionManager.class);
}
catch (NamingException ex) {
throw new TransactionSystemException(
"JTA TransactionManager is not available at JNDI location [" + transactionManagerName + "]", ex);
}
}
Look up the JTA TransactionManager in JNDI via the configured name.
Called by afterPropertiesSet if no direct TransactionManager reference was set.
Can be overridden in subclasses to provide a different TransactionManager object. |
protected Object lookupTransactionSynchronizationRegistry(String registryName) throws TransactionSystemException {
try {
if (logger.isDebugEnabled()) {
logger.debug("Retrieving JTA TransactionSynchronizationRegistry from JNDI location [" + registryName + "]");
}
Class registryClass = ClassUtils.forName(TRANSACTION_SYNCHRONIZATION_REGISTRY_CLASS_NAME,
JtaTransactionManager.class.getClassLoader());
return getJndiTemplate().lookup(registryName, registryClass);
}
catch (ClassNotFoundException ex) {
throw new TransactionSystemException(
"JTA 1.1 [" + TRANSACTION_SYNCHRONIZATION_REGISTRY_CLASS_NAME + "] not available");
}
catch (NamingException ex) {
throw new TransactionSystemException(
"JTA TransactionSynchronizationRegistry is not available at JNDI location [" + registryName + "]", ex);
}
}
|
protected UserTransaction lookupUserTransaction(String userTransactionName) throws TransactionSystemException {
try {
if (logger.isDebugEnabled()) {
logger.debug("Retrieving JTA UserTransaction from JNDI location [" + userTransactionName + "]");
}
return (UserTransaction) getJndiTemplate().lookup(userTransactionName, UserTransaction.class);
}
catch (NamingException ex) {
throw new TransactionSystemException(
"JTA UserTransaction is not available at JNDI location [" + userTransactionName + "]", ex);
}
}
Look up the JTA UserTransaction in JNDI via the configured name.
Called by afterPropertiesSet if no direct UserTransaction reference was set.
Can be overridden in subclasses to provide a different UserTransaction object. |
protected void registerAfterCompletionWithExistingTransaction(Object transaction,
List synchronizations) {
JtaTransactionObject txObject = (JtaTransactionObject) transaction;
logger.debug("Registering after-completion synchronization with existing JTA transaction");
try {
doRegisterAfterCompletionWithJtaTransaction(txObject, synchronizations);
}
catch (RollbackException ex) {
logger.debug("Participating in existing JTA transaction that has been marked for rollback: " +
"cannot register Spring after-completion callbacks with outer JTA transaction - " +
"immediately performing Spring after-completion callbacks with outcome status 'rollback'. " +
"Original exception: " + ex);
invokeAfterCompletion(synchronizations, TransactionSynchronization.STATUS_ROLLED_BACK);
}
catch (IllegalStateException ex) {
logger.debug("Participating in existing JTA transaction, but unexpected internal transaction " +
"state encountered: cannot register Spring after-completion callbacks with outer JTA " +
"transaction - processing Spring after-completion callbacks with outcome status 'unknown'" +
"Original exception: " + ex);
invokeAfterCompletion(synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on registerSynchronization", ex);
}
}
|
protected TransactionManager retrieveTransactionManager() throws TransactionSystemException {
return null;
}
|
protected Object retrieveTransactionSynchronizationRegistry() throws TransactionSystemException {
return null;
}
|
protected UserTransaction retrieveUserTransaction() throws TransactionSystemException {
return null;
}
|
public void setAllowCustomIsolationLevels(boolean allowCustomIsolationLevels) {
this.allowCustomIsolationLevels = allowCustomIsolationLevels;
}
Set whether to allow custom isolation levels to be specified.
Default is "false", throwing an exception if a non-default isolation level
is specified for a transaction. Turn this flag on if affected resource adapters
check the thread-bound transaction context and apply the specified isolation
levels individually (e.g. through a IsolationLevelDataSourceRouter). |
public void setAutodetectTransactionManager(boolean autodetectTransactionManager) {
this.autodetectTransactionManager = autodetectTransactionManager;
}
Set whether to autodetect a JTA UserTransaction object that implements
the JTA TransactionManager interface too (i.e. the JNDI location for the
TransactionManager is "java:comp/UserTransaction", same as for the UserTransaction).
Also checks the fallback JNDI locations "java:comp/TransactionManager" and
"java:/TransactionManager". Will proceed without TransactionManager if none found.
Default is "true", autodetecting the TransactionManager unless it has been
specified explicitly. Can be turned off to deliberately ignore an available
TransactionManager, for example when there are known issues with suspend/resume
and any attempt to use REQUIRES_NEW or NOT_SUPPORTED should fail fast. |
public void setAutodetectUserTransaction(boolean autodetectUserTransaction) {
this.autodetectUserTransaction = autodetectUserTransaction;
}
Set whether to autodetect the JTA UserTransaction at its default
JNDI location "java:comp/UserTransaction", as specified by J2EE.
Will proceed without UserTransaction if none found.
Default is "true", autodetecting the UserTransaction unless
it has been specified explicitly. Turn this flag off to allow for
JtaTransactionManager operating against the TransactionManager only,
despite a default UserTransaction being available. |
public void setCacheUserTransaction(boolean cacheUserTransaction) {
this.cacheUserTransaction = cacheUserTransaction;
}
Set whether to cache the JTA UserTransaction object fetched from JNDI.
Default is "true": UserTransaction lookup will only happen at startup,
reusing the same UserTransaction handle for all transactions of all threads.
This is the most efficient choice for all application servers that provide
a shared UserTransaction object (the typical case).
Turn this flag off to enforce a fresh lookup of the UserTransaction
for every transaction. This is only necessary for application servers
that return a new UserTransaction for every transaction, keeping state
tied to the UserTransaction object itself rather than the current thread. |
public void setJndiEnvironment(Properties jndiEnvironment) {
this.jndiTemplate = new JndiTemplate(jndiEnvironment);
}
Set the JNDI environment to use for JNDI lookups.
Creates a JndiTemplate with the given environment settings. |
public void setJndiTemplate(JndiTemplate jndiTemplate) {
if (jndiTemplate == null) {
throw new IllegalArgumentException("jndiTemplate must not be null");
}
this.jndiTemplate = jndiTemplate;
}
Set the JndiTemplate to use for JNDI lookups.
A default one is used if not set. |
public void setTransactionManager(TransactionManager transactionManager) {
this.transactionManager = transactionManager;
}
Set the JTA TransactionManager to use as direct reference.
A TransactionManager is necessary for suspending and resuming transactions,
as this not supported by the UserTransaction interface.
Note that the TransactionManager will be autodetected if the JTA
UserTransaction object implements the JTA TransactionManager interface too,
as well as autodetected at various well-known fallback JNDI locations. |
public void setTransactionManagerName(String transactionManagerName) {
this.transactionManagerName = transactionManagerName;
}
Set the JNDI name of the JTA TransactionManager.
A TransactionManager is necessary for suspending and resuming transactions,
as this not supported by the UserTransaction interface.
Note that the TransactionManager will be autodetected if the JTA
UserTransaction object implements the JTA TransactionManager interface too,
as well as autodetected at various well-known fallback JNDI locations. |
public void setTransactionSynchronizationRegistryName(String transactionSynchronizationRegistryName) {
this.transactionSynchronizationRegistryName = transactionSynchronizationRegistryName;
}
Set the JNDI name of the JTA 1.1 TransactionSynchronizationRegistry.
Note that the TransactionSynchronizationRegistry will be autodetected
at the Java EE 5 default location "java:comp/TransactionSynchronizationRegistry"
if not specified explicitly. |
public void setUserTransaction(UserTransaction userTransaction) {
this.userTransaction = userTransaction;
}
Set the JTA UserTransaction to use as direct reference.
Typically just used for local JTA setups; in a J2EE environment,
the UserTransaction will always be fetched from JNDI. |
public void setUserTransactionName(String userTransactionName) {
this.userTransactionName = userTransactionName;
}
Set the JNDI name of the JTA UserTransaction.
Note that the UserTransaction will be autodetected at the J2EE default
location "java:comp/UserTransaction" if not specified explicitly. |
protected boolean shouldCommitOnGlobalRollbackOnly() {
return true;
}
This implementation returns "true": a JTA commit will properly handle
transactions that have been marked rollback-only at a global level. |
protected boolean useSavepointForNestedTransaction() {
return false;
}
This implementation returns false to cause a further invocation
of doBegin despite an already existing transaction.
JTA implementations might support nested transactions via further
UserTransaction.begin() invocations, but never support savepoints. |