com.sun.enterprise.transaction
Class JavaEETransactionManagerSimplified

java.lang.Object
  extended by com.sun.enterprise.transaction.JavaEETransactionManagerSimplified
All Implemented Interfaces:
JavaEETransactionManager, TransactionManager, org.jvnet.hk2.component.PostConstruct

@Service
public class JavaEETransactionManagerSimplified
extends java.lang.Object
implements JavaEETransactionManager, org.jvnet.hk2.component.PostConstruct

Implementation of javax.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
protected  java.util.logging.Logger _logger
           
protected  InvocationManager invMgr
           
 
Constructor Summary
JavaEETransactionManagerSimplified()
           
 
Method Summary
 void begin()
           
 void begin(int timeout)
          This method is introduced as part of implementing the local transaction timeout capability.
 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).
 void checkTransactionImport()
          Called from the CORBA Interceptors on the server-side when the server is replying to the client (local + remote client).
 void cleanTxnTimeout()
           
 void clearThreadTx()
          Clears the transaction associated with the caller thread
 void commit()
           
 void componentDestroyed(java.lang.Object instance)
           
 void componentDestroyed(java.lang.Object instance, ComponentInvocation inv)
           
 void componentDestroyed(ResourceHandler rh)
           
 JavaEETransaction createImportedTransaction(TransactionInternal jtsTx)
           
 void delistComponentResources(boolean suspend)
           
 boolean delistResource(Transaction tran, TransactionalResource h, int flag)
           
 void enlistComponentResources()
           
 boolean enlistResource(Transaction tran, TransactionalResource h)
           
protected  boolean enlistXAResource(Transaction tran, TransactionalResource h)
           
 void forceRollback(java.lang.String txnId)
           
 void freeze()
           
 java.util.ArrayList getActiveTransactions()
           
 JavaEETransaction getCurrentTransaction()
           
 int getEffectiveTimeout()
           
 java.util.List getExistingResourceList(java.lang.Object instance, ComponentInvocation inv)
           
 java.util.logging.Logger getLogger()
           
 int getPurgeCancelledTtransactionsAfter()
          Returns the value to be used to purge transaction tasks after the specified number of cancelled tasks.
 java.util.List getResourceList(java.lang.Object instance, ComponentInvocation inv)
          get the resources being used in the calling component's invocation context
 int getStatus()
           
static java.lang.String getStatusAsString(int status)
           
 Transaction getTransaction()
           
 TransactionAdminBean getTransactionAdminBean(Transaction tran)
           
 java.lang.String getTxLogLocation()
          
 XAResourceWrapper getXAResourceWrapper(java.lang.String clName)
           
 XATerminator getXATerminator()
          This is used by importing transactions via the Connector contract.
 void handlePropertyUpdate(java.lang.String name, java.lang.Object value)
           
 void initRecovery(boolean force)
           
 boolean isDelegate(JavaEETransactionManagerDelegate d)
           
 boolean isFrozen()
          XXX ???
 boolean isInvocationStackEmpty()
           
 boolean isNullTransaction()
          Return true if a "null transaction context" was received from the client.
 boolean isTimedOut()
           
 void monitorTxBegin(Transaction tx)
           
