Class JavaEETransactionManagerJTSDelegate
- java.lang.Object
-
- com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate
-
- All Implemented Interfaces:
JavaEETransactionManagerDelegate,org.glassfish.hk2.api.PostConstruct
@Service public class JavaEETransactionManagerJTSDelegate extends Object implements JavaEETransactionManagerDelegate, org.glassfish.hk2.api.PostConstruct
Implementation of JavaEETransactionManagerDelegate that supports XA transactions with JTS.- Author:
- Marina Vatkina
-
-
Constructor Summary
Constructors Constructor Description JavaEETransactionManagerJTSDelegate()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireWriteLock()Allows the delegate to acquire a write lock.voidbeginJTS(int timeout)voidcommitDistributedTransaction()An XA transaction commitbooleanenlistDistributedNonXAResource(jakarta.transaction.Transaction tx, 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.static JavaEETransactionManagerJTSDelegategetInstance()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 t)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.voidinitTransactionProperties()voidinitXA()booleanisNullTransaction()Return true if a "null transaction context" was received from the client.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()An XA transaction rollbackvoidsetRollbackOnlyDistributedTransaction()Perform implementation specific steps to set setRollbackOnly status for distributed transaction if there is any.voidsetTransactionManager(JavaEETransactionManager tm)Set the JavaEETransactionManager reference.voidsetUseLAO(boolean b)Reset LAO value.TransactionInternalstartJTSTx(JavaEETransaction tran, 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.SystemExceptionAn XA transaction commit- Specified by:
commitDistributedTransactionin interfaceJavaEETransactionManagerDelegate- Throws:
jakarta.transaction.RollbackExceptionjakarta.transaction.HeuristicMixedExceptionjakarta.transaction.HeuristicRollbackExceptionSecurityExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
rollbackDistributedTransaction
public void rollbackDistributedTransaction() throws IllegalStateException, SecurityException, jakarta.transaction.SystemExceptionAn XA transaction 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 tx, 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:
tx- 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.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelegatePerform implementation specific steps to set setRollbackOnly status for distributed transaction if there is any.- 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 tran, 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:
tran- the JavaEETransaction object.isAssociatedTimeout-trueif transaction has a timeout associated with it.- Returns:
- the new JTS Transaction instance.
- Throws:
jakarta.transaction.RollbackExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
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.
-
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
-
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.
-
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.
-
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
-
beginJTS
public void beginJTS(int timeout) throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemException- Throws:
jakarta.transaction.NotSupportedExceptionjakarta.transaction.SystemException
-
supportsXAResource
public boolean supportsXAResource()
Description copied from interface:JavaEETransactionManagerDelegateReturnstrue> if this delegate supports XA resources.- Specified by:
supportsXAResourcein interfaceJavaEETransactionManagerDelegate
-
initTransactionProperties
public void initTransactionProperties()
-
isNullTransaction
public boolean isNullTransaction()
Return true if a "null transaction context" was received from the client. See EJB2.0 spec section 19.6.2.1. A null tx context has no Coordinator objref. It indicates that the client had an active tx but the client container did not support tx interop.- Specified by:
isNullTransactionin interfaceJavaEETransactionManagerDelegate
-
getTransactionAdminBean
public TransactionAdminBean getTransactionAdminBean(jakarta.transaction.Transaction t) 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
-
getReadLock
public Lock getReadLock()
Description copied from interface:JavaEETransactionManagerDelegateReturn the delegate specific read lock that implements Lock interface.- Specified by:
getReadLockin 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
-
isWriteLocked
public boolean isWriteLocked()
Description copied from interface:JavaEETransactionManagerDelegateReturntrueif the delegate had its write lock acquired.- Specified by:
isWriteLockedin interfaceJavaEETransactionManagerDelegate
-
getInstance
public static JavaEETransactionManagerJTSDelegate getInstance()
-
initXA
public void initXA()
-
-