public class StubAggregateLifecycle extends AggregateLifecycle
activate()
) and deactivated (see close()
) at will. Events
applied while it is active are stored and can be retrieved using getAppliedEvents()
or
getAppliedEventPayloads()
.
When using with JUnit, consider using the StubAggregateLifecycleRule
with @Rule
instead,
as it is easier and safer to use.
Constructor and Description |
---|
StubAggregateLifecycle() |
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates this lifecycle instance.
|
void |
close()
Closes this lifecycle instance, restoring to the situation prior to this lifecycle being started.
|
protected <T> ApplyMore |
doApply(T payload,
MetaData metaData)
Apply a
DomainEventMessage with given payload and metadata (metadata from interceptors will be combined
with the provided metadata). |
protected void |
doMarkDeleted()
Marks this aggregate as deleted.
|
List<Object> |
getAppliedEventPayloads()
Returns the payloads of the Events applied while this lifecycle instance was active.
|
List<EventMessage<?>> |
getAppliedEvents()
Returns the list of applied Events for this lifecycle instance.
|
protected boolean |
getIsLive()
Indicates whether this Aggregate instance is 'live'.
|
boolean |
isMarkedDeleted()
Indicates whether an Aggregate has invoked "markDeleted" while this lifecycle was active.
|
apply, apply, execute, executeWithResult, getInstance, isLive, markDeleted, registerAsCurrent, registerWithUnitOfWork
public void activate()
close()
is called.public void close()
protected boolean getIsLive()
AggregateLifecycle
getIsLive
in class AggregateLifecycle
true
if the aggregate is 'live', false
if the aggregate is initializing state based on
historic eventsprotected void doMarkDeleted()
AggregateLifecycle
doMarkDeleted
in class AggregateLifecycle
protected <T> ApplyMore doApply(T payload, MetaData metaData)
AggregateLifecycle
DomainEventMessage
with given payload and metadata (metadata from interceptors will be combined
with the provided metadata). The event should be applied to the aggregate immediately and scheduled for
publication to other event handlers.
The event should be applied on all entities part of this aggregate. If the event is applied from an event handler
of the aggregate and additional events need to be applied that depends on state changes brought about by the
first event the returned ApplyMore
instance should allow for additional events to be applied after this
event.doApply
in class AggregateLifecycle
payload
- the payload of the event to applymetaData
- any meta-data that must be registered with the EventApplyMore
public List<EventMessage<?>> getAppliedEvents()
Note that this list is not reset when activating or deactivating the lifecycle.
public List<Object> getAppliedEventPayloads()
AggregateLifecycle.apply(Object)
method.public boolean isMarkedDeleted()
true
if AggregateLifecycle.markDeleted()
was invoked, otherwise false
Copyright © 2010–2017. All rights reserved.