protected  void monitorTxCompleted(java.lang.Object obj, boolean committed)
           
 void monitorTxCompleted0(java.lang.Object obj, boolean b)
           
 void postConstruct()
           
 void postInvoke(ComponentInvocation curr, ComponentInvocation prev)
           
 void preInvoke(ComponentInvocation prev)
           
 void recover(XAResource[] resourceList)
           
 boolean recoverIncompleteTx(boolean delegated, java.lang.String logPath, XAResource[] xaresArray)
           
 void recreate(Xid xid, long timeout)
          Recreate a transaction based on the Xid.
 void registerComponentResource(TransactionalResource h)
           
 void registerRecoveryResourceHandler(XAResource xaResource)
          
 void registerSynchronization(Synchronization sync)
           
 void release(Xid xid)
          Release a transaction.
 boolean resourceEnlistable(TransactionalResource h)
           
 void resume(Transaction tobj)
           
 void rollback()
           
 void setCurrentTransaction(JavaEETransaction t)
           
 void setDefaultTransactionTimeout(int seconds)
           
 void setDelegate(JavaEETransactionManagerDelegate d)
           
 void setMonitoringEnabled(boolean enabled)
           
 void setPurgeCancelledTtransactionsAfter(int num)
          Modify the value to be used to purge transaction tasks after the specified number of cancelled tasks.
 void setRollbackOnly()
           
 void setTransactionCompeting(boolean b)
           
 void setTransactionTimeout(int seconds)
          Modify the value of the timeout value that is associated with the transactions started by the current thread with the begin method.
 void shutdown()
           
 void startJTSTx(JavaEETransaction t)
           
 Transaction suspend()
           
 void unfreeze()
           
 void unregisterComponentResource(TransactionalResource h)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_logger

protected java.util.logging.Logger _logger

invMgr

protected InvocationManager invMgr
Constructor Detail

JavaEETransactionManagerSimplified

public JavaEETransactionManagerSimplified()
Method Detail

postConstruct

public void postConstruct()
Specified by:
postConstruct in interface org.jvnet.hk2.component.PostConstruct

clearThreadTx

public void clearThreadTx()
Clears the transaction associated with the caller thread

Specified by:
clearThreadTx in interface JavaEETransactionManager

getTxLogLocation

public java.lang.String getTxLogLocation()

Specified by:
getTxLogLocation in interface JavaEETransactionManager

registerRecoveryResourceHandler

public void registerRecoveryResourceHandler(XAResource xaResource)

Specified by:
registerRecoveryResourceHandler in interface JavaEETransactionManager

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:
isNullTransaction in interface JavaEETransactionManager

shutdown

public void shutdown()
Specified by:
shutdown in interface JavaEETransactionManager

initRecovery

public void initRecovery(boolean force)
Specified by:
initRecovery in interface JavaEETransactionManager

recover

public void recover(XAResource[] resourceList)
Specified by:
recover in interface JavaEETransactionManager

enlistResource

public boolean enlistResource(Transaction tran,
                              TransactionalResource h)
                       throws RollbackException,
                              java.lang.IllegalStateException,
                              SystemException
Specified by:
enlistResource in interface JavaEETransactionManager
Throws:
RollbackException
java.lang.IllegalStateException
SystemException

unregisterComponentResource

public void unregisterComponentResource(TransactionalResource h)
Specified by:
unregisterComponentResource in interface JavaEETransactionManager

startJTSTx

public void startJTSTx(JavaEETransaction t)
                throws RollbackException,
                       java.lang.IllegalStateException,
                       SystemException
Throws:
RollbackException
java.lang.IllegalStateException
SystemException

getResourceList

public java.util.List getResourceList(java.lang.Object instance,
                                      ComponentInvocation inv)
get the resources being used in the calling component's invocation context

Specified by:
getResourceList in interface JavaEETransactionManager
Parameters:
instance - Calling component instance
inv - Calling component's invocation information
Returns:
List of resources

enlistComponentResources

public void enlistComponentResources()
                              throws java.rmi.RemoteException
Specified by:
enlistComponentResources in interface JavaEETransactionManager
Throws:
java.rmi.RemoteException

delistResource

public boolean delistResource(Transaction tran,
                              TransactionalResource h,
                              int flag)
                       throws java.lang.IllegalStateException,
                              SystemException
Specified by:
delistResource in interface JavaEETransactionManager
Throws:
java.lang.IllegalStateException
SystemException

delistComponentResources

public void delistComponentResources(boolean suspend)
                              throws java.rmi.RemoteException
Specified by:
delistComponentResources in interface JavaEETransactionManager
Throws:
java.rmi.RemoteException

registerComponentResource

