org.axonframework.commandhandling.disruptor
Class CommandHandlerInvoker

java.lang.Object
  extended by org.axonframework.commandhandling.disruptor.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 pre-loaded, it is set to the ThreadLocal.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
CommandHandlerInvoker(EventStore eventStore, Cache cache, int segmentId)
          Create an aggregate invoker instance that uses the given eventStore and cache to retrieve aggregate instances.
 
Method Summary
<T extends EventSourcedAggregateRoot>
Repository<T>
createRepository(AggregateFactory<T> aggregateFactory, EventStreamDecorator decorator)
          Create a repository instance for an aggregate created by the given aggregateFactory.
static
<T extends EventSourcedAggregateRoot>
org.axonframework.commandhandling.disruptor.CommandHandlerInvoker.DisruptorRepository<T>
getRepository(String typeIdentifier)
          Returns the Repository instance for Aggregate with given typeIdentifier used by the CommandHandlerInvoker that is running on the current thread.
 void onEvent(CommandHandlingEntry entry, long sequence, boolean endOfBatch)
           
 void onShutdown()
           
 void onStart()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandHandlerInvoker

public CommandHandlerInvoker(EventStore eventStore,
                             Cache cache,
                             int segmentId)
Create an aggregate invoker instance that uses the given eventStore and cache to retrieve aggregate instances.

Parameters:
eventStore - The event store providing access to events to reconstruct aggregates
cache - The cache temporarily storing aggregate instances
segmentId - The id of the segment this invoker should handle
Method Detail

getRepository

public static <T extends EventSourcedAggregateRoot> org.axonframework.commandhandling.disruptor.CommandHandlerInvoker.DisruptorRepository<T> getRepository(String typeIdentifier)
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:
typeIdentifier - The type identifier of the aggregate
Returns:
the repository instance for aggregate of given type

onEvent

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

createRepository

public <T extends EventSourcedAggregateRoot> Repository<T> createRepository(AggregateFactory<T> aggregateFactory,
                                                                            EventStreamDecorator decorator)
Create a repository instance for an aggregate created by the given aggregateFactory. The returning repository must be sage to use by this invoker instance.

Type Parameters:
T - The type of aggregate created by the factory
Parameters:
aggregateFactory - The factory creating aggregate instances
decorator - The decorator to decorate event streams with
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


Copyright © 2010-2016. All Rights Reserved.