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 <T> Aggregate<T> |
doCreateNew(Class<T> aggregateType,
Callable<T> factoryMethod)
Creates a new aggregate instance.
|
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'.
|
protected Object |
identifier()
Retrieve a
Object denoting the identifier of this Aggregate. |
boolean |
isMarkedDeleted()
Indicates whether an Aggregate has invoked "markDeleted" while this lifecycle was active.
|
protected String |
type()
Retrieve a
String denoting the type of this Aggregate. |
protected Long |
version()
Gets the version of the aggregate.
|
apply, apply, createNew, describeScope, execute, getInstance, getVersion, isLive, markDeleteddescribeCurrentScope, endScope, executeWithResult, getCurrentScope, startScopepublic void activate()
close() is called.public void close()
protected boolean getIsLive()
AggregateLifecyclegetIsLive in class AggregateLifecycletrue if the aggregate is 'live', false if the aggregate is initializing state based on
historic eventsprotected <T> Aggregate<T> doCreateNew(Class<T> aggregateType, Callable<T> factoryMethod) throws Exception
AggregateLifecycleRepository should be
available to the current aggregate. Repository of an aggregate to be created is exposed to the current
aggregate via RepositoryProvider.doCreateNew in class AggregateLifecycleT - type of new aggregate to be createdaggregateType - type of new aggregate to be createdfactoryMethod - factory method which creates new aggregateException - thrown if something goes wrong during instantiation of new aggregateprotected String type()
AggregateLifecycleString denoting the type of this Aggregate.type in class AggregateLifecycleString denoting the type of this Aggregateprotected Object identifier()
AggregateLifecycleObject denoting the identifier of this Aggregate.identifier in class AggregateLifecycleObject denoting the identifier of this Aggregateprotected Long version()
AggregateLifecycleversion in class AggregateLifecycleprotected void doMarkDeleted()
AggregateLifecycledoMarkDeleted in class AggregateLifecycleprotected <T> ApplyMore doApply(T payload, MetaData metaData)
AggregateLifecycleDomainEventMessage 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 AggregateLifecyclepayload - the payload of the event to applymetaData - any meta-data that must be registered with the EventApplyMorepublic 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 falseCopyright © 2010–2023. All rights reserved.