public void registerComponentResource(TransactionalResource h)
Specified by:
registerComponentResource in interface JavaEETransactionManager

getExistingResourceList

public java.util.List getExistingResourceList(java.lang.Object instance,
                                              ComponentInvocation inv)
Specified by:
getExistingResourceList in interface JavaEETransactionManager

preInvoke

public void preInvoke(ComponentInvocation prev)
               throws InvocationException
Specified by:
preInvoke in interface JavaEETransactionManager
Throws:
InvocationException

postInvoke

public void postInvoke(ComponentInvocation curr,
                       ComponentInvocation prev)
                throws InvocationException
Specified by:
postInvoke in interface JavaEETransactionManager
Throws:
InvocationException

componentDestroyed

public void componentDestroyed(java.lang.Object instance)
Specified by:
componentDestroyed in interface JavaEETransactionManager

componentDestroyed

public void componentDestroyed(java.lang.Object instance,
                               ComponentInvocation inv)
Specified by:
componentDestroyed in interface JavaEETransactionManager

componentDestroyed

public void componentDestroyed(ResourceHandler rh)
Specified by:
componentDestroyed in interface JavaEETransactionManager

isTimedOut

public boolean isTimedOut()
Specified by:
isTimedOut in interface JavaEETransactionManager

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:
checkTransactionImport in interface JavaEETransactionManager

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:
checkTransactionExport in interface JavaEETransactionManager
Throws:
java.lang.RuntimeException - if the transaction is not exportable

getXATerminator

public XATerminator getXATerminator()
This is used by importing transactions via the Connector contract. Should not be called

Specified by:
getXATerminator in interface JavaEETransactionManager
Returns:
a XATerminator instance.
Throws:
java.lang.UnsupportedOperationException

release

public void release(Xid xid)
             throws 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:
release in interface JavaEETransactionManager
Parameters:
xid - the Xid object representing a transaction.
Throws:
WorkException

recreate

public void recreate(Xid xid,
                     long timeout)
              throws 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:
recreate in interface JavaEETransactionManager
Parameters:
xid - the Xid object representing a transaction.
Throws:
WorkException

registerSynchronization

public void registerSynchronization(Synchronization sync)
                             throws java.lang.IllegalStateException,
                                    SystemException
Specified by:
registerSynchronization in interface JavaEETransactionManager
Throws:
java.lang.IllegalStateException
SystemException

begin

public void begin()
           throws NotSupportedException,
                  SystemException
Specified by:
begin in interface TransactionManager
Throws:
NotSupportedException
SystemException

begin

public void begin(int timeout)
           throws NotSupportedException,
                  SystemException
This 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:
begin in interface JavaEETransactionManager
Throws:
NotSupportedException
SystemException

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   java.lang.SecurityException,
                   java.lang.IllegalStateException,
                   SystemException
Specified by:
commit in interface TransactionManager
Throws:
RollbackException
HeuristicMixedException
HeuristicRollbackException
java.lang.SecurityException
java.lang.IllegalStateException
SystemException

rollback

public void rollback()
              throws java.lang.IllegalStateException,
                     java.lang.SecurityException,
                     SystemException
Specified by:
rollback in interface TransactionManager
Throws:
java.lang.IllegalStateException
java.lang.SecurityException
SystemException

getStatus

public int getStatus()
              throws SystemException
Specified by:
getStatus in interface TransactionManager
Throws:
SystemException

getTransaction

public Transaction getTransaction()
                           throws SystemException
Specified by:
getTransaction in interface TransactionManager
Throws:
SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws java.lang.IllegalStateException,
                            SystemException
Specified by:
setRollbackOnly in interface TransactionManager
Throws:
java.lang.IllegalStateException
SystemException

suspend

public Transaction suspend()
                    throws SystemException
Specified by:
suspend in interface TransactionManager
Throws:
SystemException

resume

public void resume(Transaction tobj)
            throws InvalidTransactionException,
                   java.lang.IllegalStateException,
                   SystemException
