Package com.sun.enterprise.transaction
Class JavaEETransactionManagerSimplifiedDelegate
- java.lang.Object
-
- com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate
-
- All Implemented Interfaces:
JavaEETransactionManagerDelegate,org.glassfish.hk2.api.PostConstruct
@Service public class JavaEETransactionManagerSimplifiedDelegate extends Object implements JavaEETransactionManagerDelegate, org.glassfish.hk2.api.PostConstruct
Implementation of JavaEETransactionManagerDelegate that supports only local transactions with a single non-XA resource.- Author:
- Marina Vatkina
-
-
Constructor Summary
Constructors Constructor Description JavaEETransactionManagerSimplifiedDelegate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireWriteLock()Allows the delegate to acquire a write lock.voidcommitDistributedTransaction()Throws an exception if called as it means that there is no active local transaction to commit.booleanenlistDistributedNonXAResource(jakarta.transaction.Transaction tran, TransactionalResource h)Perform implementation specific steps to enlist a non-XA resource with a distribute transaction.booleanenlistLAOResource(jakarta.transaction.Transaction tran, TransactionalResource h)Perform implementation specific steps to enlist resource as a LAO.JavaEETransactiongetJavaEETransaction(jakarta.transaction.Transaction t)Get local transaction object that corresponds to this transaction instance.intgetOrder()The delegate with the largest order will be used.LockgetReadLock()Return the delegate specific read lock that implements Lock interface.intgetStatus()Get implementation specific status of the transaction associated with the current thread.jakarta.transaction.TransactiongetTransaction()Get implementation specific transaction object that represents the transaction context of the calling thread.TransactionAdminBeangetTransactionAdminBean(jakarta.transaction.Transaction tran)Return TransactionAdminBean with delegate specific implementation details of an active Transaction.StringgetTxLogLocation()Return location of transaction logsXAResourceWrappergetXAResourceWrapper(String clName)Returns an instance of an XAResourceWrapper if this delegate supports transaction recovery and there is a wrapper available for this class name.jakarta.resource.spi.XATerminatorgetXATerminator()This is used by importing transactions via the Connector contract.voidhandlePropertyUpdate(String name, Object value)Handle configuration change.voidinitRecovery(boolean force)Initialize recovery framework.booleanisNullTransaction()Return false as this delegate doesn't support tx interop.booleanisWriteLocked()Returntrueif the delegate had its write lock acquired.voidpostConstruct()voidrecover(XAResource[] resourceList)Recover an array of XAResource objects for a failed XA transaction.booleanrecoverIncompleteTx(boolean delegated, String logPath, XAResource[] xaresArray)Recover the populated array of XAResource if this delegate supports transaction recovery.voidrecreate(Xid xid, long timeout)Recreate a transaction based on the Xid.voidregisterRecoveryResourceHandler(XAResource xaResource)Allows an arbitrary XAResource to register for recoveryvoidrelease(Xid xid)Release a transaction.voidreleaseWriteLock()Allows the delegate to release a write lock.voidremoveTransaction(jakarta.transaction.Transaction tx)Remove the Transaction object from the cache.voidresume(jakarta.transaction.Transaction tx)Perform implementation specific steps to resume a Transaction.voidrollbackDistributedTransaction()Throws an exception if called as it means that there is no active local transaction to rollback.voidsetRollbackOnlyDistributedTransaction()Throws an exception if called as it means that there is no active local transaction.voidsetTransactionManager(JavaEETransactionManager tm)Set the JavaEETransactionManager reference.voidsetUseLAO(boolean b)Reset LAO value.TransactionInternalstartJTSTx(JavaEETransaction t, boolean isAssociatedTimeout)Start new JTS transaction for the existing local transaction object.booleansupportsXAResource()Returnstrue> if this delegate supports XA resources.jakarta.transaction.Transactionsuspend(JavaEETransaction tx)Perform implementation specific steps to suspend a JavaEETransaction.booleanuseLAO()Returnstrueif this implementation supports last agent optimization.
-
-
-
Method Detail
-
postConstruct
public void postConstruct()
- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
useLAO
public boolean useLAO()
Description copied from interface:JavaEETransactionManagerDelegateReturnstrueif this implementation supports last agent optimization.- Specified by:
useLAOin interfaceJavaEETransactionManagerDelegate
-
setUseLAO
public void setUseLAO(boolean b)
Description copied from interface:JavaEETransactionManagerDelegateReset LAO value.- Specified by:
setUseLAOin interfaceJavaEETransactionManagerDelegate- Parameters:
b- the boolean value for the LAO flag.
-
commitDistributedTransaction
public void commitDistributedTransaction() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, IllegalStateException, jakarta.transaction.SystemExceptionThrows an exception if called as it means that there is no active local transaction to commit.- Specified by:
commitDistributedTransactionin interfaceJavaEETransactionManagerDelegate- Throws:
jakarta.transaction.RollbackExceptionjakarta.transaction.HeuristicMixedExceptionjakarta.transaction.HeuristicRollbackExceptionSecurityExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
rollbackDistributedTransaction
public void rollbackDistributedTransaction() throws IllegalStateException, SecurityException, jakarta.transaction.SystemExceptionThrows an exception if called as it means that there is no active local transaction to rollback.- Specified by:
rollbackDistributedTransactionin interfaceJavaEETransactionManagerDelegate- Throws:
IllegalStateExceptionSecurityExceptionjakarta.transaction.SystemException
-
getStatus
public int getStatus() throws jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelegateGet implementation specific status of the transaction associated with the current thread.- Specified by:
getStatusin interfaceJavaEETransactionManagerDelegate- Returns:
- the status value as an int.
- Throws:
jakarta.transaction.SystemException
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelegateGet implementation specific transaction object that represents the transaction context of the calling thread.- Specified by:
getTransactionin interfaceJavaEETransactionManagerDelegate- Returns:
- the transaction object.
- Throws:
jakarta.transaction.SystemException
-
getJavaEETransaction
public JavaEETransaction getJavaEETransaction(jakarta.transaction.Transaction t)
Description copied from interface:JavaEETransactionManagerDelegateGet local transaction object that corresponds to this transaction instance.- Specified by:
getJavaEETransactionin interfaceJavaEETransactionManagerDelegate- Returns:
- the transaction object.
-
enlistDistributedNonXAResource
public boolean enlistDistributedNonXAResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelegatePerform implementation specific steps to enlist a non-XA resource with a distribute transaction.- Specified by:
enlistDistributedNonXAResourcein interfaceJavaEETransactionManagerDelegate- Parameters:
tran- the Transaction object to be used to enlist the resource.h- the TransactionalResource object to be enlisted.- Returns:
trueif the resource was enlisted successfully.- Throws:
jakarta.transaction.RollbackExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
enlistLAOResource
public boolean enlistLAOResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelegatePerform implementation specific steps to enlist resource as a LAO.- Specified by:
enlistLAOResourcein interfaceJavaEETransactionManagerDelegate- Parameters:
tran- the Transaction object to be used to enlist the resource.h- the TransactionalResource object to be enlisted.- Returns:
trueif the resource was enlisted successfully.- Throws:
jakarta.transaction.RollbackExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
setRollbackOnlyDistributedTransaction
public void setRollbackOnlyDistributedTransaction() throws IllegalStateException, jakarta.transaction.SystemExceptionThrows an exception if called as it means that there is no active local transaction.- Specified by:
setRollbackOnlyDistributedTransactionin interfaceJavaEETransactionManagerDelegate- Throws:
IllegalStateExceptionjakarta.transaction.SystemException
-
suspend
public jakarta.transaction.Transaction suspend(JavaEETransaction tx) throws jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegatePerform implementation specific steps to suspend a JavaEETransaction.- Specified by:
suspendin interfaceJavaEETransactionManagerDelegate- Parameters:
tx- the JavaEETransaction object to be suspend.- Returns:
- Transaction object representing the suspended transaction.
- Throws:
jakarta.transaction.SystemException
-
resume
public void resume(jakarta.transaction.Transaction tx) throws jakarta.transaction.InvalidTransactionException, IllegalStateException, jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelegatePerform implementation specific steps to resume a Transaction.- Specified by:
resumein interfaceJavaEETransactionManagerDelegate- Parameters:
tx- the Transaction object that represents the transaction to be resumed.- Throws:
jakarta.transaction.InvalidTransactionExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
removeTransaction
public void removeTransaction(jakarta.transaction.Transaction tx)
Description copied from interface:JavaEETransactionManagerDelegateRemove the Transaction object from the cache.- Specified by:
removeTransactionin interfaceJavaEETransactionManagerDelegate- Parameters:
tx- the Transaction object to be removed.
-
getOrder
public int getOrder()
Description copied from interface:JavaEETransactionManagerDelegateThe delegate with the largest order will be used.- Specified by:
getOrderin interfaceJavaEETransactionManagerDelegate- Returns:
- the order in which this delegate should be used.
-
setTransactionManager
public void setTransactionManager(JavaEETransactionManager tm)
Description copied from interface:JavaEETransactionManagerDelegateSet the JavaEETransactionManager reference.- Specified by:
setTransactionManagerin interfaceJavaEETransactionManagerDelegate- Parameters:
tm- the JavaEETransactionManager object.
-
startJTSTx
public TransactionInternal startJTSTx(JavaEETransaction t, boolean isAssociatedTimeout) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegateStart new JTS transaction for the existing local transaction object.- Specified by:
startJTSTxin interfaceJavaEETransactionManagerDelegate- Parameters:
t- the JavaEETransaction object.isAssociatedTimeout-trueif transaction has a timeout associated with it.- Returns:
- the new JTS Transaction instance.
- Throws:
jakarta.transaction.RollbackExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
supportsXAResource
public boolean supportsXAResource()
Description copied from interface:JavaEETransactionManagerDelegateReturnstrue> if this delegate supports XA resources.- Specified by:
supportsXAResourcein interfaceJavaEETransactionManagerDelegate
-
initRecovery
public void initRecovery(boolean force)
Description copied from interface:JavaEETransactionManagerDelegateInitialize recovery framework. Is a no-op if a delegate doesn't support this functionality.- Specified by:
initRecoveryin interfaceJavaEETransactionManagerDelegate
-
recover
public void recover(XAResource[] resourceList)
Description copied from interface:JavaEETransactionManagerDelegateRecover an array of XAResource objects for a failed XA transaction.- Specified by:
recoverin interfaceJavaEETransactionManagerDelegate- Parameters:
resourceList- the array of XAResource objects to recover.
-
getXATerminator
public jakarta.resource.spi.XATerminator getXATerminator()
Description copied from interface:JavaEETransactionManagerDelegateThis is used by importing transactions via the Connector contract. Should not be called- Specified by:
getXATerminatorin interfaceJavaEETransactionManagerDelegate- Returns:
- a
XATerminatorinstance.
-
release
public void release(Xid xid) throws jakarta.resource.spi.work.WorkException
Description copied from interface:JavaEETransactionManagerDelegateRelease a transaction. This call causes the calling thread to be dissociated from the specified transaction.This is used by importing transactions via the Connector contract.
- Specified by:
releasein interfaceJavaEETransactionManagerDelegate- Parameters:
xid- the Xid object representing a transaction.- Throws:
jakarta.resource.spi.work.WorkException
-
recreate
public void recreate(Xid xid, long timeout) throws jakarta.resource.spi.work.WorkException
Description copied from interface:JavaEETransactionManagerDelegateRecreate a transaction based on the Xid. This call causes the calling thread to be associated with the specified transaction.This is used by importing transactions via the Connector contract.
- Specified by:
recreatein interfaceJavaEETransactionManagerDelegate- Parameters:
xid- the Xid object representing a transaction.timeout- the timeout for the transaction to be recreated.- Throws:
jakarta.resource.spi.work.WorkException
-
recoverIncompleteTx
public boolean recoverIncompleteTx(boolean delegated, String logPath, XAResource[] xaresArray) throws ExceptionDescription copied from interface:JavaEETransactionManagerDelegateRecover the populated array of XAResource if this delegate supports transaction recovery.- Specified by:
recoverIncompleteTxin interfaceJavaEETransactionManagerDelegate- Parameters:
delegated-trueif the recovery process is owned by this instance.logPath- the name of the transaction logging directoryxaresArray- the array of XA Resources to be recovered.- Returns:
- true if the recovery has been successful.
- Throws:
Exception
-
getXAResourceWrapper
public XAResourceWrapper getXAResourceWrapper(String clName)
Description copied from interface:JavaEETransactionManagerDelegateReturns an instance of an XAResourceWrapper if this delegate supports transaction recovery and there is a wrapper available for this class name. Returnsnullotherwise.- Specified by:
getXAResourceWrapperin interfaceJavaEETransactionManagerDelegate- Returns:
- an instance of an XAResourceWrapper or
nullif this delegate doesn't support transaction recovery or a wrapper is not available.
-
handlePropertyUpdate
public void handlePropertyUpdate(String name, Object value)
Description copied from interface:JavaEETransactionManagerDelegateHandle configuration change.- Specified by:
handlePropertyUpdatein interfaceJavaEETransactionManagerDelegate- Parameters:
name- the name of the configuration property.value- the ne value of the configuration.
-
getReadLock
public Lock getReadLock()
Description copied from interface:JavaEETransactionManagerDelegateReturn the delegate specific read lock that implements Lock interface.- Specified by:
getReadLockin interfaceJavaEETransactionManagerDelegate
-
isWriteLocked
public boolean isWriteLocked()
Description copied from interface:JavaEETransactionManagerDelegateReturntrueif the delegate had its write lock acquired.- Specified by:
isWriteLockedin interfaceJavaEETransactionManagerDelegate
-
acquireWriteLock
public void acquireWriteLock()
Description copied from interface:JavaEETransactionManagerDelegateAllows the delegate to acquire a write lock.- Specified by:
acquireWriteLockin interfaceJavaEETransactionManagerDelegate
-
releaseWriteLock
public void releaseWriteLock()
Description copied from interface:JavaEETransactionManagerDelegateAllows the delegate to release a write lock.- Specified by:
releaseWriteLockin interfaceJavaEETransactionManagerDelegate
-
isNullTransaction
public boolean isNullTransaction()
Return false as this delegate doesn't support tx interop.- Specified by:
isNullTransactionin interfaceJavaEETransactionManagerDelegate
-
getTransactionAdminBean
public TransactionAdminBean getTransactionAdminBean(jakarta.transaction.Transaction tran) throws jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegateReturn TransactionAdminBean with delegate specific implementation details of an active Transaction.- Specified by:
getTransactionAdminBeanin interfaceJavaEETransactionManagerDelegate- Throws:
jakarta.transaction.SystemException
-
getTxLogLocation
public String getTxLogLocation()
Return location of transaction logs- Specified by:
getTxLogLocationin interfaceJavaEETransactionManagerDelegate- Returns:
- String location of transaction logs
-
registerRecoveryResourceHandler
public void registerRecoveryResourceHandler(XAResource xaResource)
Allows an arbitrary XAResource to register for recovery- Specified by:
registerRecoveryResourceHandlerin interfaceJavaEETransactionManagerDelegate- Parameters:
xaResource- XAResource to register for recovery
-
-