## org.jboss.tm
Class TxManager

    java.lang.Object
      |
      +--org.jboss.tm.TxManager

All Implemented Interfaces:
  javax.transaction.TransactionManager, TransactionPropagationContextFactory, TransactionPropagationContextImporter

public class TxManager
extends java.lang.Object
implements javax.transaction.TransactionManager, TransactionPropagationContextImporter, TransactionPropagationContextFactory

Our TransactionManager implementation.

Version:
  $Revision: 1.28.4.3 $
Author:
  Rickard Öberg (rickard.oberg@telkel.com), Marc Fleury, Ole Husgaard
See Also:
  <related>

Method Summary
`void` `associateThread(javax.transaction.Transaction transaction)`
`void` `begin()` Begin a new transaction.
`void` `commit()` Commit the transaction associated with the currently running thread.
`javax.transaction.Transaction` `disassociateThread()`
`int` `getDefaultTransactionTimeout()` Get the default transaction timeout.
`static TxManager` `getInstance()` Get a reference to the singleton instance.
`long` `getNumSuspendedTransactions()` Number of suspended transactions
`long` `getNumTransactions()` Number of transactions in progress
`int` `getStatus()` Return the status of the transaction associated with the currently running thread, or `Status.STATUS_NO_TRANSACTION` if no active transaction is currently associated.
`javax.transaction.Transaction` `getTransaction()` Return the transaction currently associated with the invoking thread, or `null` if no active transaction is currently associated.
`java.lang.Object` `getTransactionPropagationContext()` Return a TPC for the current transaction.
`java.lang.Object` `getTransactionPropagationContext(javax.transaction.Transaction tx)` Return a TPC for the argument transaction.
`javax.transaction.Transaction` `importTransactionPropagationContext(java.lang.Object tpc)` Import a transaction propagation context into this TM.
`void` `resume(javax.transaction.Transaction transaction)` Resume a transaction.
`void` `rollback()` Roll back the transaction associated with the currently running thread.
`void` `setDefaultTransactionTimeout(int seconds)` Set the default transaction timeout for new transactions.
`void` `setRollbackOnly()` Mark the transaction associated with the currently running thread so that the only possible outcome is a rollback.
`void` `setTransactionTimeout(int seconds)` Set the transaction timeout for new transactions started by the calling thread.
`javax.transaction.Transaction` `suspend()` Suspend the transaction currently associated with the current thread, and return it.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getNumTransactions

    public long getNumTransactions()

  Number of transactions in progress

### getNumSuspendedTransactions

    public long getNumSuspendedTransactions()

  Number of suspended transactions

### getInstance

    public static TxManager getInstance()

  Get a reference to the singleton instance.

### begin

    public void begin()
               throws javax.transaction.NotSupportedException,
                      javax.transaction.SystemException

  Begin a new transaction. The new transaction will be associated with the calling thread.
  Specified by:
    `begin` in interface `javax.transaction.TransactionManager`

### commit

    public void commit()
                throws javax.transaction.RollbackException,
                       javax.transaction.HeuristicMixedException,
                       javax.transaction.HeuristicRollbackException,
                       java.lang.SecurityException,
                       java.lang.IllegalStateException,
                       javax.transaction.SystemException

  Commit the transaction associated with the currently running thread.
  Specified by:
    `commit` in interface `javax.transaction.TransactionManager`

### getStatus

    public int getStatus()
                  throws javax.transaction.SystemException

  Return the status of the transaction associated with the currently running thread, or `Status.STATUS_NO_TRANSACTION` if no active transaction is currently associated.
  Specified by:
    `getStatus` in interface `javax.transaction.TransactionManager`

### getTransaction

    public javax.transaction.Transaction getTransaction()
                                                 throws javax.transaction.SystemException

  Return the transaction currently associated with the invoking thread, or `null` if no active transaction is currently associated.
  Specified by:
    `getTransaction` in interface `javax.transaction.TransactionManager`

### resume

    public void resume(javax.transaction.Transaction transaction)
                throws javax.transaction.InvalidTransactionException,
                       java.lang.IllegalStateException,
                       javax.transaction.SystemException

  Resume a transaction. Note: This will not enlist any resources involved in this transaction. According to JTA1.0.1 specification section 3.2.3, that is the responsibility of the application server.
  Specified by:
    `resume` in interface `javax.transaction.TransactionManager`

### suspend

    public javax.transaction.Transaction suspend()
                                          throws javax.transaction.SystemException

  Suspend the transaction currently associated with the current thread, and return it. Note: This will not delist any resources involved in this transaction. According to JTA1.0.1 specification section 3.2.3, that is the responsibility of the application server.
  Specified by:
    `suspend` in interface `javax.transaction.TransactionManager`

### rollback

    public void rollback()
                  throws java.lang.IllegalStateException,
                         java.lang.SecurityException,
                         javax.transaction.SystemException

  Roll back the transaction associated with the currently running thread.
  Specified by:
    `rollback` in interface `javax.transaction.TransactionManager`

### setRollbackOnly

    public void setRollbackOnly()
                         throws java.lang.IllegalStateException,
                                javax.transaction.SystemException

  Mark the transaction associated with the currently running thread so that the only possible outcome is a rollback.
  Specified by:
    `setRollbackOnly` in interface `javax.transaction.TransactionManager`

### setTransactionTimeout

    public void setTransactionTimeout(int seconds)
                               throws javax.transaction.SystemException

  Set the transaction timeout for new transactions started by the calling thread.
  Specified by:
    `setTransactionTimeout` in interface `javax.transaction.TransactionManager`

### setDefaultTransactionTimeout

    public void setDefaultTransactionTimeout(int seconds)

  Set the default transaction timeout for new transactions. This default value is used if `setTransactionTimeout()` was never called, or if it was called with a value of `0`.

### getDefaultTransactionTimeout

    public int getDefaultTransactionTimeout()

  Get the default transaction timeout.
  Returns:
    Default transaction timeout in seconds.

### disassociateThread

    public javax.transaction.Transaction disassociateThread()

### associateThread

    public void associateThread(javax.transaction.Transaction transaction)

### importTransactionPropagationContext

    public javax.transaction.Transaction importTransactionPropagationContext(java.lang.Object tpc)

  Import a transaction propagation context into this TM. The TPC is loosely typed, as we may (at a later time) want to import TPCs that come from other transaction domains without offloading the conversion to the client.
  Specified by:
    `importTransactionPropagationContext` in interface `TransactionPropagationContextImporter`
  Parameters:
    `tpc` - The transaction propagation context that we want to import into this TM. Currently this is an instance of GlobalId. At some later time this may be an instance of a transaction propagation context from another transaction domain like org.omg.CosTransactions.PropagationContext.
  Returns:
    A transaction representing this transaction propagation context, or null if this TPC cannot be imported.

### getTransactionPropagationContext

    public java.lang.Object getTransactionPropagationContext()

  Return a TPC for the current transaction.
  Specified by:
    `getTransactionPropagationContext` in interface `TransactionPropagationContextFactory`

### getTransactionPropagationContext

    public java.lang.Object getTransactionPropagationContext(javax.transaction.Transaction tx)

  Return a TPC for the argument transaction.
  Specified by:
    `getTransactionPropagationContext` in interface `TransactionPropagationContextFactory`

Copyright © 2000 The JBoss Organization. All Rights Reserved.