Package com.sun.enterprise.transaction
Class JavaEETransactionManagerSimplified
- java.lang.Object
-
- com.sun.enterprise.transaction.JavaEETransactionManagerSimplified
-
- All Implemented Interfaces:
JavaEETransactionManager,jakarta.transaction.TransactionManager,org.glassfish.hk2.api.PostConstruct
@Service @ContractsProvided({jakarta.transaction.TransactionManager.class,JavaEETransactionManager.class}) @Rank(50) public class JavaEETransactionManagerSimplified extends Object implements JavaEETransactionManager, org.glassfish.hk2.api.PostConstructImplementation of jakarta.transaction.TransactionManager interface. This class provides non-XA local transaction support and delegates to implementation of the JavaEETransactionManagerDelegate for XA or LAO optimization, and complete JTS implementation.- Author:
- Tony Ng, Marina Vatkina
-
-
Field Summary
Fields Modifier and Type Field Description protected Logger_loggerprotected InvocationManagerinvMgr
-
Constructor Summary
Constructors Constructor Description JavaEETransactionManagerSimplified()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()voidbegin(int timeout)This method is introduced as part of implementing the local transaction timeout capability.voidcheckTransactionExport(boolean isLocal)Called from the CORBA Interceptors on the client-side when a client makes a call to a remote object (not in the same JVM).voidcheckTransactionImport()Called from the CORBA Interceptors on the server-side when the server is replying to the client (local + remote client).voidcleanTxnTimeout()voidclearThreadTx()Clears the transaction associated with the caller threadvoidcommit()voidcomponentDestroyed(Object instance)This is called by Container to indicate that a component is being destroyed.voidcomponentDestroyed(Object instance, ComponentInvocation inv)This is called by Container to indicate that a component is being destroyed.voidcomponentDestroyed(ResourceHandler rh)This is called by Container to indicate that a component is being destroyed.JavaEETransactioncreateImportedTransaction(TransactionInternal jtsTx)voiddelistComponentResources(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 InvocationManagerbooleandelistResource(jakarta.transaction.Transaction tran, TransactionalResource h, int flag)Delist the resource specified from the transactionvoidenlistComponentResources()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 InvocationManagerbooleanenlistResource(jakarta.transaction.Transaction tran, TransactionalResource h)Enlist the resource specified with the transactionprotected booleanenlistXAResource(jakarta.transaction.Transaction tran, TransactionalResource h)voidforceRollback(String txnId)voidfreeze()ArrayListgetActiveTransactions()JavaEETransactiongetCurrentTransaction()Return JavaEETransaction instance associated with the current thread.intgetEffectiveTimeout()ListgetExistingResourceList(Object instance, ComponentInvocation inv)Returns a list of resource handles held by the componentLoggergetLogger()intgetPurgeCancelledTtransactionsAfter()Returns the value to be used to purge transaction tasks after the specified number of cancelled tasks.ListgetResourceList(Object instance, ComponentInvocation inv)get the resources being used in the calling component's invocation contextintgetStatus()static StringgetStatusAsString(int status)jakarta.transaction.TransactiongetTransaction()TransactionAdminBeangetTransactionAdminBean(jakarta.transaction.Transaction tran)StringgetTxLogLocation()Return location of transaction logsXAResourceWrappergetXAResourceWrapper(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.XATerminatorgetXATerminator()This is used by importing transactions via the Connector contract.voidhandlePropertyUpdate(String name, Object value)Handle configuration change.voidinitRecovery(boolean force)Initialize recovery frameworkbooleanisDelegate(JavaEETransactionManagerDelegate d)booleanisFrozen()XXX ???booleanisInvocationStackEmpty()booleanisNullTransaction()Return true if a "null transaction context" was received from the client.booleanisTimedOut()Utility for the ejb container to check if the transaction is marked for rollback because of timeout.voidmonitorTxBegin(jakarta.transaction.Transaction tx)voidmonitorTxCompleted(Object obj, boolean b)voidpostConstruct()voidpostInvoke(ComponentInvocation curr, ComponentInvocation prev)Called by InvocationManagervoidpreInvoke(ComponentInvocation prev)Called by InvocationManagervoidrecover(XAResource[] resourceList)booleanrecoverIncompleteTx(boolean delegated, String logPath, XAResource[] xaresArray)Called by the ResourceRecoveryManager to recover the populated array of XAResource.voidrecreate(Xid xid, long timeout)Recreate a transaction based on the Xid.voidregisterComponentResource(TransactionalResource h)voidregisterRecoveryResourceHandler(XAResource xaResource)Allows an arbitrary XAResource to register for recoveryvoidregisterSynchronization(jakarta.transaction.Synchronization sync)register a synchronization object with the transaction associated with the current threadvoidrelease(Xid xid)Release a transaction.booleanresourceEnlistable(TransactionalResource h)voidresume(jakarta.transaction.Transaction tobj)voidrollback()voidsetCurrentTransaction(JavaEETransaction t)Update JavaEETransaction associated with the current thread.voidsetDefaultTransactionTimeout(int seconds)voidsetDelegate(JavaEETransactionManagerDelegate d)Explicitly set the JavaEETransactionManagerDelegate instance for implementation-specific callbacks.voidsetMonitoringEnabled(boolean enabled)voidsetPurgeCancelledTtransactionsAfter(int num)Modify the value to be used to purge transaction tasks after the specified number of cancelled tasks.voidsetRollbackOnly()voidsetTransactionCompeting(boolean b)voidsetTransactionTimeout(int seconds)Modify the value of the timeout value that is associated with the transactions started by the current thread with the begin method.voidshutdown()Perform shutdown cleanup.voidstartJTSTx(JavaEETransaction t)jakarta.transaction.Transactionsuspend()voidunfreeze()voidunregisterComponentResource(TransactionalResource h)
-
-
-
Field Detail
-
_logger
protected Logger _logger
-
invMgr
@Inject protected InvocationManager invMgr
-
-
Method Detail
-
postConstruct
public void postConstruct()
- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
clearThreadTx
public void clearThreadTx()
Clears the transaction associated with the caller thread- Specified by:
clearThreadTxin interfaceJavaEETransactionManager
-
getTxLogLocation
public String getTxLogLocation()
Return location of transaction logs- Specified by:
getTxLogLocationin interfaceJavaEETransactionManager- Returns:
- String location of transaction logs
-
registerRecoveryResourceHandler
public void registerRecoveryResourceHandler(XAResource xaResource)
Allows an arbitrary XAResource to register for recovery- Specified by:
registerRecoveryResourceHandlerin interfaceJavaEETransactionManager- Parameters:
xaResource- XAResource to register for recovery
-
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 interfaceJavaEETransactionManager
-
shutdown
public void shutdown()
Description copied from interface:JavaEETransactionManagerPerform shutdown cleanup.- Specified by:
shutdownin interfaceJavaEETransactionManager
-
initRecovery
public void initRecovery(boolean force)
Description copied from interface:JavaEETransactionManagerInitialize recovery framework- Specified by:
initRecoveryin interfaceJavaEETransactionManager- Parameters:
force- if true, forces initialization, otherwise relies on the TimerService configuration.
-
recover
public void recover(XAResource[] resourceList)
- Specified by:
recoverin interfaceJavaEETransactionManager
-
enlistResource
public boolean enlistResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerEnlist the resource specified with the transaction- Specified by:
enlistResourcein interfaceJavaEETransactionManager- 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
-
unregisterComponentResource
public void unregisterComponentResource(TransactionalResource h)
- Specified by:
unregisterComponentResourcein interfaceJavaEETransactionManager
-
startJTSTx
public void startJTSTx(JavaEETransaction t) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
- Throws:
jakarta.transaction.RollbackExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
getResourceList
public List getResourceList(Object instance, ComponentInvocation inv)
get the resources being used in the calling component's invocation context- Specified by:
getResourceListin interfaceJavaEETransactionManager- Parameters:
instance- Calling component instanceinv- Calling component's invocation information- Returns:
- List of resources
-
enlistComponentResources
public void enlistComponentResources() throws RemoteExceptionDescription copied from interface:JavaEETransactionManagerThis 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- Specified by:
enlistComponentResourcesin interfaceJavaEETransactionManager- Throws:
RemoteException
-
delistResource
public boolean delistResource(jakarta.transaction.Transaction tran, TransactionalResource h, int flag) throws IllegalStateException, jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerDelist the resource specified from the transaction- Specified by:
delistResourcein interfaceJavaEETransactionManager- 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
-
delistComponentResources
public void delistComponentResources(boolean suspend) throws RemoteExceptionDescription copied from interface:JavaEETransactionManagerThis 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- Specified by:
delistComponentResourcesin interfaceJavaEETransactionManager- Parameters:
suspend- true if the resources should be delisted with TMSUSPEND flag; false otherwise- Throws:
RemoteException
-
registerComponentResource
public void registerComponentResource(TransactionalResource h)
- Specified by:
registerComponentResourcein interfaceJavaEETransactionManager
-
getExistingResourceList
public List getExistingResourceList(Object instance, ComponentInvocation inv)
Description copied from interface:JavaEETransactionManagerReturns a list of resource handles held by the component- Specified by:
getExistingResourceListin interfaceJavaEETransactionManager
-
preInvoke
public void preInvoke(ComponentInvocation prev) throws InvocationException
Description copied from interface:JavaEETransactionManagerCalled by InvocationManager- Specified by:
preInvokein interfaceJavaEETransactionManager- Throws:
InvocationException
-
postInvoke
public void postInvoke(ComponentInvocation curr, ComponentInvocation prev) throws InvocationException
Description copied from interface:JavaEETransactionManagerCalled by InvocationManager- Specified by:
postInvokein interfaceJavaEETransactionManager- Throws:
InvocationException
-
componentDestroyed
public void componentDestroyed(Object instance)
Description copied from interface:JavaEETransactionManagerThis is called by Container to indicate that a component is being destroyed. All resources registered in the context should be released- Specified by:
componentDestroyedin interfaceJavaEETransactionManager- Parameters:
instance- The component instance
-
componentDestroyed
public void componentDestroyed(Object instance, ComponentInvocation inv)
Description copied from interface:JavaEETransactionManagerThis 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.- Specified by:
componentDestroyedin interfaceJavaEETransactionManager- Parameters:
instance- The component instanceinv- The ComponentInvocation
-
componentDestroyed
public void componentDestroyed(ResourceHandler rh)
Description copied from interface:JavaEETransactionManagerThis is called by Container to indicate that a component is being destroyed. All resources registered with this ResourceHandler should be released.- Specified by:
componentDestroyedin interfaceJavaEETransactionManager- Parameters:
rh- The ResourceHandler
-
isTimedOut
public boolean isTimedOut()
Description copied from interface:JavaEETransactionManagerUtility 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- Specified by:
isTimedOutin interfaceJavaEETransactionManager
-
checkTransactionImport
public void checkTransactionImport()
Called from the CORBA Interceptors on the server-side when the server is replying to the client (local + remote client). Check if there is an active transaction and remove it from TLS.- Specified by:
checkTransactionImportin interfaceJavaEETransactionManager
-
checkTransactionExport
public void checkTransactionExport(boolean isLocal)
Called from the CORBA Interceptors on the client-side when a client makes a call to a remote object (not in the same JVM). Check if there is an active, exportable transaction.- Specified by:
checkTransactionExportin interfaceJavaEETransactionManager- Throws:
RuntimeException- if the transaction is not exportable
-
getXATerminator
public jakarta.resource.spi.XATerminator getXATerminator()
This is used by importing transactions via the Connector contract. Should not be called- Specified by:
getXATerminatorin interfaceJavaEETransactionManager- Returns:
- a
XATerminatorinstance. - Throws:
UnsupportedOperationException
-
release
public 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.
- Specified by:
releasein interfaceJavaEETransactionManager- 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
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:
recreatein interfaceJavaEETransactionManager- Parameters:
xid- the Xid object representing a transaction.- Throws:
jakarta.resource.spi.work.WorkException
-
registerSynchronization
public void registerSynchronization(jakarta.transaction.Synchronization sync) throws IllegalStateException, jakarta.transaction.SystemExceptionDescription copied from interface:JavaEETransactionManagerregister a synchronization object with the transaction associated with the current thread- Specified by:
registerSynchronizationin interfaceJavaEETransactionManager- 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 condition
-
begin
public void begin() throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemException- Specified by:
beginin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.NotSupportedExceptionjakarta.transaction.SystemException
-
begin
public void begin(int timeout) throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemExceptionThis method is introduced as part of implementing the local transaction timeout capability. Implementation of begin() moved here. Previpusly there is no timeout infrastructure for local txns, so when ever a timeout required for local txn, it uses the globaltxn timeout infrastructure by doing an XA simulation.- Specified by:
beginin interfaceJavaEETransactionManager- Throws:
jakarta.transaction.NotSupportedExceptionjakarta.transaction.SystemException
-
commit
public void commit() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, IllegalStateException, jakarta.transaction.SystemException- Specified by:
commitin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.RollbackExceptionjakarta.transaction.HeuristicMixedExceptionjakarta.transaction.HeuristicRollbackExceptionSecurityExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
rollback
public void rollback() throws IllegalStateException, SecurityException, jakarta.transaction.SystemException- Specified by:
rollbackin interfacejakarta.transaction.TransactionManager- Throws:
IllegalStateExceptionSecurityExceptionjakarta.transaction.SystemException
-
getStatus
public int getStatus() throws jakarta.transaction.SystemException- Specified by:
getStatusin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemException- Specified by:
getTransactionin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
setRollbackOnly
public void setRollbackOnly() throws IllegalStateException, jakarta.transaction.SystemException- Specified by:
setRollbackOnlyin interfacejakarta.transaction.TransactionManager- Throws:
IllegalStateExceptionjakarta.transaction.SystemException
-
suspend
public jakarta.transaction.Transaction suspend() throws jakarta.transaction.SystemException- Specified by:
suspendin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
resume
public void resume(jakarta.transaction.Transaction tobj) throws jakarta.transaction.InvalidTransactionException, IllegalStateException, jakarta.transaction.SystemException- Specified by:
resumein interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.InvalidTransactionExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
setTransactionTimeout
public void setTransactionTimeout(int seconds) throws jakarta.transaction.SystemExceptionModify the value of the timeout value that is associated with the transactions started by the current thread with the begin method.If an application has not called this method, the transaction service uses some default value for the transaction timeout.
- Specified by:
setTransactionTimeoutin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException- Thrown if the transaction manager encounters an unexpected error condition
-
setPurgeCancelledTtransactionsAfter
public void setPurgeCancelledTtransactionsAfter(int num)
Modify the value to be used to purge transaction tasks after the specified number of cancelled tasks.- Specified by:
setPurgeCancelledTtransactionsAfterin interfaceJavaEETransactionManager
-
getPurgeCancelledTtransactionsAfter
public int getPurgeCancelledTtransactionsAfter()
Returns the value to be used to purge transaction tasks after the specified number of cancelled tasks.- Specified by:
getPurgeCancelledTtransactionsAfterin interfaceJavaEETransactionManager
-
getCurrentTransaction
public JavaEETransaction getCurrentTransaction()
Description copied from interface:JavaEETransactionManagerReturn JavaEETransaction instance associated with the current thread.- Specified by:
getCurrentTransactionin interfaceJavaEETransactionManager- Returns:
- the JavaEETransaction associated with the current thread or null if it there is none.
-
setCurrentTransaction
public void setCurrentTransaction(JavaEETransaction t)
Description copied from interface:JavaEETransactionManagerUpdate JavaEETransaction associated with the current thread.- Specified by:
setCurrentTransactionin interfaceJavaEETransactionManager- Parameters:
t- the JavaEETransaction associated with the current thread or null if the existing transaction had been completed.
-
getXAResourceWrapper
public XAResourceWrapper getXAResourceWrapper(String clName)
Description copied from interface:JavaEETransactionManagerReturn XAResourceWrapper instance specific to this datasource class name that can be used instead of the driver provided version for transaction recovery.- Specified by:
getXAResourceWrapperin interfaceJavaEETransactionManager- 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
public void handlePropertyUpdate(String name, Object value)
Description copied from interface:JavaEETransactionManagerHandle configuration change. Actual change will be performed by the delegate.- Specified by:
handlePropertyUpdatein interfaceJavaEETransactionManager- 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:JavaEETransactionManagerCalled by the ResourceRecoveryManager to recover the populated array of XAResource.- Specified by:
recoverIncompleteTxin interfaceJavaEETransactionManager- 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
-
freeze
public void freeze()
- Specified by:
freezein interfaceJavaEETransactionManager
-
unfreeze
public void unfreeze()
- Specified by:
unfreezein interfaceJavaEETransactionManager
-
isFrozen
public boolean isFrozen()
XXX ???- Specified by:
isFrozenin interfaceJavaEETransactionManager
-
cleanTxnTimeout
public void cleanTxnTimeout()
- Specified by:
cleanTxnTimeoutin interfaceJavaEETransactionManager
-
getEffectiveTimeout
public int getEffectiveTimeout()
-
setDefaultTransactionTimeout
public void setDefaultTransactionTimeout(int seconds)
- Specified by:
setDefaultTransactionTimeoutin interfaceJavaEETransactionManager
-
getActiveTransactions
public ArrayList getActiveTransactions()
- Specified by:
getActiveTransactionsin interfaceJavaEETransactionManager
-
getTransactionAdminBean
public TransactionAdminBean getTransactionAdminBean(jakarta.transaction.Transaction tran) throws jakarta.transaction.SystemException
- Throws:
jakarta.transaction.SystemException
-
forceRollback
public void forceRollback(String txnId) throws IllegalStateException, jakarta.transaction.SystemException
- Specified by:
forceRollbackin interfaceJavaEETransactionManager- Throws:
IllegalStateExceptionjakarta.transaction.SystemException
-
setMonitoringEnabled
public void setMonitoringEnabled(boolean enabled)
- Specified by:
setMonitoringEnabledin interfaceJavaEETransactionManager
-
getStatusAsString
public static String getStatusAsString(int status)
-
enlistXAResource
protected boolean enlistXAResource(jakarta.transaction.Transaction tran, TransactionalResource h) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException- Throws:
jakarta.transaction.RollbackExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
isDelegate
public boolean isDelegate(JavaEETransactionManagerDelegate d)
-
setDelegate
public void setDelegate(JavaEETransactionManagerDelegate d)
Description copied from interface:JavaEETransactionManagerExplicitly set the JavaEETransactionManagerDelegate instance for implementation-specific callbacks.- Specified by:
setDelegatein interfaceJavaEETransactionManager- Parameters:
d- the JavaEETransactionManagerDelegate instance.
-
getLogger
public Logger getLogger()
-
monitorTxCompleted
public void monitorTxCompleted(Object obj, boolean b)
-
monitorTxBegin
public void monitorTxBegin(jakarta.transaction.Transaction tx)
-
resourceEnlistable
public boolean resourceEnlistable(TransactionalResource h)
-
isInvocationStackEmpty
public boolean isInvocationStackEmpty()
-
setTransactionCompeting
public void setTransactionCompeting(boolean b)
-
createImportedTransaction
public JavaEETransaction createImportedTransaction(TransactionInternal jtsTx) throws jakarta.transaction.SystemException
- Throws:
jakarta.transaction.SystemException
-
-