bitronix.tm
Class BitronixTransactionManager

java.lang.Object
  extended bybitronix.tm.BitronixTransactionManager
All Implemented Interfaces:
javax.naming.Referenceable, Service, javax.transaction.TransactionManager, javax.transaction.UserTransaction

public class BitronixTransactionManager
extends java.lang.Object
implements javax.transaction.TransactionManager, javax.transaction.UserTransaction, javax.naming.Referenceable, Service

Implementation of TransactionManager and UserTransaction.

© Bitronix Software

Author:
lorban

Constructor Summary
BitronixTransactionManager()
          Create the BitronixTransactionManager.
 
Method Summary
 void begin()
          Start a new transaction and bind the context to the calling thread.
 void commit()
           
 void dumpTransactionContexts()
          Dump an overview of all running transactions as debug logs.
 BitronixTransaction getCurrentTransaction()
          Get the transaction currently registered on the current thread context.
 java.util.Map getInFlightTransactions()
          Return all in-flight transactions.
 long getOldestInFlightTransactionTimestamp()
          Return the timestamp of the oldest in-flight transaction.
 javax.naming.Reference getReference()
          BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference with no special information to find back the sole instance.
 int getStatus()
           
 javax.transaction.Transaction getTransaction()
           
 void resume(javax.transaction.Transaction transaction)
           
 void rollback()
           
 void setRollbackOnly()
           
 void setTransactionTimeout(int seconds)
           
 void shutdown()
          Shut down the transaction manager and release all resources held by it.
 javax.transaction.Transaction suspend()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixTransactionManager

public BitronixTransactionManager()
Create the BitronixTransactionManager. Open the journal, load resources and perform recovery synchronously. The recovery service then gets scheduled for background recovery.

Method Detail

begin

public void begin()
           throws javax.transaction.NotSupportedException,
                  javax.transaction.SystemException
Start a new transaction and bind the context to the calling thread.

Specified by:
begin in interface javax.transaction.TransactionManager
Throws:
javax.transaction.NotSupportedException - if a transaction is already bound to the calling thread.
javax.transaction.SystemException - if the transaction manager is shutting down.

commit

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

rollback

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

getStatus

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

getTransaction

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

setRollbackOnly

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

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws javax.transaction.SystemException
Specified by:
setTransactionTimeout in interface javax.transaction.TransactionManager
Throws:
javax.transaction.SystemException

suspend

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

resume

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

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference with no special information to find back the sole instance. BitronixTransactionManagerObjectFactory will be used by the JNDI server to get the BitronixTransactionManager instance of the JVM.

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
an empty reference to get the BitronixTransactionManager.
Throws:
javax.naming.NamingException

getInFlightTransactions

public java.util.Map getInFlightTransactions()
Return all in-flight transactions.

Returns:
a map of BitronixTransaction objects using Uid as key and BitronixTransaction as value.

getOldestInFlightTransactionTimestamp

public long getOldestInFlightTransactionTimestamp()
Return the timestamp of the oldest in-flight transaction.

Returns:
the timestamp or Long.MIN_VALUE if there is no in-flight transaction.

getCurrentTransaction

public BitronixTransaction getCurrentTransaction()
Get the transaction currently registered on the current thread context.

Returns:
the current transaction or null if no transaction has been started on the current thread.

dumpTransactionContexts

public void dumpTransactionContexts()
Dump an overview of all running transactions as debug logs.


shutdown

public void shutdown()
Shut down the transaction manager and release all resources held by it.

This call will also close the resources pools registered by the ResourceLoader like JMS and JDBC pools. The manually created ones are left untouched.

The Transaction Manager will wait during a configurable graceful period before forcibly killing active transactions.

After this method is called, attempts to create new transactions (via calls to TransactionManager.begin()) will be rejected with a SystemException.

Specified by:
shutdown in interface Service
See Also:
Configuration.getGracefulShutdownInterval()

toString

public java.lang.String toString()