Class TransactionManagerImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTransactionAssociationListener​(TransactionManagerMonitor listener)  
      void begin()
      Create a new transaction and associate it with the current thread.
      javax.transaction.Transaction begin​(long transactionTimeoutMilliseconds)  
      void commit()
      Complete the transaction associated with the current thread.
      void commit​(javax.transaction.Transaction tx, boolean onePhase)  
      void forget​(javax.transaction.Transaction tx)  
      long getActiveCount()
      Returns the number of active transactions.
      java.util.Map<javax.transaction.xa.Xid,​TransactionImpl> getExternalXids()  
      java.lang.Object getResource​(java.lang.Object key)
      Get an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
      boolean getRollbackOnly()
      Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
      int getStatus()
      Obtain the status of the transaction associated with the current thread.
      long getTotalCommits()
      Return the number of total commits
      long getTotalRollbacks()
      Returns the number of total rollbacks
      javax.transaction.Transaction getTransaction()
      Get the transaction object that represents the transaction context of the calling thread.
      java.lang.Object getTransactionKey()
      Return an opaque object to represent the transaction bound to the current thread at the time this method is called.
      int getTransactionStatus()
      Return the status of the transaction bound to the current thread at the time this method is called.
      javax.transaction.Transaction importXid​(javax.transaction.xa.Xid xid, long transactionTimeoutMilliseconds)  
      int prepare​(javax.transaction.Transaction tx)  
      void putResource​(java.lang.Object key, java.lang.Object value)
      Add or replace an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
      void recoveryError​(java.lang.Exception e)  
      void registerInterposedSynchronization​(javax.transaction.Synchronization synchronization)
      jta 1.1 method so the jpa implementations can be told to flush their caches.
      void registerNamedXAResourceFactory​(NamedXAResourceFactory namedXAResourceFactory)  
      void removeTransactionAssociationListener​(TransactionManagerMonitor listener)  
      void resetStatistics()
      Reset statistics
      void resume​(javax.transaction.Transaction tx)
      Resume the transaction context association of the calling thread with the transaction represented by the supplied Transaction object.
      void rollback()
      Roll back the transaction associated with the current thread.
      void rollback​(javax.transaction.Transaction tx)  
      void setRollbackOnly()
      Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
      void setTransactionTimeout​(int seconds)
      Modify the timeout value that is associated with transactions started by the current thread with the begin method.
      javax.transaction.Transaction suspend()
      Suspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended.
      void unregisterNamedXAResourceFactory​(java.lang.String namedXAResourceFactoryName)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TransactionManagerImpl

        public TransactionManagerImpl()
                               throws javax.transaction.xa.XAException
        Throws:
        javax.transaction.xa.XAException
      • TransactionManagerImpl

        public TransactionManagerImpl​(int defaultTransactionTimeoutSeconds)
                               throws javax.transaction.xa.XAException
        Throws:
        javax.transaction.xa.XAException
      • TransactionManagerImpl

        public TransactionManagerImpl​(int defaultTransactionTimeoutSeconds,
                                      TransactionLog transactionLog)
                               throws javax.transaction.xa.XAException
        Throws:
        javax.transaction.xa.XAException
      • TransactionManagerImpl

        public TransactionManagerImpl​(int defaultTransactionTimeoutSeconds,
                                      XidFactory xidFactory,
                                      TransactionLog transactionLog)
                               throws javax.transaction.xa.XAException
        Throws:
        javax.transaction.xa.XAException
    • Method Detail

      • getTransaction

        public javax.transaction.Transaction getTransaction()
        Description copied from interface: javax.transaction.TransactionManager
        Get the transaction object that represents the transaction context of the calling thread.
        Specified by:
        getTransaction in interface javax.transaction.TransactionManager
        Returns:
        the Transaction object representing the transaction associated with the calling thread.
      • setTransactionTimeout

        public void setTransactionTimeout​(int seconds)
                                   throws javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Modify the timeout value that is associated with 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 javax.transaction.TransactionManager
        Specified by:
        setTransactionTimeout in interface javax.transaction.UserTransaction
        Parameters:
        seconds - The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.
        Throws:
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • getStatus

        public int getStatus()
                      throws javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Obtain the status of the transaction associated with the current thread.
        Specified by:
        getStatus in interface javax.transaction.TransactionManager
        Specified by:
        getStatus in interface javax.transaction.UserTransaction
        Returns:
        The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
        Throws:
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • begin

        public void begin()
                   throws javax.transaction.NotSupportedException,
                          javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Create a new transaction and associate it with the current thread.
        Specified by:
        begin in interface javax.transaction.TransactionManager
        Specified by:
        begin in interface javax.transaction.UserTransaction
        Throws:
        javax.transaction.NotSupportedException - Thrown if the thread is already associated with a transaction and the Transaction Manager implementation does not support nested transactions.
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • begin

        public javax.transaction.Transaction begin​(long transactionTimeoutMilliseconds)
                                            throws javax.transaction.NotSupportedException,
                                                   javax.transaction.SystemException
        Throws:
        javax.transaction.NotSupportedException
        javax.transaction.SystemException
      • suspend

        public javax.transaction.Transaction suspend()
                                              throws javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Suspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended. If the calling thread is not associated with a transaction, the method returns a null object reference. When this method returns, the calling thread is not associated with a transaction.
        Specified by:
        suspend in interface javax.transaction.TransactionManager
        Returns:
        Transaction object representing the suspended transaction.
        Throws:
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • resume

        public void resume​(javax.transaction.Transaction tx)
                    throws java.lang.IllegalStateException,
                           javax.transaction.InvalidTransactionException,
                           javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Resume the transaction context association of the calling thread with the transaction represented by the supplied Transaction object. When this method returns, the calling thread is associated with the transaction context specified.
        Specified by:
        resume in interface javax.transaction.TransactionManager
        Parameters:
        tx - The Transaction object that represents the transaction to be resumed.
        Throws:
        java.lang.IllegalStateException - Thrown if the thread is already associated with another transaction.
        javax.transaction.InvalidTransactionException - Thrown if the parameter transaction object contains an invalid transaction.
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • getResource

        public java.lang.Object getResource​(java.lang.Object key)
        Description copied from interface: javax.transaction.TransactionSynchronizationRegistry
        Get an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called. The key should have been supplied earlier by a call to putResouce in the same transaction. If the key cannot be found in the current resource Map, null is returned. The general contract of this method is that of Map.get(Object) for a Map that supports non-null keys and null values. For example, the returned value is null if there is no entry for the parameter key or if the value associated with the key is actually null.
        Specified by:
        getResource in interface javax.transaction.TransactionSynchronizationRegistry
        Parameters:
        key - the key for the Map entry.
        Returns:
        the value associated with the key.
      • getRollbackOnly

        public boolean getRollbackOnly()
        Description copied from interface: javax.transaction.TransactionSynchronizationRegistry
        Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
        Specified by:
        getRollbackOnly in interface javax.transaction.TransactionSynchronizationRegistry
        Returns:
        the rollbackOnly status.
      • getTransactionKey

        public java.lang.Object getTransactionKey()
        Description copied from interface: javax.transaction.TransactionSynchronizationRegistry
        Return an opaque object to represent the transaction bound to the current thread at the time this method is called. This object overrides hashCode and equals to allow its use as the key in a hashMap for use by the caller. If there is no transaction currently active, return null.

        This object will return the same hashCode and compare equal to all other objects returned by calling this method from any component executing in the same transaction context in the same application server.

        The toString method returns a String that might be usable by a human reader to usefully understand the transaction context. The toString result is otherwise not defined. Specifically, there is no forward or backward compatibility guarantee of the results of toString.

        The object is not necessarily serializable, and has no defined behavior outside the virtual machine whence it was obtained.

        Specified by:
        getTransactionKey in interface javax.transaction.TransactionSynchronizationRegistry
        Returns:
        an opaque object representing the transaction bound to the current thread at the time this method is called.
      • getTransactionStatus

        public int getTransactionStatus()
        Description copied from interface: javax.transaction.TransactionSynchronizationRegistry
        Return the status of the transaction bound to the current thread at the time this method is called. This is the result of executing TransactionManager.getStatus() in the context of the transaction bound to the current thread at the time this method is called.
        Specified by:
        getTransactionStatus in interface javax.transaction.TransactionSynchronizationRegistry
        Returns:
        the status of the transaction bound to the current thread at the time this method is called.
      • putResource

        public void putResource​(java.lang.Object key,
                                java.lang.Object value)
        Description copied from interface: javax.transaction.TransactionSynchronizationRegistry
        Add or replace an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called. The supplied key should be of an caller- defined class so as not to conflict with other users. The class of the key must guarantee that the hashCode and equals methods are suitable for use as keys in a map. The key and value are not examined or used by the implementation. The general contract of this method is that of Map.put(Object, Object) for a Map that supports non-null keys and null values. For example, if there is already an value associated with the key, it is replaced by the value parameter.
        Specified by:
        putResource in interface javax.transaction.TransactionSynchronizationRegistry
        Parameters:
        key - the key for the Map entry.
        value - the value for the Map entry.
      • registerInterposedSynchronization

        public void registerInterposedSynchronization​(javax.transaction.Synchronization synchronization)
        jta 1.1 method so the jpa implementations can be told to flush their caches.
        Specified by:
        registerInterposedSynchronization in interface javax.transaction.TransactionSynchronizationRegistry
        Parameters:
        synchronization - interposed synchronization
      • setRollbackOnly

        public void setRollbackOnly()
                             throws java.lang.IllegalStateException
        Description copied from interface: javax.transaction.TransactionManager
        Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
        Specified by:
        setRollbackOnly in interface javax.transaction.TransactionManager
        Specified by:
        setRollbackOnly in interface javax.transaction.TransactionSynchronizationRegistry
        Specified by:
        setRollbackOnly in interface javax.transaction.UserTransaction
        Throws:
        java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
      • commit

        public void commit()
                    throws javax.transaction.HeuristicMixedException,
                           javax.transaction.HeuristicRollbackException,
                           java.lang.IllegalStateException,
                           javax.transaction.RollbackException,
                           java.lang.SecurityException,
                           javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Complete the transaction associated with the current thread. When this method completes, the thread is no longer associated with a transaction.
        Specified by:
        commit in interface javax.transaction.TransactionManager
        Specified by:
        commit in interface javax.transaction.UserTransaction
        Throws:
        javax.transaction.HeuristicMixedException - Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.
        javax.transaction.HeuristicRollbackException - Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.
        java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
        javax.transaction.RollbackException - Thrown to indicate that the transaction has been rolled back rather than committed.
        java.lang.SecurityException - Thrown to indicate that the thread is not allowed to commit the transaction.
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • rollback

        public void rollback()
                      throws java.lang.IllegalStateException,
                             java.lang.SecurityException,
                             javax.transaction.SystemException
        Description copied from interface: javax.transaction.TransactionManager
        Roll back the transaction associated with the current thread. When this method completes, the thread is no longer associated with a transaction.
        Specified by:
        rollback in interface javax.transaction.TransactionManager
        Specified by:
        rollback in interface javax.transaction.UserTransaction
        Throws:
        java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
        java.lang.SecurityException - Thrown to indicate that the thread is not allowed to roll back the transaction.
        javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • importXid

        public javax.transaction.Transaction importXid​(javax.transaction.xa.Xid xid,
                                                       long transactionTimeoutMilliseconds)
                                                throws javax.transaction.xa.XAException,
                                                       javax.transaction.SystemException
        Specified by:
        importXid in interface XidImporter
        Throws:
        javax.transaction.xa.XAException
        javax.transaction.SystemException
      • commit

        public void commit​(javax.transaction.Transaction tx,
                           boolean onePhase)
                    throws javax.transaction.xa.XAException
        Specified by:
        commit in interface XidImporter
        Throws:
        javax.transaction.xa.XAException
      • forget

        public void forget​(javax.transaction.Transaction tx)
                    throws javax.transaction.xa.XAException
        Specified by:
        forget in interface XidImporter
        Throws:
        javax.transaction.xa.XAException
      • prepare

        public int prepare​(javax.transaction.Transaction tx)
                    throws javax.transaction.xa.XAException
        Specified by:
        prepare in interface XidImporter
        Throws:
        javax.transaction.xa.XAException
      • rollback

        public void rollback​(javax.transaction.Transaction tx)
                      throws javax.transaction.xa.XAException
        Specified by:
        rollback in interface XidImporter
        Throws:
        javax.transaction.xa.XAException
      • getActiveCount

        public long getActiveCount()
        Returns the number of active transactions.
        Returns:
        the count of active transactions
      • getTotalCommits

        public long getTotalCommits()
        Return the number of total commits
        Returns:
        the number of commits since statistics were reset
      • getTotalRollbacks

        public long getTotalRollbacks()
        Returns the number of total rollbacks
        Returns:
        the number of rollbacks since statistics were reset
      • resetStatistics

        public void resetStatistics()
        Reset statistics