Class 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.PostConstruct
    Implementation 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
    • Constructor Detail

      • JavaEETransactionManagerSimplified

        public JavaEETransactionManagerSimplified()
    • Method Detail

      • postConstruct

        public void postConstruct()
        Specified by:
        postConstruct in interface org.glassfish.hk2.api.PostConstruct
      • 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
      • initRecovery

        public void initRecovery​(boolean force)
        Description copied from interface: JavaEETransactionManager
        Initialize recovery framework
        Specified by:
        initRecovery in interface JavaEETransactionManager
        Parameters:
        force - if true, forces initialization, otherwise relies on the TimerService configuration.
      • enlistResource

        public boolean enlistResource​(jakarta.transaction.Transaction tran,
                                      TransactionalResource h)
                               throws jakarta.transaction.RollbackException,
                                      IllegalStateException,
                                      jakarta.transaction.SystemException
        Description copied from interface: JavaEETransactionManager
        Enlist the resource specified with the transaction
        Specified by:
        enlistResource in interface JavaEETransactionManager
        Parameters:
        tran - The transaction object
        h - 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
      • getResourceList

        public List getResourceList​(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
      • delistResource

        public boolean delistResource​(jakarta.transaction.Transaction tran,
                                      TransactionalResource h,
                                      int flag)
                               throws IllegalStateException,
                                      jakarta.transaction.SystemException
        Description copied from interface: JavaEETransactionManager
        Delist the resource specified from the transaction
        Specified by:
        delistResource in interface JavaEETransactionManager
        Parameters:
        tran - The transaction object
        h - The resource handle object
        flag - 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 RemoteException
        Description copied from interface: JavaEETransactionManager
        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
        Specified by:
        delistComponentResources in interface JavaEETransactionManager
        Parameters:
        suspend - true if the resources should be delisted with TMSUSPEND flag; false otherwise
        Throws:
        RemoteException
      • componentDestroyed

        public void componentDestroyed​(Object instance)
        Description copied from interface: JavaEETransactionManager
        This is called by Container to indicate that a component is being destroyed. All resources registered in the context should be released
        Specified by:
        componentDestroyed in interface JavaEETransactionManager
        Parameters:
        instance - The component instance
      • componentDestroyed

        public void componentDestroyed​(Object instance,
                                       ComponentInvocation inv)
        Description copied from interface: JavaEETransactionManager
        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.
        Specified by:
        componentDestroyed in interface JavaEETransactionManager
        Parameters:
        instance - The component instance
        inv - The ComponentInvocation
      • isTimedOut

        public boolean isTimedOut()
        Description copied from interface: JavaEETransactionManager
        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
        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:
        RuntimeException - if the transaction is not exportable
      • 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:
        release in interface JavaEETransactionManager
        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:
        recreate in interface JavaEETransactionManager
        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.SystemException
        Description copied from interface: JavaEETransactionManager
        register a synchronization object with the transaction associated with the current thread
        Specified by:
        registerSynchronization in interface JavaEETransactionManager
        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:
        begin in interface jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.NotSupportedException
        jakarta.transaction.SystemException
      • begin

        public void begin​(int timeout)
                   throws jakarta.transaction.NotSupportedException,
                          jakarta.transaction.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:
        jakarta.transaction.NotSupportedException
        jakarta.transaction.SystemException
      • commit

        public void commit()
                    throws jakarta.transaction.RollbackException,
                           jakarta.transaction.HeuristicMixedException,
                           jakarta.transaction.HeuristicRollbackException,
                           SecurityException,
                           IllegalStateException,
                           jakarta.transaction.SystemException
        Specified by:
        commit in interface jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.RollbackException
        jakarta.transaction.HeuristicMixedException
        jakarta.transaction.HeuristicRollbackException
        SecurityException
        IllegalStateException
        jakarta.transaction.SystemException
      • getStatus

        public int getStatus()
                      throws jakarta.transaction.SystemException
        Specified by:
        getStatus in interface jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.SystemException
      • getTransaction

        public jakarta.transaction.Transaction getTransaction()
                                                       throws jakarta.transaction.SystemException
        Specified by:
        getTransaction in interface jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.SystemException
      • setRollbackOnly

        public void setRollbackOnly()
                             throws IllegalStateException,
                                    jakarta.transaction.SystemException
        Specified by:
        setRollbackOnly in interface jakarta.transaction.TransactionManager
        Throws:
        IllegalStateException
        jakarta.transaction.SystemException
      • suspend

        public jakarta.transaction.Transaction suspend()
                                                throws jakarta.transaction.SystemException
        Specified by:
        suspend in interface jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.SystemException
      • resume

        public void resume​(jakarta.transaction.Transaction tobj)
                    throws jakarta.transaction.InvalidTransactionException,
                           IllegalStateException,
                           jakarta.transaction.SystemException
        Specified by:
        resume in interface jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.InvalidTransactionException
        IllegalStateException
        jakarta.transaction.SystemException
      • setTransactionTimeout

        public void setTransactionTimeout​(int seconds)
                                   throws jakarta.transaction.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 jakarta.transaction.TransactionManager
        Throws:
        jakarta.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition
      • getXAResourceWrapper

        public XAResourceWrapper getXAResourceWrapper​(String clName)
        Description copied from interface: JavaEETransactionManager
        Return XAResourceWrapper instance specific to this datasource class name that can be used instead of the driver provided version for transaction recovery.
        Specified by:
        getXAResourceWrapper in interface JavaEETransactionManager
        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: JavaEETransactionManager
        Handle configuration change. Actual change will be performed by the delegate.
        Specified by:
        handlePropertyUpdate in interface JavaEETransactionManager
        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 Exception
        Description copied from interface: JavaEETransactionManager
        Called by the ResourceRecoveryManager to recover the populated array of XAResource.
        Specified by:
        recoverIncompleteTx in interface JavaEETransactionManager
        Parameters:
        delegated - true if the recovery process is owned by this instance.
        logPath - the name of the transaction logging directory
        xaresArray - the array of XA Resources to be recovered.
        Returns:
        true if the recovery has been successful.
        Throws:
        Exception
      • getEffectiveTimeout

        public int getEffectiveTimeout()
      • getTransactionAdminBean

        public TransactionAdminBean getTransactionAdminBean​(jakarta.transaction.Transaction tran)
                                                     throws jakarta.transaction.SystemException
        Throws:
        jakarta.transaction.SystemException
      • 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.RollbackException
        IllegalStateException
        jakarta.transaction.SystemException
      • getLogger

        public Logger getLogger()
      • monitorTxCompleted

        public void monitorTxCompleted​(Object obj,
                                       boolean b)
      • monitorTxBegin

        public void monitorTxBegin​(jakarta.transaction.Transaction tx)
      • isInvocationStackEmpty

        public boolean isInvocationStackEmpty()
      • setTransactionCompeting

        public void setTransactionCompeting​(boolean b)
      • createImportedTransaction

        public JavaEETransaction createImportedTransaction​(TransactionInternal jtsTx)
                                                    throws jakarta.transaction.SystemException
        Throws:
        jakarta.transaction.SystemException