|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface UnitOfWork
All operations on entities goes through an UnitOfWork.
A UnitOfWork allows you to access Entities and work with them. All modifications to Entities are recorded by the UnitOfWork, and at the end they may be sent to the underlying EntityStore by calling complete(). If the UoW was read-only you may instead simply discard() it.
A UoW differs from a traditional Transaction in the sense that it is not tied at all to the underlying storage resource. Because of this there is no timeout on a UoW. It can be very short or very long. Another difference is that if a call to complete() fails, and the cause is validation errors in the Entities of the UoW, then these can be corrected and the UoW retried. By contrast, when a Transaction commit fails, then the whole transaction has to be done from the beginning again.
A UoW can be associated with a Usecase. A Usecase describes the metainformation about the process to be performed by the UoW.
Method Summary | ||
---|---|---|
void |
addUnitOfWorkCallback(UnitOfWorkCallback callback)
Register a callback. |
|
void |
complete()
Complete this UnitOfWork. |
|
void |
discard()
Discard thie UnitOfWork. |
|
|
get(Class<T> type,
String identity)
Find an Entity of the given mixin type with the give identity. |
|
|
get(T entity)
If you have a reference to an Entity from another UnitOfWork and want to create a reference to it in this UnitOfWork, then call this method. |
|
boolean |
isOpen()
Check if the UnitOfWork is open. |
|
boolean |
isPaused()
Check if the UnitOfWork is paused. |
|
MetaInfo |
metaInfo()
Get the MetaInfo for this UnitOfWork. |
|
|
newEntity(Class<T> type)
Create a new Entity which implements the given mixin type. |
|
|
newEntity(Class<T> type,
String identity)
Create a new Entity which implements the given mixin type. |
|
|
newEntityBuilder(Class<T> type)
Create a new EntityBuilder for an EntityComposite which implements the given mixin type. |
|
|
newEntityBuilder(Class<T> type,
String identity)
Create a new EntityBuilder for an EntityComposite which implements the given mixin type. |
|
void |
pause()
Pauses this UnitOfWork. |
|
void |
remove(Object entity)
Remove the given Entity. |
|
void |
removeUnitOfWorkCallback(UnitOfWorkCallback callback)
|
|
void |
resume()
Resumes this UnitOfWork to again become the current UnitOfWork. |
|
UnitOfWorkFactory |
unitOfWorkFactory()
Get the UnitOfWorkFactory that this UnitOfWork was created from. |
|
Usecase |
usecase()
Get the Usecase for this UnitOfWork |
Method Detail |
---|
UnitOfWorkFactory unitOfWorkFactory()
Usecase usecase()
MetaInfo metaInfo()
<T> T newEntity(Class<T> type) throws EntityTypeNotFoundException, LifecycleException
type
- the mixin type that the EntityComposite must implement
NoSuchEntityException
- if no EntityComposite type of the given mixin type has been registered
LifecycleException
- if the entity cannot be created
EntityTypeNotFoundException
<T> T newEntity(Class<T> type, String identity) throws EntityTypeNotFoundException, LifecycleException
type
- the mixin type that the EntityComposite must implementidentity
- the identity of the new Entity
NoSuchEntityException
- if no EntityComposite type of the given mixin type has been registered
LifecycleException
- if the entity cannot be created
EntityTypeNotFoundException
<T> EntityBuilder<T> newEntityBuilder(Class<T> type) throws EntityTypeNotFoundException
type
- the mixin type that the EntityComposite must implement
NoSuchEntityException
- if no EntityComposite type of the given mixin type has been registered
LifecycleException
EntityTypeNotFoundException
<T> EntityBuilder<T> newEntityBuilder(Class<T> type, String identity) throws EntityTypeNotFoundException
type
- the mixin type that the EntityComposite must implementidentity
- the identity of the new Entity
NoSuchEntityException
- if no EntityComposite type of the given mixin type has been registered
LifecycleException
EntityTypeNotFoundException
<T> T get(Class<T> type, String identity) throws EntityTypeNotFoundException, NoSuchEntityException
type
- of the entityidentity
- of the entity
EntityTypeNotFoundException
- if no entity type could be found
NoSuchEntityException
<T> T get(T entity) throws EntityTypeNotFoundException
entity
- the Entity to be dereferenced
EntityTypeNotFoundException
- if no entity type could be foundvoid remove(Object entity) throws LifecycleException
entity
- the Entity to be removed.
LifecycleException
- if the entity could not be removedvoid complete() throws UnitOfWorkCompletionException, ConcurrentEntityModificationException
UnitOfWorkCompletionException
- if the UnitOfWork could not be completed
ConcurrentEntityModificationException
- if entities have been modified by othersvoid discard()
boolean isOpen()
boolean isPaused()
pause()
and then resumed by calling
resume()
.
void pause()
Calling this method will cause the underlying UnitOfWork to become the current UnitOfWork until the the resume() method is called. It is the client's responsibility not to drop the reference to this UnitOfWork while being paused.
void resume()
void addUnitOfWorkCallback(UnitOfWorkCallback callback)
callback
- a callback to be registered with this UnitOfWorkvoid removeUnitOfWorkCallback(UnitOfWorkCallback callback)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |