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 void
acquireWriteLock()
Allows the delegate to acquire a write lock.void
commitDistributedTransaction()
Throws an exception if called as it means that there is no active local transaction to commit.boolean
enlistDistributedNonXAResource(jakarta.transaction.Transaction tran, TransactionalResource h)
Perform implementation specific steps to enlist a non-XA resource with a distribute transaction.boolean
enlistLAOResource(jakarta.transaction.Transaction tran, TransactionalResource h)
Perform implementation specific steps to enlist resource as a LAO.JavaEETransaction
getJavaEETransaction(jakarta.transaction.Transaction t)
Get local transaction object that corresponds to this transaction instance.int
getOrder()
The delegate with the largest order will be used.Lock
getReadLock()
Return the delegate specific read lock that implements Lock interface.int
getStatus()
Get implementation specific status of the transaction associated with the current thread.jakarta.transaction.Transaction
getTransaction()
Get implementation specific transaction object that represents the transaction context of the calling thread.TransactionAdminBean
getTransactionAdminBean(jakarta.transaction.Transaction tran)
Return TransactionAdminBean with delegate specific implementation details of an active Transaction.String
getTxLogLocation()
Return location of transaction logsXAResourceWrapper
getXAResourceWrapper(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.XATerminator
getXATerminator()
This is used by importing transactions via the Connector contract.void
handlePropertyUpdate(String name, Object value)
Handle configuration change.void
initRecovery(boolean force)
Initialize recovery framework.boolean
isNullTransaction()
Return false as this delegate doesn't support tx interop.boolean
isWriteLocked()
Returntrue
if the delegate had its write lock acquired.void
postConstruct()
void
recover(XAResource[] resourceList)
Recover an array of XAResource objects for a failed XA transaction.boolean
recoverIncompleteTx(boolean delegated, String logPath, XAResource[] xaresArray)
Recover the populated array of XAResource if this delegate supports transaction recovery.void
recreate(Xid xid, long timeout)
Recreate a transaction based on the Xid.void
registerRecoveryResourceHandler(XAResource xaResource)
Allows an arbitrary XAResource to register for recoveryvoid
release(Xid xid)
Release a transaction.void
releaseWriteLock()
Allows the delegate to release a write lock.void
removeTransaction(jakarta.transaction.Transaction tx)
Remove the Transaction object from the cache.void
resume(jakarta.transaction.Transaction tx)
Perform implementation specific steps to resume a Transaction.void
rollbackDistributedTransaction()
Throws an exception if called as it means that there is no active local transaction to rollback.void
setRollbackOnlyDistributedTransaction()
Throws an exception if called as it means that there is no active local transaction.void
setTransactionManager(JavaEETransactionManager tm)
Set the JavaEETransactionManager reference.void
setUseLAO(boolean b)
Reset LAO value.TransactionInternal
startJTSTx(JavaEETransaction t, boolean isAssociatedTimeout)
Start new JTS transaction for the existing local transaction object.boolean
supportsXAResource()
Returnstrue> if this delegate supports XA resources.
jakarta.transaction.Transaction
suspend(JavaEETransaction tx)
Perform implementation specific steps to suspend a JavaEETransaction.boolean
useLAO()
Returnstrue
if this implementation supports last agent optimization.
-
-
-
Method Detail
-
postConstruct
public void postConstruct()
- Specified by:
postConstruct
in interfaceorg.glassfish.hk2.api.PostConstruct
-
useLAO
public boolean useLAO()
Description copied from interface:JavaEETransactionManagerDelegate
Returnstrue
if this implementation supports last agent optimization.- Specified by:
useLAO
in interfaceJavaEETransactionManagerDelegate
-
setUseLAO
public void setUseLAO(boolean b)
Description copied from interface:JavaEETransactionManagerDelegate
Reset LAO value.- Specified by:
setUseLAO
in 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.SystemException
Throws an exception if called as it means that there is no active local transaction to commit.- Specified by:
commitDistributedTransaction
in interfaceJavaEETransactionManagerDelegate
- Throws:
jakarta.transaction.RollbackException
jakarta.transaction.HeuristicMixedException
jakarta.transaction.HeuristicRollbackException
SecurityException
IllegalStateException
jakarta.transaction.SystemException
-
rollbackDistributedTransaction
public void rollbackDistributedTransaction() throws IllegalStateException, SecurityException, jakarta.transaction.SystemException
Throws an exception if called as it means that there is no active local transaction to rollback.- Specified by:
rollbackDistributedTransaction
in interfaceJavaEETransactionManagerDelegate
- Throws:
IllegalStateException
SecurityException
jakarta.transaction.SystemException
-
getStatus
public int getStatus() throws jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Get implementation specific status of the transaction associated with the current thread.- Specified by:
getStatus
in interfaceJavaEETransactionManagerDelegate
- Returns:
- the status value as an int.
- Throws:
jakarta.transaction.SystemException
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Get implementation specific transaction object that represents the transaction context of the calling thread.- Specified by:
getTransaction
in interfaceJavaEETransactionManagerDelegate
- Returns:
- the transaction object.
- Throws:
jakarta.transaction.SystemException
-
getJavaEETransaction
public JavaEETransaction getJavaEETransaction(jakarta.transaction.Transaction t)
Description copied from interface:JavaEETransactionManagerDelegate
Get local transaction object that corresponds to this transaction instance.- Specified by:
getJavaEETransaction
in interfaceJavaEETransactionManagerDelegate
- Returns:
- the transaction object.
-
enlistDistributedNonXAResource
public boolean enlistDistributedNonXAResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Perform implementation specific steps to enlist a non-XA resource with a distribute transaction.- Specified by:
enlistDistributedNonXAResource
in interfaceJavaEETransactionManagerDelegate
- Parameters:
tran
- the Transaction object to be used to enlist the resource.h
- the TransactionalResource object to be enlisted.- Returns:
true
if the resource was enlisted successfully.- Throws:
jakarta.transaction.RollbackException
IllegalStateException
jakarta.transaction.SystemException
-
enlistLAOResource
public boolean enlistLAOResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Perform implementation specific steps to enlist resource as a LAO.- Specified by:
enlistLAOResource
in interfaceJavaEETransactionManagerDelegate
- Parameters:
tran
- the Transaction object to be used to enlist the resource.h
- the TransactionalResource object to be enlisted.- Returns:
true
if the resource was enlisted successfully.- Throws:
jakarta.transaction.RollbackException
IllegalStateException
jakarta.transaction.SystemException
-
setRollbackOnlyDistributedTransaction
public void setRollbackOnlyDistributedTransaction() throws IllegalStateException, jakarta.transaction.SystemException
Throws an exception if called as it means that there is no active local transaction.- Specified by:
setRollbackOnlyDistributedTransaction
in interfaceJavaEETransactionManagerDelegate
- Throws:
IllegalStateException
jakarta.transaction.SystemException
-
suspend
public jakarta.transaction.Transaction suspend(JavaEETransaction tx) throws jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Perform implementation specific steps to suspend a JavaEETransaction.- Specified by:
suspend
in 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.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Perform implementation specific steps to resume a Transaction.- Specified by:
resume
in interfaceJavaEETransactionManagerDelegate
- Parameters:
tx
- the Transaction object that represents the transaction to be resumed.- Throws:
jakarta.transaction.InvalidTransactionException
IllegalStateException
jakarta.transaction.SystemException
-
removeTransaction
public void removeTransaction(jakarta.transaction.Transaction tx)
Description copied from interface:JavaEETransactionManagerDelegate
Remove the Transaction object from the cache.- Specified by:
removeTransaction
in interfaceJavaEETransactionManagerDelegate
- Parameters:
tx
- the Transaction object to be removed.
-
getOrder
public int getOrder()
Description copied from interface:JavaEETransactionManagerDelegate
The delegate with the largest order will be used.- Specified by:
getOrder
in interfaceJavaEETransactionManagerDelegate
- Returns:
- the order in which this delegate should be used.
-
setTransactionManager
public void setTransactionManager(JavaEETransactionManager tm)
Description copied from interface:JavaEETransactionManagerDelegate
Set the JavaEETransactionManager reference.- Specified by:
setTransactionManager
in 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:JavaEETransactionManagerDelegate
Start new JTS transaction for the existing local transaction object.- Specified by:
startJTSTx
in interfaceJavaEETransactionManagerDelegate
- Parameters:
t
- the JavaEETransaction object.isAssociatedTimeout
-true
if transaction has a timeout associated with it.- Returns:
- the new JTS Transaction instance.
- Throws:
jakarta.transaction.RollbackException
IllegalStateException
jakarta.transaction.SystemException
-
supportsXAResource
public boolean supportsXAResource()
Description copied from interface:JavaEETransactionManagerDelegate
Returnstrue> if this delegate supports XA resources.
- Specified by:
supportsXAResource
in interfaceJavaEETransactionManagerDelegate
-
initRecovery
public void initRecovery(boolean force)
Description copied from interface:JavaEETransactionManagerDelegate
Initialize recovery framework. Is a no-op if a delegate doesn't support this functionality.- Specified by:
initRecovery
in interfaceJavaEETransactionManagerDelegate
-
recover
public void recover(XAResource[] resourceList)
Description copied from interface:JavaEETransactionManagerDelegate
Recover an array of XAResource objects for a failed XA transaction.- Specified by:
recover
in interfaceJavaEETransactionManagerDelegate
- Parameters:
resourceList
- the array of XAResource objects to recover.
-
getXATerminator
public jakarta.resource.spi.XATerminator getXATerminator()
Description copied from interface:JavaEETransactionManagerDelegate
This is used by importing transactions via the Connector contract. Should not be called- Specified by:
getXATerminator
in interfaceJavaEETransactionManagerDelegate
- Returns:
- a
XATerminator
instance.
-
release
public void release(Xid xid) throws jakarta.resource.spi.work.WorkException
Description copied from interface:JavaEETransactionManagerDelegate
Release 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:
release
in 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:JavaEETransactionManagerDelegate
Recreate 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:
recreate
in 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 Exception
Description copied from interface:JavaEETransactionManagerDelegate
Recover the populated array of XAResource if this delegate supports transaction recovery.- Specified by:
recoverIncompleteTx
in interfaceJavaEETransactionManagerDelegate
- Parameters:
delegated
-true
if 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:JavaEETransactionManagerDelegate
Returns an instance of an XAResourceWrapper if this delegate supports transaction recovery and there is a wrapper available for this class name. Returnsnull
otherwise.- Specified by:
getXAResourceWrapper
in interfaceJavaEETransactionManagerDelegate
- Returns:
- an instance of an XAResourceWrapper or
null
if 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:JavaEETransactionManagerDelegate
Handle configuration change.- Specified by:
handlePropertyUpdate
in interfaceJavaEETransactionManagerDelegate
- Parameters:
name
- the name of the configuration property.value
- the ne value of the configuration.
-
getReadLock
public Lock getReadLock()
Description copied from interface:JavaEETransactionManagerDelegate
Return the delegate specific read lock that implements Lock interface.- Specified by:
getReadLock
in interfaceJavaEETransactionManagerDelegate
-
isWriteLocked
public boolean isWriteLocked()
Description copied from interface:JavaEETransactionManagerDelegate
Returntrue
if the delegate had its write lock acquired.- Specified by:
isWriteLocked
in interfaceJavaEETransactionManagerDelegate
-
acquireWriteLock
public void acquireWriteLock()
Description copied from interface:JavaEETransactionManagerDelegate
Allows the delegate to acquire a write lock.- Specified by:
acquireWriteLock
in interfaceJavaEETransactionManagerDelegate
-
releaseWriteLock
public void releaseWriteLock()
Description copied from interface:JavaEETransactionManagerDelegate
Allows the delegate to release a write lock.- Specified by:
releaseWriteLock
in interfaceJavaEETransactionManagerDelegate
-
isNullTransaction
public boolean isNullTransaction()
Return false as this delegate doesn't support tx interop.- Specified by:
isNullTransaction
in interfaceJavaEETransactionManagerDelegate
-
getTransactionAdminBean
public TransactionAdminBean getTransactionAdminBean(jakarta.transaction.Transaction tran) throws jakarta.transaction.SystemException
Description copied from interface:JavaEETransactionManagerDelegate
Return TransactionAdminBean with delegate specific implementation details of an active Transaction.- Specified by:
getTransactionAdminBean
in interfaceJavaEETransactionManagerDelegate
- Throws:
jakarta.transaction.SystemException
-
getTxLogLocation
public String getTxLogLocation()
Return location of transaction logs- Specified by:
getTxLogLocation
in interfaceJavaEETransactionManagerDelegate
- Returns:
- String location of transaction logs
-
registerRecoveryResourceHandler
public void registerRecoveryResourceHandler(XAResource xaResource)
Allows an arbitrary XAResource to register for recovery- Specified by:
registerRecoveryResourceHandler
in interfaceJavaEETransactionManagerDelegate
- Parameters:
xaResource
- XAResource to register for recovery
-
-