org.apache.lenya.transaction
Interface UnitOfWork

All Known Subinterfaces:
Session, SharedItemStore
All Known Implementing Classes:
SessionImpl, UnitOfWorkImpl

public interface UnitOfWork

This is a "Unit of Work" object (see "Unit of Work" pattern by Martin Fowler, http://www.martinfowler.com/eaaCatalog/unitOfWork.html : the unit of work "maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems".

In the current design, this interface allows a use case to generate documents, while ensuring that only one instance of a document is created. This access is provided by the DocumentIdentityMap's DocumentFactory.

This interface may be extended in the future to allow for access to further types of business objects.

Version:
$Id: UnitOfWork.java 534530 2007-05-02 16:24:22Z andreas $

Method Summary
 void commit()
          Commits the transaction.
 Lock createLock(Lockable lockable, int version)
          Creates a lock.
 boolean isDirty(Transactionable transactionable)
           
 void registerDirty(Transactionable object)
          Registers an object as modified.
 void registerNew(Transactionable object)
          Registers an object as new.
 void registerRemoved(Transactionable object)
          Registers an object as removed.
 void removeLock(Lockable lockable)
          Removes a lock.
 void rollback()
          Rolls the transaction back.
 

Method Detail

registerNew

void registerNew(Transactionable object)
                 throws TransactionException
Registers an object as new.

Parameters:
object - The object.
Throws:
TransactionException - if an error occurs.

registerDirty

void registerDirty(Transactionable object)
                   throws TransactionException
Registers an object as modified.

Parameters:
object - The object.
Throws:
TransactionException - if an error occurs.

registerRemoved

void registerRemoved(Transactionable object)
                     throws TransactionException
Registers an object as removed.

Parameters:
object - The object.
Throws:
TransactionException - if an error occurs.

commit

void commit()
            throws TransactionException
Commits the transaction.

Throws:
TransactionException - if an error occurs.

rollback

void rollback()
              throws TransactionException
Rolls the transaction back.

Throws:
TransactionException - if an error occurs.

isDirty

boolean isDirty(Transactionable transactionable)
Parameters:
transactionable - A transactionable.
Returns:
If the transactionable is registered as dirty.

createLock

Lock createLock(Lockable lockable,
                int version)
                throws TransactionException
Creates a lock.

Parameters:
lockable - The lockable.
version - The version.
Returns:
A lock.
Throws:
TransactionException - if a lock is already placed on this transactionable.

removeLock

void removeLock(Lockable lockable)
                throws TransactionException
Removes a lock.

Parameters:
lockable - The lockable.
Throws:
TransactionException - if no lock is placed on this transactionable.


Copyright © 1999-2006 Apache Software Foundation. All Rights Reserved.