public class MetaDataCommandTargetResolver extends Object implements CommandTargetResolver
Constructor and Description |
---|
MetaDataCommandTargetResolver(String identifierKey)
Initializes the MetaDataCommandTargetResolver to use the given
identifierKey as the MetaData key to the
aggregate identifier, and a null (ignored) version. |
MetaDataCommandTargetResolver(String identifierKey,
String versionKey)
Initializes the MetaDataCommandTargetResolver to use the given
identifierKey as the MetaData key to the
aggregate identifier, and the given versionKey as key to the (optional) version entry. |
Modifier and Type | Method and Description |
---|---|
VersionedAggregateIdentifier |
resolveTarget(CommandMessage<?> command)
Returns the Aggregate Identifier and optionally the expected version of the aggregate on which the given
command should be executed. |
public MetaDataCommandTargetResolver(String identifierKey)
identifierKey
as the MetaData key to the
aggregate identifier, and a null
(ignored) version.
When the given identifierKey
is not present in a command's MetaData,
resolveTarget(CommandMessage)
will raise an IllegalArgumentException
identifierKey
- The key of the metadata field containing the aggregate identifierpublic MetaDataCommandTargetResolver(String identifierKey, String versionKey)
identifierKey
as the MetaData key to the
aggregate identifier, and the given versionKey
as key to the (optional) version entry.
When the given identifierKey
is not present in a command's MetaData,
resolveTarget(CommandMessage)
will raise an IllegalArgumentException
identifierKey
- The key of the metadata field containing the aggregate identifierversionKey
- The key of the metadata field containing the expected aggregate version. A null
value may be provided to ignore the versionpublic VersionedAggregateIdentifier resolveTarget(@Nonnull CommandMessage<?> command)
CommandTargetResolver
command
should be executed.
The version may be null
if no specific version is required. Furthermore, the returned
VersionedAggregateIdentifier
may be null entirely when the given command
is targeted towards a
CreationPolicy
annotated command handler that (optionally) constructs a new aggregate instance.
resolveTarget
in interface CommandTargetResolver
command
- The command from which to extract the identifier and version.VersionedAggregateIdentifier
instance reflecting the aggregate to execute the command on, or
null
when the command
is targeted towards a CreationPolicy
annotated command handler that
constructs a new aggregate instance.AggregateCreationPolicy.ALWAYS
,
AggregateCreationPolicy.CREATE_IF_MISSING
Copyright © 2010–2024. All rights reserved.