public abstract class AggregateLifecycle extends Scope
Constructor and Description |
---|
AggregateLifecycle() |
Modifier and Type | Method and Description |
---|---|
static ApplyMore |
apply(Object payload)
Apply a
DomainEventMessage with given payload without metadata (though
interceptors can also be used to provide metadata). |
static ApplyMore |
apply(Object payload,
MetaData metaData)
Apply a
DomainEventMessage with given payload and metadata (metadata
from interceptors will be combined with the provided metadata). |
static <T> Aggregate<T> |
createNew(Class<T> aggregateType,
Callable<T> factoryMethod)
Creates a new aggregate instance.
|
ScopeDescriptor |
describeScope()
Provide a description of this
Scope . |
protected abstract <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 abstract <T> Aggregate<T> |
doCreateNew(Class<T> aggregateType,
Callable<T> factoryMethod)
Creates a new aggregate instance.
|
protected abstract void |
doMarkDeleted()
Marks this aggregate as deleted.
|
protected void |
execute(Runnable task)
Executes the given task.
|
protected static AggregateLifecycle |
getInstance()
Get the current
AggregateLifecycle instance for the current thread. |
protected abstract boolean |
getIsLive()
Indicates whether this Aggregate instance is 'live'.
|
static Long |
getVersion()
Gets the version of the aggregate.
|
protected abstract Object |
identifier()
Retrieve a
Object denoting the identifier of this Aggregate. |
static boolean |
isLive()
Indicates whether this Aggregate instance is 'live'.
|
static void |
markDeleted()
Marks this aggregate as deleted, instructing a repository to remove that aggregate at an appropriate time.
|
protected abstract String |
type()
Retrieve a
String denoting the type of this Aggregate. |
protected abstract Long |
version()
Gets the version of the aggregate.
|
describeCurrentScope, endScope, executeWithResult, getCurrentScope, startScope
public static ApplyMore apply(Object payload, MetaData metaData)
DomainEventMessage
with given payload and metadata (metadata
from interceptors will be combined with the provided metadata). Applying events means they are immediately
applied (published) to the aggregate and scheduled for publication to other event handlers.
The event is 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
use the returned ApplyMore
instance.payload
- the payload of the event to applymetaData
- any meta-data that must be registered with the EventApplyMore
public static ApplyMore apply(Object payload)
DomainEventMessage
with given payload without metadata (though
interceptors can also be used to provide metadata). Applying events means they are immediately applied
(published) to the aggregate and scheduled for publication to other event handlers.
The event is 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
use the returned ApplyMore
instance.payload
- the payload of the event to applyApplyMore
public static <T> Aggregate<T> createNew(Class<T> aggregateType, Callable<T> factoryMethod) throws Exception
Repository
should be
available to the current aggregate. Repository
of an aggregate to be created is exposed to the current
aggregate via RepositoryProvider
.T
- 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 aggregatepublic static boolean isLive()
true
if the aggregate is 'live', false
if the aggregate is initializing state based on
historic eventspublic static Long getVersion()
public static void markDeleted()
protected static AggregateLifecycle getInstance()
AggregateLifecycle
instance for the current thread. If none exists an IllegalStateException
is thrown.AggregateLifecycle
protected abstract boolean getIsLive()
true
if the aggregate is 'live', false
if the aggregate is initializing state based on
historic eventsprotected abstract Long version()
protected abstract void doMarkDeleted()
protected abstract <T> ApplyMore doApply(T payload, MetaData metaData)
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.payload
- the payload of the event to applymetaData
- any meta-data that must be registered with the EventApplyMore
protected abstract <T> Aggregate<T> doCreateNew(Class<T> aggregateType, Callable<T> factoryMethod) throws Exception
Repository
should be
available to the current aggregate. Repository
of an aggregate to be created is exposed to the current
aggregate via RepositoryProvider
.T
- 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 void execute(Runnable task)
task
- the task to execute on the aggregatepublic ScopeDescriptor describeScope()
Scope
Scope
.describeScope
in class Scope
ScopeDescriptor
describing this Scope
protected abstract String type()
String
denoting the type of this Aggregate.String
denoting the type of this AggregateCopyright © 2010–2020. All rights reserved.