Class CommandEventCapturer<I>

java.lang.Object
com.opencqrs.framework.persistence.EventCapturer
com.opencqrs.framework.command.CommandEventCapturer<I>
Type Parameters:
I - the instance as defined by the CommandHandlerDefinition being executed
All Implemented Interfaces:
CommandEventPublisher<I>, EventPublisher

public class CommandEventCapturer<I> extends EventCapturer implements CommandEventPublisher<I>
Default implementation of CommandEventPublisher used by CommandRouter to apply events to the StateRebuildingHandlers relevant for the Command being executed.
  • Constructor Details

  • Method Details

    • publish

      public <E> I publish(E event, Map<String,?> metaData, List<Precondition> preconditions)
      Description copied from interface: CommandEventPublisher
      Publishes an event and its meta-data to the subject specified by Command.getSubject() and applies it to any assignable StateRebuildingHandlers participating in the command execution. Additionally, the given preconditions will be applied after command execution succeeds, in addition to those applied by the CommandRouter implicitly.
      Specified by:
      publish in interface CommandEventPublisher<I>
      Type Parameters:
      E - the event type
      Parameters:
      event - the event to be published
      metaData - the event meta-data to be published
      preconditions - the preconditions that must not be violated
      Returns:
      an updated or new instance with all events applied
    • publishRelative

      public <E> I publishRelative(String subjectSuffix, E event, Map<String,?> metaData, List<Precondition> preconditions)
      Description copied from interface: CommandEventPublisher
      Publishes an event and its meta-data to the subject specified by Command.getSubject() appended with the specified suffix and applies it to any assignable StateRebuildingHandlers participating in the command execution. Additionally, the given preconditions will be applied after command execution succeeds, in addition to those applied by the CommandRouter implicitly.
      Specified by:
      publishRelative in interface CommandEventPublisher<I>
      Type Parameters:
      E - the event type
      Parameters:
      subjectSuffix - the suffix to be appended to the Command.getSubject() currently executed, must not start with /
      event - the event to be published
      metaData - the event meta-data to be published
      preconditions - the preconditions that must not be violated
      Returns:
      an updated or new instance with all events applied