Specified by:
resume in interface TransactionManager
Throws:
InvalidTransactionException
java.lang.IllegalStateException
SystemException

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws SystemException
Modify 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:
setTransactionTimeout in interface TransactionManager
Throws:
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:
setPurgeCancelledTtransactionsAfter in interface JavaEETransactionManager

getPurgeCancelledTtransactionsAfter

public int getPurgeCancelledTtransactionsAfter()
Returns the value to be used to purge transaction tasks after the specified number of cancelled tasks.

Specified by:
getPurgeCancelledTtransactionsAfter in interface JavaEETransactionManager

getCurrentTransaction

public JavaEETransaction getCurrentTransaction()
Specified by:
getCurrentTransaction in interface JavaEETransactionManager

setCurrentTransaction

public void setCurrentTransaction(JavaEETransaction t)
Specified by:
setCurrentTransaction in interface JavaEETransactionManager

getXAResourceWrapper

public XAResourceWrapper getXAResourceWrapper(java.lang.String clName)
Specified by:
getXAResourceWrapper in interface JavaEETransactionManager

handlePropertyUpdate

public void handlePropertyUpdate(java.lang.String name,
                                 java.lang.Object value)
Specified by:
handlePropertyUpdate in interface JavaEETransactionManager

recoverIncompleteTx

public boolean recoverIncompleteTx(boolean delegated,
                                   java.lang.String logPath,
                                   XAResource[] xaresArray)
                            throws java.lang.Exception
Specified by:
recoverIncompleteTx in interface JavaEETransactionManager
Throws:
java.lang.Exception

freeze

public void freeze()
Specified by:
freeze in interface JavaEETransactionManager

unfreeze

public void unfreeze()
Specified by:
unfreeze in interface JavaEETransactionManager

isFrozen

public boolean isFrozen()
XXX ???

Specified by:
isFrozen in interface JavaEETransactionManager

cleanTxnTimeout

public void cleanTxnTimeout()
Specified by:
cleanTxnTimeout in interface JavaEETransactionManager

getEffectiveTimeout

public int getEffectiveTimeout()

setDefaultTransactionTimeout

public void setDefaultTransactionTimeout(int seconds)
Specified by:
setDefaultTransactionTimeout in interface JavaEETransactionManager

getActiveTransactions

public java.util.ArrayList getActiveTransactions()
Specified by:
getActiveTransactions in interface JavaEETransactionManager

getTransactionAdminBean

public TransactionAdminBean getTransactionAdminBean(Transaction tran)
                                             throws SystemException
Throws:
SystemException

forceRollback

public void forceRollback(java.lang.String txnId)
                   throws java.lang.IllegalStateException,
                          SystemException
Specified by:
forceRollback in interface JavaEETransactionManager
Throws:
java.lang.IllegalStateException
SystemException

setMonitoringEnabled

public void setMonitoringEnabled(boolean enabled)
Specified by:
setMonitoringEnabled in interface JavaEETransactionManager

monitorTxCompleted

protected void monitorTxCompleted(java.lang.Object obj,
                                  boolean committed)

getStatusAsString

public static java.lang.String getStatusAsString(int status)

enlistXAResource

protected boolean enlistXAResource(Transaction tran,
                                   TransactionalResource h)
                            throws RollbackException,
                                   java.lang.IllegalStateException,
                                   SystemException
Throws:
RollbackException
java.lang.IllegalStateException
SystemException

isDelegate

public boolean isDelegate(JavaEETransactionManagerDelegate d)

setDelegate

public void setDelegate(JavaEETransactionManagerDelegate d)
Specified by:
setDelegate in interface JavaEETransactionManager

getLogger

public java.util.logging.Logger getLogger()

monitorTxCompleted0

public void monitorTxCompleted0(java.lang.Object obj,
                                boolean b)

monitorTxBegin

public void monitorTxBegin(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 SystemException
Throws:
SystemException


Copyright © 2012 GlassFish Community. All Rights Reserved.