public abstract class NestableUnitOfWork extends Object implements UnitOfWork
CurrentUnitOfWork
and support for
nesting a Unit of Work.CurrentUnitOfWork
Constructor and Description |
---|
NestableUnitOfWork() |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Commits the UnitOfWork.
|
protected void |
commitInnerUnitOfWork()
Commit all registered inner units of work.
|
protected abstract void |
doCommit()
Executes the logic required to commit this unit of work.
|
protected abstract void |
doRollback(Throwable cause)
Executes the logic required to commit this unit of work.
|
protected abstract void |
doStart()
Performs logic required when starting this UnitOfWork instance.
|
boolean |
isStarted()
Indicates whether this UnitOfWork is started.
|
protected abstract void |
notifyListenersCleanup()
Send a
UnitOfWorkListener.onCleanup(UnitOfWork) notification to all
registered listeners. |
protected abstract void |
notifyListenersPrepareCommit()
Send a
UnitOfWorkListener.onPrepareCommit(UnitOfWork, java.util.Set,
java.util.List) notification to all registered listeners. |
protected abstract void |
notifyListenersRollback(Throwable cause)
Send a
UnitOfWorkListener.onRollback(UnitOfWork, Throwable) notification to all registered listeners. |
void |
publishEvent(EventMessage<?> event,
EventBus eventBus)
Request to publish the given
event on the given eventBus . |
protected abstract void |
registerForPublication(EventMessage<?> event,
EventBus eventBus)
Register the given
event for publication on the given eventBus when the unit of work
is committed. |
void |
rollback()
Clear the UnitOfWork of any buffered changes.
|
void |
rollback(Throwable cause)
Clear the UnitOfWork of any buffered changes.
|
protected abstract void |
saveAggregates()
Saves all registered aggregates by calling their respective callbacks.
|
void |
start()
Starts the current unit of work, preparing it for aggregate registration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isTransactional, registerAggregate, registerListener
public void commit()
UnitOfWork
commit
in interface UnitOfWork
protected abstract void notifyListenersCleanup()
UnitOfWorkListener.onCleanup(UnitOfWork)
notification to all
registered listeners. The implementation must ensure that all listeners are notified, even if one throws an
exception.protected abstract void notifyListenersRollback(Throwable cause)
UnitOfWorkListener.onRollback(UnitOfWork, Throwable)
notification to all registered listeners.cause
- The cause of the rollbackpublic void rollback()
UnitOfWork
UnitOfWorkListener
s are notified.
If the rollback is a result of an exception, consider using UnitOfWork.rollback(Throwable)
instead.rollback
in interface UnitOfWork
public void rollback(Throwable cause)
UnitOfWork
UnitOfWorkListener
s are notified.rollback
in interface UnitOfWork
cause
- The cause of the rollback. May be null
.public void start()
UnitOfWork
start
in interface UnitOfWork
public void publishEvent(EventMessage<?> event, EventBus eventBus)
UnitOfWork
event
on the given eventBus
. The UnitOfWork may either
publish immediately, or buffer the events until the UnitOfWork is committed.publishEvent
in interface UnitOfWork
event
- The event to be published on the event buseventBus
- The event bus on which to publish the eventprotected abstract void registerForPublication(EventMessage<?> event, EventBus eventBus)
event
for publication on the given eventBus
when the unit of work
is committed. This method will only be invoked on the outer unit of work, as that one is responsible for
maintaining the order of publication of events.event
- The Event to publisheventBus
- The Event Bus to publish the Event onpublic boolean isStarted()
UnitOfWork
UnitOfWork.start()
method has been called,
and
if the UnitOfWork has not been committed or rolled back.isStarted
in interface UnitOfWork
true
if this UnitOfWork is started, false
otherwise.protected abstract void doStart()
protected abstract void doCommit()
protected abstract void doRollback(Throwable cause)
cause
- the cause of the rollbackprotected void commitInnerUnitOfWork()
protected abstract void saveAggregates()
protected abstract void notifyListenersPrepareCommit()
UnitOfWorkListener.onPrepareCommit(UnitOfWork, java.util.Set,
java.util.List)
notification to all registered listeners.Copyright © 2010-2013. All Rights Reserved.