Interface CommandHandler<COMMAND,​EVENT,​ERROR>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​COMMAND,​EVENT,​ERROR,​STATE>
      CommandHandler<COMMAND,​EVENT,​ERROR>
      deciderBasedCommandHandler​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, Class<ID> aggregateIdType, AggregateIdResolver<COMMAND,​ID> aggregateIdFromCommandResolver, AggregateIdResolver<EVENT,​ID> aggregateIdFromEventResolver, AggregateSnapshotRepository aggregateSnapshotRepository, Class<STATE> stateType, Decider<COMMAND,​EVENT,​ERROR,​STATE> decider)
      Create an instance of a CommandHandler that is responsible for loading any existing Aggregate STATE from the underlying EventStore and coordinate persisting any changes to the Aggregate, in the form of EVENT's, to the EventStore as part of an active UnitOfWork (if one exists)
      The actual logic is delegated to an instance of a Decider
      HandlerResult<ERROR,​EVENT> handle​(COMMAND cmd)
      The execute method is responsible for handling a COMMAND, which can either result in an ERROR or a list of EVENT's.
      Note: This method is called decide in the decider pattern
      Idempotent handling of a COMMAND will result in an empty list of EVENT's
    • Method Detail

      • handle

        HandlerResult<ERROR,​EVENT> handle​(COMMAND cmd)
        The execute method is responsible for handling a COMMAND, which can either result in an ERROR or a list of EVENT's.
        Note: This method is called decide in the decider pattern
        Idempotent handling of a COMMAND will result in an empty list of EVENT's
        Parameters:
        cmd - the command to handle
        Returns:
        either an ERROR or a list of EVENT's.
        Idempotent handling of a COMMAND will result in an empty list of EVENT's
      • deciderBasedCommandHandler

        static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,​ID,​COMMAND,​EVENT,​ERROR,​STATE> CommandHandler<COMMAND,​EVENT,​ERROR> deciderBasedCommandHandler​(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore,
                                                                                                                                                                                                                                                                                            dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType,
                                                                                                                                                                                                                                                                                            Class<ID> aggregateIdType,
                                                                                                                                                                                                                                                                                            AggregateIdResolver<COMMAND,​ID> aggregateIdFromCommandResolver,
                                                                                                                                                                                                                                                                                            AggregateIdResolver<EVENT,​ID> aggregateIdFromEventResolver,
                                                                                                                                                                                                                                                                                            AggregateSnapshotRepository aggregateSnapshotRepository,
                                                                                                                                                                                                                                                                                            Class<STATE> stateType,
                                                                                                                                                                                                                                                                                            Decider<COMMAND,​EVENT,​ERROR,​STATE> decider)
        Create an instance of a CommandHandler that is responsible for loading any existing Aggregate STATE from the underlying EventStore and coordinate persisting any changes to the Aggregate, in the form of EVENT's, to the EventStore as part of an active UnitOfWork (if one exists)
        The actual logic is delegated to an instance of a Decider
        Type Parameters:
        CONFIG - The type of AggregateEventStreamConfiguration that the EventStore provided supports
        ID - the type of aggregate id that is associated with the AggregateType
        COMMAND - the type of COMMAND that the Decider instance supports
        EVENT - the type of EVENT that the Decider instance supports
        ERROR - the type of ERROR that the Decider instance supports
        STATE - the type of Aggregate STATE that the Decider instance supports
        Parameters:
        eventStore - the EventStore that provides persistence support for aggregate events
        aggregateType - the aggregate type that this command handler can support COMMAND's related to and which the Decider supports EVENT's related to
        aggregateIdType - the type of aggregate id that is associated with the AggregateType
        aggregateIdFromCommandResolver - resolver that can resolve the aggregate-id from a COMMAND object instance
        aggregateIdFromEventResolver - resolver that can resolve the aggregate-id from an EVENT object instance
        aggregateSnapshotRepository - optional AggregateSnapshotRepository for storing snapshots of the aggregate STATE for faster loading
        stateType - The type of aggregate STATE that the Decider instance works with
        decider - the Decider instance responsible for Aggregate logic
        Returns:
        a CommandHandler that is responsible for loading any existing Aggregate STATE from the underlying EventStore and coordinate persisting any changes to the Aggregate, in the form of EVENT's, to the EventStore as part of an active UnitOfWork (if one exists)
        The actual logic is delegated to an instance of a Decider