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 Details

    • ConflictResolution

      public ConflictResolution()
  • Method Details

    • initialize

      public static void initialize(ConflictResolver conflictResolver)
      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

      public static ConflictResolver 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, the ConflictResolver that 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: ParameterResolverFactory
      If available, creates a ParameterResolver instance that can provide a parameter of type parameterType for a given message.

      If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns null.

      Specified by:
      createInstance in interface ParameterResolverFactory
      Parameters:
      executable - The executable (constructor or method) to inspect
      parameters - The parameters on the executable to inspect
      parameterIndex - The index of the parameter to return a ParameterResolver for
      Returns:
      a suitable ParameterResolver, or null if none is found
    • resolveParameterValue

      public ConflictResolver resolveParameterValue(Message<?> message)
      Description copied from interface: ParameterResolver
      Resolves the parameter value to use for the given message, or null if no suitable parameter value can be resolved.
      Specified by:
      resolveParameterValue in interface ParameterResolver<ConflictResolver>
      Parameters:
      message - The message to resolve the value from
      Returns:
      the parameter value for the handler
    • matches

      public boolean matches(Message<?> message)
      Description copied from interface: ParameterResolver
      Indicates whether this resolver is capable of providing a value for the given message.
      Specified by:
      matches in interface ParameterResolver<ConflictResolver>
      Parameters:
      message - The message to evaluate
      Returns:
      true if this resolver can provide a value for the message, otherwise false