org.apache.openejb.core.transaction
Class JtaTransactionPolicy

java.lang.Object
  extended by org.apache.openejb.core.transaction.JtaTransactionPolicy
All Implemented Interfaces:
TransactionPolicy
Direct Known Subclasses:
TxBeanManaged, TxMandatory, TxNever, TxNotSupported, TxRequired, TxRequiresNew, TxSupports

public abstract class JtaTransactionPolicy
extends Object
implements TransactionPolicy


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.openejb.core.transaction.TransactionPolicy
TransactionPolicy.TransactionSynchronization
 
Field Summary
protected static Logger logger
           
protected  TransactionManager transactionManager
           
protected  TransactionType transactionType
           
protected static Logger txLogger
           
 
Constructor Summary
JtaTransactionPolicy(TransactionType transactionType, TransactionManager transactionManager)
           
 
Method Summary
protected  Transaction beginTransaction()
           
protected  void completeTransaction(Transaction tx)
           
 void enlistResource(XAResource xaResource)
          Enlists a XAResource in the actual active transaction.
protected  void fireNonTransactionalCompletion()
           
abstract  Transaction getCurrentTransaction()
           
 Object getResource(Object key)
          Gets a resource associated with the specified key.
protected  Transaction getTransaction()
           
 TransactionType getTransactionType()
          Gets the TransactionType for this policy.
 boolean isRollbackOnly()
          If true, this TransactionPolicy will ultimately end with rollback.
 boolean isTransactionActive()
          Is there a actual transaction active?
 void putResource(Object key, Object value)
          Associates the specified resource with the specified key.
 void registerSynchronization(TransactionPolicy.TransactionSynchronization synchronization)
          Registers a listener for transaction synchronization events.
 Object removeResource(Object key)
          Removes and returns the resource associated with the specified key.
protected  void resumeTransaction(Transaction tx)
           
protected  void rollbackTransaction(Transaction tx)
           
 void setRollbackOnly()
          Sets this TransactionPolicy to rollback when completed
protected  void setRollbackOnly(Transaction tx)
           
protected  Transaction suspendTransaction()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.openejb.core.transaction.TransactionPolicy
commit, isClientTransaction, isNewTransaction
 

Field Detail

logger

protected static final Logger logger

txLogger

protected static final Logger txLogger

transactionType

protected final TransactionType transactionType

transactionManager

protected final TransactionManager transactionManager
Constructor Detail

JtaTransactionPolicy

public JtaTransactionPolicy(TransactionType transactionType,
                            TransactionManager transactionManager)
Method Detail

getTransactionType

public TransactionType getTransactionType()
Description copied from interface: TransactionPolicy
Gets the TransactionType for this policy.

Specified by:
getTransactionType in interface TransactionPolicy
Returns:
the TransactionType for this policy

getCurrentTransaction

public abstract Transaction getCurrentTransaction()

isTransactionActive

public boolean isTransactionActive()
Description copied from interface: TransactionPolicy
Is there a actual transaction active?

Specified by:
isTransactionActive in interface TransactionPolicy
Returns:
true if there is an actual transaction active

isRollbackOnly

public boolean isRollbackOnly()
Description copied from interface: TransactionPolicy
If true, this TransactionPolicy will ultimately end with rollback.

Specified by:
isRollbackOnly in interface TransactionPolicy
Returns:
true if this TransactionPolicy will ultimately end with rollback

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: TransactionPolicy
Sets this TransactionPolicy to rollback when completed

Specified by:
setRollbackOnly in interface TransactionPolicy

getResource

public Object getResource(Object key)
Description copied from interface: TransactionPolicy
Gets a resource associated with the specified key. If there is an actual transaction active, the resource associated with the transaction is returned; otherwise the resource is scoped to this TransactionPolicy.

Specified by:
getResource in interface TransactionPolicy
Parameters:
key - the resource key
Returns:
the resource or null if no resource was associated with the key

putResource

public void putResource(Object key,
                        Object value)
Description copied from interface: TransactionPolicy
Associates the specified resource with the specified key. If there is an actual transaction active, the resource associated with the transaction is set; otherwise the resource is scoped to this TransactionPolicy.

Specified by:
putResource in interface TransactionPolicy
Parameters:
key - the resource key
value - the resource

removeResource

public Object removeResource(Object key)
Description copied from interface: TransactionPolicy
Removes and returns the resource associated with the specified key. If there is an actual transaction active, the resource associated with the transaction is returned; otherwise the resource is scoped to this TransactionPolicy.

Specified by:
removeResource in interface TransactionPolicy
Parameters:
key - the resource key
Returns:
the resource previously associated with the key

registerSynchronization

public void registerSynchronization(TransactionPolicy.TransactionSynchronization synchronization)
Description copied from interface: TransactionPolicy
Registers a listener for transaction synchronization events. If there is an actual transaction active, the events are fired when the acutal transaction is commited; otherwise the events are fired when this TransactionPolicy completes.

Specified by:
registerSynchronization in interface TransactionPolicy
Parameters:
synchronization - the transaction synchronization listener

fireNonTransactionalCompletion

protected void fireNonTransactionalCompletion()

enlistResource

public void enlistResource(XAResource xaResource)
                    throws SystemException
Description copied from interface: TransactionPolicy
Enlists a XAResource in the actual active transaction. This only works if the TransactionPolicy is associated with an actual transaction and the TransactionPolicy supports XAResouce enlistment.

Specified by:
enlistResource in interface TransactionPolicy
Parameters:
xaResource - the XAResource to enlist
Throws:
SystemException - if the xaResource could not be enlisted in the transaction

toString

public String toString()
Overrides:
toString in class Object

getTransaction

protected Transaction getTransaction()
                              throws SystemException
Throws:
SystemException

setRollbackOnly

protected void setRollbackOnly(Transaction tx)

beginTransaction

protected Transaction beginTransaction()
                                throws SystemException
Throws:
SystemException

suspendTransaction

protected Transaction suspendTransaction()
                                  throws SystemException
Throws:
SystemException

resumeTransaction

protected void resumeTransaction(Transaction tx)
                          throws SystemException
Throws:
SystemException

completeTransaction

protected void completeTransaction(Transaction tx)
                            throws SystemException,
                                   ApplicationException
Throws:
SystemException
ApplicationException

rollbackTransaction

protected void rollbackTransaction(Transaction tx)
                            throws SystemException
Throws:
SystemException


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