Class ConflictResolution
java.lang.Object
org.axonframework.eventsourcing.conflictresolution.ConflictResolution
- All Implemented Interfaces:
ParameterResolver<ConflictResolver>,ParameterResolverFactory
public class ConflictResolution
extends Object
implements ParameterResolverFactory, ParameterResolver<ConflictResolver>
ParameterResolverFactory that add support for the ConflictResolver parameter type in annotated handlers.
Conflict resolution can be initialized by passing a ConflictResolver to the static initialize(ConflictResolver) method. Note that a UnitOfWork needs
to be active before conflict resolution can be initialized.
- Author:
- Rene de Waele
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateInstance(Executable executable, Parameter[] parameters, int parameterIndex) If available, creates a ParameterResolver instance that can provide a parameter of typeparameterTypefor a given message.static ConflictResolverReturns the ConflictResolver instance that can be used to resolve conflicts of an Aggregate that has been previously loaded in this Unit of Work.static voidinitialize(ConflictResolver conflictResolver) Initialize conflict resolution in the context of the current Unit of Work dealing with a command on an event sourced aggregate.booleanIndicates whether this resolver is capable of providing a value for the givenmessage.resolveParameterValue(Message<?> message) Resolves the parameter value to use for the givenmessage, ornullif no suitable parameter value can be resolved.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.annotation.ParameterResolver
supportedPayloadType
-
Constructor Details
-
ConflictResolution
public ConflictResolution()
-
-
Method Details
-
initialize
Initialize conflict resolution in the context of the current Unit of Work dealing with a command on an event sourced aggregate.- Parameters:
conflictResolver- conflict resolver able to detect conflicts
-
getConflictResolver
Returns the ConflictResolver instance that can be used to resolve conflicts of an Aggregate that has been previously loaded in this Unit of Work. Note that, when multiple aggregates are loaded, theConflictResolverthat was registered last, is returned.Any conflicts must be resolved (by invoking one of the methods on
ConflictResolver) before the Unit of Work is committed.If no Aggregate was loaded, or no conflicts are present, this method will return a
NoConflictResolver, instance.- Returns:
- The ConflictResolver for the last loaded Aggregate.
-
createInstance
public ParameterResolver createInstance(Executable executable, Parameter[] parameters, int parameterIndex) Description copied from interface:ParameterResolverFactoryIf available, creates a ParameterResolver instance that can provide a parameter of typeparameterTypefor a given message.If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns
null.- Specified by:
createInstancein interfaceParameterResolverFactory- Parameters:
executable- The executable (constructor or method) to inspectparameters- The parameters on the executable to inspectparameterIndex- The index of the parameter to return a ParameterResolver for- Returns:
- a suitable ParameterResolver, or
nullif none is found
-
resolveParameterValue
Description copied from interface:ParameterResolverResolves the parameter value to use for the givenmessage, ornullif no suitable parameter value can be resolved.- Specified by:
resolveParameterValuein interfaceParameterResolver<ConflictResolver>- Parameters:
message- The message to resolve the value from- Returns:
- the parameter value for the handler
-
matches
Description copied from interface:ParameterResolverIndicates whether this resolver is capable of providing a value for the givenmessage.- Specified by:
matchesin interfaceParameterResolver<ConflictResolver>- Parameters:
message- The message to evaluate- Returns:
trueif this resolver can provide a value for the message, otherwisefalse
-