org.qi4j.api.unitofwork
Interface UnitOfWorkFactory

All Known Subinterfaces:
Module

public interface UnitOfWorkFactory

Factory for UnitOfWork.


Method Summary
 UnitOfWork currentUnitOfWork()
          Returns the UnitOfWork that is currently associated with the executing thread.
 UnitOfWork getUnitOfWork(EntityComposite entity)
          Returns the UnitOfWork that the EntityComposite is bound to.
 boolean isUnitOfWorkActive()
           
 UnitOfWork newUnitOfWork()
          Create a new UnitOfWork and associate it with the current thread.
 UnitOfWork newUnitOfWork(long currentTime)
          Create a new UnitOfWork and associate it with the current thread.
 UnitOfWork newUnitOfWork(Usecase usecase)
          Create a new UnitOfWork for the given Usecase and associate it with the current thread.
 UnitOfWork newUnitOfWork(Usecase usecase, long currentTime)
          Create a new UnitOfWork for the given Usecase and associate it with the current thread.
 

Method Detail

newUnitOfWork

UnitOfWork newUnitOfWork()
Create a new UnitOfWork and associate it with the current thread.

The UnitOfWork will use the default Usecase settings.

Current time will be set to System.currentTimeMillis();

Returns:
a new UnitOfWork

newUnitOfWork

UnitOfWork newUnitOfWork(long currentTime)
Create a new UnitOfWork and associate it with the current thread.

The UnitOfWork will use the default Usecase settings.

Returns:
a new UnitOfWork

newUnitOfWork

UnitOfWork newUnitOfWork(Usecase usecase)
Create a new UnitOfWork for the given Usecase and associate it with the current thread.

Current time will be set to System.currentTimeMillis();

Parameters:
usecase - the Usecase for this UnitOfWork
Returns:
a new UnitOfWork

newUnitOfWork

UnitOfWork newUnitOfWork(Usecase usecase,
                         long currentTime)
Create a new UnitOfWork for the given Usecase and associate it with the current thread.

Parameters:
usecase - the Usecase for this UnitOfWork
Returns:
a new UnitOfWork

isUnitOfWorkActive

boolean isUnitOfWorkActive()
Returns:
true if there is an active UnitOfWork associated with the executing thread

currentUnitOfWork

UnitOfWork currentUnitOfWork()
                             throws java.lang.IllegalStateException
Returns the UnitOfWork that is currently associated with the executing thread.

Returns:
The current UnitOfWork associated with the executing thread
Throws:
java.lang.IllegalStateException - if no current UnitOfWork is active

getUnitOfWork

UnitOfWork getUnitOfWork(EntityComposite entity)
Returns the UnitOfWork that the EntityComposite is bound to.

Parameters:
entity - the entity to be checked.
Returns:
The UnitOfWork instance that the Entity is bound to, or null if the entity is not associated with any UnitOfWork.