Interface JavaEETransactionManager
-
- All Superinterfaces:
jakarta.transaction.TransactionManager
- All Known Implementing Classes:
JavaEETransactionManagerSimplified
@Contract public interface JavaEETransactionManager extends jakarta.transaction.TransactionManager
Manages transactions, acting as a gateway to the TM state machine.- Author:
- Tony Ng
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
begin(int timeout)
void
checkTransactionExport(boolean isLocal)
Perform checks during export of a transaction on a remote call.void
checkTransactionImport()
Perform checks during import of a transaction on a remote call.void
cleanTxnTimeout()
void
clearThreadTx()
Clears the transaction associated with the caller threadvoid
componentDestroyed(Object instance)
This is called by Container to indicate that a component is being destroyed.void
componentDestroyed(Object instance, ComponentInvocation inv)
This is called by Container to indicate that a component is being destroyed.void
componentDestroyed(ResourceHandler rh)
This is called by Container to indicate that a component is being destroyed.void
delistComponentResources(boolean suspend)
This is called by the Container to ask the Transaction Manager to delist all resources held by a component The TM finds the component through the InvocationManagerboolean
delistResource(jakarta.transaction.Transaction tran, TransactionalResource h, int flag)
Delist the resource specified from the transactionvoid
enlistComponentResources()
This is called by the Container to ask the Transaction Manager to enlist all resources held by a component and to associate the current Transaction with the current Invocation The TM finds the component through the InvocationManagerboolean
enlistResource(jakarta.transaction.Transaction tran, TransactionalResource h)
Enlist the resource specified with the transactionvoid
forceRollback(String txnId)
void
freeze()
ArrayList
getActiveTransactions()
JavaEETransaction
getCurrentTransaction()
Return JavaEETransaction instance associated with the current thread.List
getExistingResourceList(Object instance, ComponentInvocation inv)
Returns a list of resource handles held by the componentint
getPurgeCancelledTtransactionsAfter()
Returns the value to be used to purge transaction tasks after the specified number of cancelled tasksList
getResourceList(Object instance, ComponentInvocation inv)
get the resources being used in the calling component's invocation contextString
getTxLogLocation()
Return location of transaction logsXAResourceWrapper
getXAResourceWrapper(String clName)
Return XAResourceWrapper instance specific to this datasource class name that can be used instead of the driver provided version for transaction recovery.jakarta.resource.spi.XATerminator
getXATerminator()
Provides a handle to aXATerminator
instance.void
handlePropertyUpdate(String name, Object value)
Handle configuration change.void
initRecovery(boolean force)
Initialize recovery frameworkboolean
isFrozen()
boolean
isNullTransaction()
Return true if a "null transaction context" was received from the client or if the server's transaction.interoperability flag is false.boolean
isTimedOut()
Utility for the ejb container to check if the transaction is marked for rollback because of timeout.void
postInvoke(ComponentInvocation curr, ComponentInvocation prev)
Called by InvocationManagervoid
preInvoke(ComponentInvocation prev)
Called by InvocationManagervoid
recover(XAResource[] resourceList)
boolean
recoverIncompleteTx(boolean delegated, String logPath, XAResource[] xaresArray)
Called by the ResourceRecoveryManager to recover the populated array of XAResource.void
recreate(Xid xid, long timeout)
recreate a transaction based on the Xid.void
registerComponentResource(TransactionalResource h)
void
registerRecoveryResourceHandler(XAResource xaResource)
Allows an arbitrary XAResource to register for recoveryvoid
registerSynchronization(jakarta.transaction.Synchronization sync)
register a synchronization object with the transaction associated with the current threadvoid
release(Xid xid)
Release a transaction.void
setCurrentTransaction(JavaEETransaction tx)
Update JavaEETransaction associated with the current thread.void
setDefaultTransactionTimeout(int seconds)
void
setDelegate(JavaEETransactionManagerDelegate delegate)
Explicitly set the JavaEETransactionManagerDelegate instance for implementation-specific callbacks.void
setMonitoringEnabled(boolean enabled)
void
setPurgeCancelledTtransactionsAfter(int value)
Allows to purge transaction tasks after the specified value of cancelled tasksvoid
shutdown()
Perform shutdown cleanup.void
unfreeze()
void
unregisterComponentResource(TransactionalResource h)
-
-
-
Method Detail
-
registerSynchronization
void registerSynchronization(jakarta.transaction.Synchronization sync) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
register a synchronization object with the transaction associated with the current thread- Parameters:
sync
- the synchronization object- Throws:
IllegalStateException
- Thrown if the transaction in the target object is in prepared state or the transaction is inactive.jakarta.transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error conditionjakarta.transaction.RollbackException
-
enlistResource
boolean enlistResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
Enlist the resource specified with the transaction- Parameters:
tran
- The transaction objecth
- The resource handle object- Returns:
- true if the resource was enlisted successfully; otherwise * false.
- Throws:
jakarta.transaction.RollbackException
- Thrown to indicate that the transaction has been marked for rollback only.IllegalStateException
- Thrown if the transaction in the target object is in prepared state or the transaction is inactive.jakarta.transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition
-
delistResource
boolean delistResource(jakarta.transaction.Transaction tran, TransactionalResource h, int flag) throws IllegalStateException, jakarta.transaction.SystemException
Delist the resource specified from the transaction- Parameters:
tran
- The transaction objecth
- The resource handle objectflag
- One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL.- Throws:
IllegalStateException
- Thrown if the transaction in the target object is inactive.jakarta.transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition
-
enlistComponentResources
void enlistComponentResources() throws RemoteException
This is called by the Container to ask the Transaction Manager to enlist all resources held by a component and to associate the current Transaction with the current Invocation The TM finds the component through the InvocationManager- Throws:
RemoteException
-
delistComponentResources
void delistComponentResources(boolean suspend) throws RemoteException
This is called by the Container to ask the Transaction Manager to delist all resources held by a component The TM finds the component through the InvocationManager- Parameters:
suspend
- true if the resources should be delisted with TMSUSPEND flag; false otherwise- Throws:
RemoteException
-
componentDestroyed
void componentDestroyed(Object instance, ComponentInvocation inv)
This is called by Container to indicate that a component is being destroyed. All resources registered in the context should be released. The ComponentInvocation will be used for callback to calculate the resource table key.- Parameters:
instance
- The component instanceinv
- The ComponentInvocation
-
componentDestroyed
void componentDestroyed(Object instance)
This is called by Container to indicate that a component is being destroyed. All resources registered in the context should be released- Parameters:
instance
- The component instance
-
componentDestroyed
void componentDestroyed(ResourceHandler rh)
This is called by Container to indicate that a component is being destroyed. All resources registered with this ResourceHandler should be released.- Parameters:
rh
- The ResourceHandler
-
preInvoke
void preInvoke(ComponentInvocation prev) throws InvocationException
Called by InvocationManager- Throws:
InvocationException
-
postInvoke
void postInvoke(ComponentInvocation curr, ComponentInvocation prev) throws InvocationException
Called by InvocationManager- Throws:
InvocationException
-
setDefaultTransactionTimeout
void setDefaultTransactionTimeout(int seconds)
-
cleanTxnTimeout
void cleanTxnTimeout()
-
getExistingResourceList
List getExistingResourceList(Object instance, ComponentInvocation inv)
Returns a list of resource handles held by the component
-
registerComponentResource
void registerComponentResource(TransactionalResource h)
-
unregisterComponentResource
void unregisterComponentResource(TransactionalResource h)
-
recover
void recover(XAResource[] resourceList)
-
initRecovery
void initRecovery(boolean force)
Initialize recovery framework- Parameters:
force
- if true, forces initialization, otherwise relies on the TimerService configuration.
-
shutdown
void shutdown()
Perform shutdown cleanup.
-
begin
void begin(int timeout) throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemException
- Throws:
jakarta.transaction.NotSupportedException
jakarta.transaction.SystemException
-
isNullTransaction
boolean isNullTransaction()
Return true if a "null transaction context" was received from the client or if the server's transaction.interoperability flag is false. A null tx context indicates that the client had an active tx but the client container did not support tx interop. See EJB2.0 spec section 18.5.2.1.
-
checkTransactionExport
void checkTransactionExport(boolean isLocal)
Perform checks during export of a transaction on a remote call.
-
checkTransactionImport
void checkTransactionImport()
Perform checks during import of a transaction on a remote call. This is called from the reply interceptors after a remote call completes.
-
isTimedOut
boolean isTimedOut()
Utility for the ejb container to check if the transaction is marked for rollback because of timeout. This is applicable only for local transactions as jts transaction will rollback instead of setting the txn for rollback
-
getActiveTransactions
ArrayList getActiveTransactions()
-
forceRollback
void forceRollback(String txnId) throws IllegalStateException, jakarta.transaction.SystemException
- Throws:
IllegalStateException
jakarta.transaction.SystemException
-
setMonitoringEnabled
void setMonitoringEnabled(boolean enabled)
-
freeze
void freeze()
-
unfreeze
void unfreeze()
-
isFrozen
boolean isFrozen()
-
recreate
void recreate(Xid xid, long timeout) throws jakarta.resource.spi.work.WorkException
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.
- Parameters:
xid
- the Xid object representing a transaction.- Throws:
jakarta.resource.spi.work.WorkException
-
release
void release(Xid xid) throws jakarta.resource.spi.work.WorkException
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.
- Parameters:
xid
- the Xid object representing a transaction.- Throws:
jakarta.resource.spi.work.WorkException
-
getXATerminator
jakarta.resource.spi.XATerminator getXATerminator()
Provides a handle to aXATerminator
instance. TheXATerminator
instance could be used by a resource adapter to flow-in transaction completion and crash recovery calls from an EIS.This is used by importing transactions via the Connector contract.
- Returns:
- a
XATerminator
instance.
-
setDelegate
void setDelegate(JavaEETransactionManagerDelegate delegate)
Explicitly set the JavaEETransactionManagerDelegate instance for implementation-specific callbacks.- Parameters:
delegate
- the JavaEETransactionManagerDelegate instance.
-
getCurrentTransaction
JavaEETransaction getCurrentTransaction()
Return JavaEETransaction instance associated with the current thread.- Returns:
- the JavaEETransaction associated with the current thread or null if it there is none.
-
setCurrentTransaction
void setCurrentTransaction(JavaEETransaction tx)
Update JavaEETransaction associated with the current thread.- Parameters:
tx
- the JavaEETransaction associated with the current thread or null if the existing transaction had been completed.
-
getXAResourceWrapper
XAResourceWrapper getXAResourceWrapper(String clName)
Return XAResourceWrapper instance specific to this datasource class name that can be used instead of the driver provided version for transaction recovery.- Parameters:
clName
- the class name of a datasource.- Returns:
- the XAResourceWrapper instance specific to this datasource class name or null if there is no special wrapper available.
-
handlePropertyUpdate
void handlePropertyUpdate(String name, Object value)
Handle configuration change. Actual change will be performed by the delegate.- Parameters:
name
- the name of the configuration property.value
- the ne value of the configuration.
-
recoverIncompleteTx
boolean recoverIncompleteTx(boolean delegated, String logPath, XAResource[] xaresArray) throws Exception
Called by the ResourceRecoveryManager to recover the populated array of XAResource.- 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
-
getResourceList
List getResourceList(Object instance, ComponentInvocation inv)
get the resources being used in the calling component's invocation context- Parameters:
instance
- calling component instanceinv
- Calling component's invocation information- Returns:
- List of resources
-
clearThreadTx
void clearThreadTx()
Clears the transaction associated with the caller thread
-
getTxLogLocation
String getTxLogLocation()
Return location of transaction logs- Returns:
- String location of transaction logs
-
registerRecoveryResourceHandler
void registerRecoveryResourceHandler(XAResource xaResource)
Allows an arbitrary XAResource to register for recovery- Parameters:
xaResource
- XAResource to register for recovery
-
getPurgeCancelledTtransactionsAfter
int getPurgeCancelledTtransactionsAfter()
Returns the value to be used to purge transaction tasks after the specified number of cancelled tasks
-
setPurgeCancelledTtransactionsAfter
void setPurgeCancelledTtransactionsAfter(int value)
Allows to purge transaction tasks after the specified value of cancelled tasks
-
-