SRJRCFrames
v0.1.296

de.schwarzrot.data.transaction
Interface Transaction

All Known Implementing Classes:
ApplicationTransaction

public interface Transaction

A transaction with an interface similar to Transaction, but with slightly different approach. This Transaction is like a cake-recipe, so you can add arbitrary TransactionalOperations. As creating a cake-recipe doesn't produce anything eatable, creating a Transaction does not perform any of its operations.

Use execute to perform all steps of the Transaction. The Transaction passes control to Repository on execution and as Repository uses EntityManagers for persistence tasks, enlisting and delisting of TransactionResources happens during transaction execution. Application does not need to care about TransactionResources.

Transaction implementation should add support for VetoableChangeListener on the TransactionStatus. The listener may throw different types of veto:

Author:
Reinhard Mantey
See Also:
TryAgainTransactionException, AbortTransactionException

Method Summary
 void add(TransactionalOperation<?> tao)
          used to add an operation to the transaction.
 void addVetoableStatusListener(VetoableChangeListener listener)
          add vetoable change listener to the transaction.
 void execute()
          executes all added operations
 TransactionalOperation.DataDirection getDataDirection()
          internal use only.
 List<TransactionalOperation<?>> getOperations()
          internal use only.
 TransactionResource<?> getResource(EntityManager em)
          internal use only.
 TransactionStatus getStatus()
          accessor to the transactions status
 boolean isEntityManagerRegistered(EntityManager em)
          internal use only.
 boolean isRollbackOnly()
          internal use only.
 Collection<EntityManager> registeredManagers()
          internal use only.
 void registerResource(EntityManager em, TransactionResource<?> resource)
          internal use only.
 void setRollbackOnly()
          use this, if the transaction does only read operations.
 void setStatus(TransactionStatus ts)
          internal use only.
 

Method Detail

add

void add(TransactionalOperation<?> tao)
used to add an operation to the transaction.

Parameters:
tao - the operation to add to the transaction

addVetoableStatusListener

void addVetoableStatusListener(VetoableChangeListener listener)
add vetoable change listener to the transaction. TransationStatus is the property guarded by the change listeners, so a listener can throw its veto on each status change. Any veto will result in a rollback of the transaction.

Parameters:
listener - - the listener to add

execute

void execute()
executes all added operations


getDataDirection

TransactionalOperation.DataDirection getDataDirection()
internal use only.. Is used by the EntityManager to open the TransactionResource in an appropriate way.


getOperations

List<TransactionalOperation<?>> getOperations()
internal use only.. Is used by the Repository

Returns:
the defined operations

getResource

TransactionResource<?> getResource(EntityManager em)
internal use only.. Is used by the Repository

Parameters:
em - the EntityManager, that created that resource
Returns:
the registered TransactionResource

getStatus

TransactionStatus getStatus()
accessor to the transactions status

Returns:
the status of the transaction

isEntityManagerRegistered

boolean isEntityManagerRegistered(EntityManager em)
internal use only.. Is used by the Repository

Parameters:
em - the EntityManager of interest
Returns:
true, if the EntityManager has been used in a previous operation, otherwise false

isRollbackOnly

boolean isRollbackOnly()
internal use only.. Is used by the Repository

Returns:
whether this transaction has been marked for rollback

registeredManagers

Collection<EntityManager> registeredManagers()
internal use only.. Is used by the Repository

Returns:
all registered EntityManagers

registerResource

void registerResource(EntityManager em,
                      TransactionResource<?> resource)
internal use only.. Is used by the Repository

Parameters:
em - the EntityManager, that created the TransactionResource
resource - the created TransactionResource

setRollbackOnly

void setRollbackOnly()
use this, if the transaction does only read operations. May save some resources, depending on the bound Entity


setStatus

void setStatus(TransactionStatus ts)
               throws PropertyVetoException
internal use only.. Is used by the Repository

Parameters:
ts - the new status
Throws:
PropertyVetoException

SRJRCFrames
v0.1.296

hosted at
Find SRJRCFrames at SourceForge.net. Fast, secure and free:
           Open Source Software download
Submit a bug or request a feature

SRJRCFrames is published according to the GNU General Public License
Copyright 2005-2012 Reinhard Mantey - some rights reserved.