Class CommandHandlerInvoker

java.lang.Object
org.axonframework.disruptor.commandhandling.CommandHandlerInvoker
All Implemented Interfaces:
com.lmax.disruptor.EventHandler<CommandHandlingEntry>, com.lmax.disruptor.LifecycleAware

public class CommandHandlerInvoker extends Object implements com.lmax.disruptor.EventHandler<CommandHandlingEntry>, com.lmax.disruptor.LifecycleAware
Component of the DisruptorCommandBus that invokes the command handler. The execution is done within a Unit Of Work. If an aggregate has been preloaded, it is set to the ThreadLocal.
Since:
2.0
Author:
Allard Buijze
  • Constructor Details

    • CommandHandlerInvoker

      public CommandHandlerInvoker(Cache cache, int segmentId)
      Create an aggregate invoker instance for the given segment and cache.
      Parameters:
      cache - The cache temporarily storing aggregate instances
      segmentId - The id of the segment this invoker should handle
  • Method Details

    • getRepository

      public static <T> org.axonframework.disruptor.commandhandling.CommandHandlerInvoker.DisruptorRepository<T> getRepository(Class<?> type)
      Returns the Repository instance for Aggregate with given typeIdentifier used by the CommandHandlerInvoker that is running on the current thread.

      Calling this method from any other thread will return null.

      Type Parameters:
      T - The type of aggregate
      Parameters:
      type - The type of aggregate
      Returns:
      the repository instance for aggregate of given type
    • onEvent

      public void onEvent(CommandHandlingEntry entry, long sequence, boolean endOfBatch)
      Specified by:
      onEvent in interface com.lmax.disruptor.EventHandler<CommandHandlingEntry>
    • createRepository

      public <T> Repository<T> createRepository(EventStore eventStore, AggregateFactory<T> aggregateFactory, SnapshotTriggerDefinition snapshotTriggerDefinition, ParameterResolverFactory parameterResolverFactory)
      Create a repository instance for an aggregate created by the given aggregateFactory. The returning repository must be safe to use by this invoker instance.
      Type Parameters:
      T - The type of aggregate created by the factory
      Parameters:
      eventStore - The events store to load and publish events
      aggregateFactory - The factory creating aggregate instances
      snapshotTriggerDefinition - The trigger definition for snapshots
      parameterResolverFactory - The factory used to resolve parameters on command handler methods
      Returns:
      A Repository instance for the given aggregate
    • createRepository

      public <T> Repository<T> createRepository(EventStore eventStore, RepositoryProvider repositoryProvider, AggregateFactory<T> aggregateFactory, SnapshotTriggerDefinition snapshotTriggerDefinition, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition)
      Create a repository instance for an aggregate created by the given aggregateFactory. The returning repository must be safe to use by this invoker instance.
      Type Parameters:
      T - The type of aggregate created by the factory
      Parameters:
      eventStore - The events store to load and publish events
      repositoryProvider - Provides repositories for specified aggregate types
      aggregateFactory - The factory creating aggregate instances
      snapshotTriggerDefinition - The trigger definition for snapshots
      parameterResolverFactory - The factory used to resolve parameters on command handler methods
      handlerDefinition - The handler definition used to create concrete handlers
      Returns:
      A Repository instance for the given aggregate
    • onStart

      public void onStart()
      Specified by:
      onStart in interface com.lmax.disruptor.LifecycleAware
    • onShutdown

      public void onShutdown()
      Specified by:
      onShutdown in interface com.lmax.disruptor.LifecycleAware