org.apache.openejb.core.transaction
Class TxRequired

java.lang.Object
  extended by org.apache.openejb.core.transaction.JtaTransactionPolicy
      extended by org.apache.openejb.core.transaction.TxRequired
All Implemented Interfaces:
TransactionPolicy

public class TxRequired
extends JtaTransactionPolicy

17.6.2.2 Required

The Container must invoke an enterprise Bean method whose transaction attribute is set to Required with a valid transaction context.

If a client invokes the enterprise Bean's method while the client is associated with a transaction context, the container invokes the enterprise Bean's method in the client's transaction context.

If the client invokes the enterprise Bean's method while the client is not associated with a transaction context, the container automatically starts a new transaction before delegating a method call to the enterprise Bean business method. The Container automatically enlists all the resource managers accessed by the business method with the transaction. If the business method invokes other enterprise beans, the Container passes the transaction context with the invocation. The Container attempts to commit the transaction when the business method has completed. The container performs the commit protocol before the method result is sent to the client.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.openejb.core.transaction.TransactionPolicy
TransactionPolicy.TransactionSynchronization
 
Field Summary
 
Fields inherited from class org.apache.openejb.core.transaction.JtaTransactionPolicy
logger, transactionManager, transactionType, txLogger
 
Constructor Summary
TxRequired(javax.transaction.TransactionManager transactionManager)
           
 
Method Summary
 void commit()
          Commits or rolls back this TransactionPolicy.
 javax.transaction.Transaction getCurrentTransaction()
           
 boolean isClientTransaction()
          Is this policy running in an inhreited transaction? Some TransactionTypes, such as Required or Supported, use the caller's transaction instead of starting a new transaction.
 boolean isNewTransaction()
          Is this a new transaction and not an inhreited transaction or no transaction? Some TransactionTypes, such as Required or Supported, use the caller's transaction instead of starting a new transaction.
 
Methods inherited from class org.apache.openejb.core.transaction.JtaTransactionPolicy
beginTransaction, completeTransaction, enlistResource, fireNonTransactionalCompletion, getResource, getTransaction, getTransactionType, isRollbackOnly, isTransactionActive, putResource, registerSynchronization, removeResource, resumeTransaction, rollbackTransaction, setRollbackOnly, setRollbackOnly, suspendTransaction, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TxRequired

public TxRequired(javax.transaction.TransactionManager transactionManager)
           throws SystemException
Throws:
SystemException
Method Detail

isNewTransaction

public boolean isNewTransaction()
Description copied from interface: TransactionPolicy
Is this a new transaction and not an inhreited transaction or no transaction? Some TransactionTypes, such as Required or Supported, use the caller's transaction instead of starting a new transaction. If there is no active transaction (e.g., TransactionType is NotSupported), this method will

Returns:
true if this not an inherited transaction

isClientTransaction

public boolean isClientTransaction()
Description copied from interface: TransactionPolicy
Is this policy running in an inhreited transaction? Some TransactionTypes, such as Required or Supported, use the caller's transaction instead of starting a new transaction. If there is no active transaction (e.g., TransactionType is NotSupported), this method will return false.

Returns:
true if this is an inherited transaction

getCurrentTransaction

public javax.transaction.Transaction getCurrentTransaction()
Specified by:
getCurrentTransaction in class JtaTransactionPolicy

commit

public void commit()
            throws ApplicationException,
                   SystemException
Description copied from interface: TransactionPolicy
Commits or rolls back this TransactionPolicy. If there the actual transaction is completed or there is no actual transaction, the registered TransactionSynchronization are called. Otherwise, the registered TransactionSynchronization are called when the actual transaction is completed.

Throws:
ApplicationException - if recoverable exception is encountered
SystemException - if an unrecoverable exception is encountered


Copyright © 1999-2011 The Apache OpenEJB development community. All Rights Reserved.