public interface UnitOfWork
CurrentUnitOfWork.get()
.Modifier and Type | Method and Description |
---|---|
void |
commit()
Commits the UnitOfWork.
|
boolean |
isStarted()
Indicates whether this UnitOfWork is started.
|
boolean |
isTransactional()
Indicates whether this UnitOfWork is bound to a transaction.
|
void |
publishEvent(EventMessage<?> event,
EventBus eventBus)
Request to publish the given
event on the given eventBus . |
<T extends AggregateRoot> |
registerAggregate(T aggregateRoot,
EventBus eventBus,
SaveAggregateCallback<T> saveAggregateCallback)
Register an aggregate with this UnitOfWork.
|
void |
registerListener(UnitOfWorkListener listener)
Register a listener that listens to state changes in this UnitOfWork.
|
void |
rollback()
Clear the UnitOfWork of any buffered changes.
|
void |
rollback(Throwable cause)
Clear the UnitOfWork of any buffered changes.
|
void |
start()
Starts the current unit of work, preparing it for aggregate registration.
|
void commit()
IllegalStateException
- if the UnitOfWork wasn't startedvoid rollback()
UnitOfWorkListener
s are notified.
If the rollback is a result of an exception, consider using rollback(Throwable)
instead.void rollback(Throwable cause)
UnitOfWorkListener
s are notified.cause
- The cause of the rollback. May be null
.IllegalStateException
- if the UnitOfWork wasn't startedvoid start()
boolean isStarted()
start()
method has been called,
and
if the UnitOfWork has not been committed or rolled back.true
if this UnitOfWork is started, false
otherwise.boolean isTransactional()
true
if this unit of work is bound to a transaction, otherwise false
void registerListener(UnitOfWorkListener listener)
listener
- The listener to notify when the UnitOfWork's state changes.<T extends AggregateRoot> T registerAggregate(T aggregateRoot, EventBus eventBus, SaveAggregateCallback<T> saveAggregateCallback)
saveAggregateCallback
is ignored.T
- the type of aggregate to registeraggregateRoot
- The aggregate root to register in the UnitOfWorkeventBus
- The event bus on which Events generated by this aggregate must be publishedsaveAggregateCallback
- The callback that is invoked when the UnitOfWork wants to store the registered
aggregateIllegalStateException
- if this Unit Of Work does not support registrations of aggregates with identical
type and identifiervoid publishEvent(EventMessage<?> event, EventBus eventBus)
event
on the given eventBus
. The UnitOfWork may either
publish immediately, or buffer the events until the UnitOfWork is committed.event
- The event to be published on the event buseventBus
- The event bus on which to publish the eventCopyright © 2010-2013. All Rights Reserved.