SRJRCFrames
v0.1.296

de.schwarzrot.data.transaction
Class ApplicationTransaction

java.lang.Object
  extended by de.schwarzrot.data.transaction.ApplicationTransaction
All Implemented Interfaces:
Transaction

public class ApplicationTransaction
extends Object
implements Transaction

An ApplicationTransaction is a wrapper around TransactionalOperations, which can be added to setup a transaction. The transaction is then executed by the Repository and so the transaction may span different persistent resources, but the application does not need to care about those resources nor does it need to know, which resource is involved.

The application only adds an Entity or several entities together with the opcode, which should be applied to that entities.

So, the enlisting/delisting of resources is internal to the transaction processor, which in this case is the Repository.

This transaction implements a VetoableChangeSupport for changes of the transaction status. These status values are vetoable:

Any veto on other status changes is silently ignored.

Author:
Reinhard Mantey

Constructor Summary
ApplicationTransaction()
           
 
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<?> res)
          internal use only.
 void setRollbackOnly()
          use this, if the transaction does only read operations.
 void setStatus(TransactionStatus ts)
          internal use only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationTransaction

public ApplicationTransaction()
Method Detail

add

public void add(TransactionalOperation<?> tao)
Description copied from interface: Transaction
used to add an operation to the transaction.

Specified by:
add in interface Transaction
Parameters:
tao - the operation to add to the transaction

addVetoableStatusListener

public void addVetoableStatusListener(VetoableChangeListener listener)
Description copied from interface: Transaction
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.

Specified by:
addVetoableStatusListener in interface Transaction
Parameters:
listener - - the listener to add

execute

public void execute()
Description copied from interface: Transaction
executes all added operations

Specified by:
execute in interface Transaction

getDataDirection

public TransactionalOperation.DataDirection getDataDirection()
Description copied from interface: Transaction
internal use only.. Is used by the EntityManager to open the TransactionResource in an appropriate way.

Specified by:
getDataDirection in interface Transaction

getOperations

public List<TransactionalOperation<?>> getOperations()
Description copied from interface: Transaction
internal use only.. Is used by the Repository

Specified by:
getOperations in interface Transaction
Returns:
the defined operations

getResource

public TransactionResource<?> getResource(EntityManager em)
Description copied from interface: Transaction
internal use only.. Is used by the Repository

Specified by:
getResource in interface Transaction
Parameters:
em - the EntityManager, that created that resource
Returns:
the registered TransactionResource

getStatus

public TransactionStatus getStatus()
Description copied from interface: Transaction
accessor to the transactions status

Specified by:
getStatus in interface Transaction
Returns:
the status of the transaction

isEntityManagerRegistered

public boolean isEntityManagerRegistered(EntityManager em)
Description copied from interface: Transaction
internal use only.. Is used by the Repository

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

isRollbackOnly

public boolean isRollbackOnly()
Description copied from interface: Transaction
internal use only.. Is used by the Repository

Specified by:
isRollbackOnly in interface Transaction
Returns:
whether this transaction has been marked for rollback

registeredManagers

public Collection<EntityManager> registeredManagers()
Description copied from interface: Transaction
internal use only.. Is used by the Repository

Specified by:
registeredManagers in interface Transaction
Returns:
all registered EntityManagers

registerResource

public void registerResource(EntityManager em,
                             TransactionResource<?> res)
Description copied from interface: Transaction
internal use only.. Is used by the Repository

Specified by:
registerResource in interface Transaction
Parameters:
em - the EntityManager, that created the TransactionResource
res - the created TransactionResource

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: Transaction
use this, if the transaction does only read operations. May save some resources, depending on the bound Entity

Specified by:
setRollbackOnly in interface Transaction

setStatus

public void setStatus(TransactionStatus ts)
               throws PropertyVetoException
Description copied from interface: Transaction
internal use only.. Is used by the Repository

Specified by:
setStatus in interface Transaction
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.