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 Summary
ConstructorsConstructorDescriptionCommandHandlerInvoker(Cache cache, int segmentId) Create an aggregate invoker instance for the givensegmentandcache. -
Method Summary
Modifier and TypeMethodDescription<T> Repository<T> createRepository(EventStore eventStore, AggregateFactory<T> aggregateFactory, SnapshotTriggerDefinition snapshotTriggerDefinition, ParameterResolverFactory parameterResolverFactory) Create a repository instance for an aggregate created by the givenaggregateFactory.<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 givenaggregateFactory.static <T> org.axonframework.disruptor.commandhandling.CommandHandlerInvoker.DisruptorRepository<T> getRepository(Class<?> type) Returns the Repository instance for Aggregate with giventypeIdentifierused by the CommandHandlerInvoker that is running on the current thread.voidonEvent(CommandHandlingEntry entry, long sequence, boolean endOfBatch) voidvoidonStart()
-
Constructor Details
-
CommandHandlerInvoker
Create an aggregate invoker instance for the givensegmentandcache.- Parameters:
cache- The cache temporarily storing aggregate instancessegmentId- 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 giventypeIdentifierused 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
- Specified by:
onEventin interfacecom.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 givenaggregateFactory. 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 eventsaggregateFactory- The factory creating aggregate instancessnapshotTriggerDefinition- The trigger definition for snapshotsparameterResolverFactory- 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 givenaggregateFactory. 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 eventsrepositoryProvider- Provides repositories for specified aggregate typesaggregateFactory- The factory creating aggregate instancessnapshotTriggerDefinition- The trigger definition for snapshotsparameterResolverFactory- The factory used to resolve parameters on command handler methodshandlerDefinition- The handler definition used to create concrete handlers- Returns:
- A Repository instance for the given aggregate
-
onStart
public void onStart()- Specified by:
onStartin interfacecom.lmax.disruptor.LifecycleAware
-
onShutdown
public void onShutdown()- Specified by:
onShutdownin interfacecom.lmax.disruptor.LifecycleAware
-