org.apache.openejb.spring
Class SpringTransactionPolicy

java.lang.Object
  extended by org.apache.openejb.spring.SpringTransactionPolicy
All Implemented Interfaces:
TransactionPolicy
Direct Known Subclasses:
SpringBeanTransactionPolicy

public class SpringTransactionPolicy
extends Object
implements TransactionPolicy


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.openejb.core.transaction.TransactionPolicy
TransactionPolicy.TransactionSynchronization
 
Field Summary
protected  org.springframework.transaction.PlatformTransactionManager transactionManager
           
protected  TransactionType type
           
 
Constructor Summary
SpringTransactionPolicy(org.springframework.transaction.PlatformTransactionManager transactionManager, TransactionType type)
           
 
Method Summary
 void commit()
          Commits or rolls back this TransactionPolicy.
 void enlistResource(XAResource xaResource)
          Enlists a XAResource in the actual active transaction.
 Object getResource(Object key)
          Gets a resource associated with the specified key.
protected  org.springframework.transaction.support.DefaultTransactionStatus getTransactionStatus()
           
 TransactionType getTransactionType()
          Gets the TransactionType for this policy.
 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.
 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.
 void setRollbackOnly()
          Sets this TransactionPolicy to rollback when completed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionManager

protected final org.springframework.transaction.PlatformTransactionManager transactionManager

type

protected final TransactionType type
Constructor Detail

SpringTransactionPolicy

public SpringTransactionPolicy(org.springframework.transaction.PlatformTransactionManager transactionManager,
                               TransactionType type)
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

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

Specified by:
isNewTransaction in interface TransactionPolicy
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.

Specified by:
isClientTransaction in interface TransactionPolicy
Returns:
true if this is an inherited transaction

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

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.

Specified by:
commit in interface TransactionPolicy
Throws:
ApplicationException - if recoverable exception is encountered
SystemException - if an unrecoverable exception is encountered

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

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

getTransactionStatus

protected org.springframework.transaction.support.DefaultTransactionStatus getTransactionStatus()


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