org.axonframework.eventhandling
Class AsynchronousEventHandlerWrapper

java.lang.Object
  extended by org.axonframework.eventhandling.AsynchronousEventHandlerWrapper
All Implemented Interfaces:
EventListener, EventListenerProxy

public class AsynchronousEventHandlerWrapper
extends Object
implements EventListenerProxy

The AsynchronousEventHandlerWrapper can wrap any event listener to give it asynchronous behavior. The wrapper will schedule all incoming events for processing, making the calling thread return immediately.

Since:
0.3
Author:
Allard Buijze

Constructor Summary
AsynchronousEventHandlerWrapper(EventListener eventListener, EventSequencingPolicy eventSequencingPolicy, Executor executor)
          Initialize the AsynchronousEventHandlerWrapper for the given eventListener using the given executor.
AsynchronousEventHandlerWrapper(EventListener eventListener, TransactionManager transactionManager, EventSequencingPolicy eventSequencingPolicy, Executor executor)
          Initialize the AsynchronousEventHandlerWrapper for the given eventListener using the given executor and transactionManager.
 
Method Summary
 Object getTarget()
          Returns the instance that this proxy delegates all event handling to
 void handle(Event event)
          Handles the event by scheduling it for execution by the target event handler.
protected  EventProcessingScheduler newProcessingScheduler(org.axonframework.eventhandling.EventProcessingScheduler.ShutdownCallback shutDownCallback)
          Creates a new scheduler instance for the eventListener that schedules events on the executor service for the managed EventListener.
protected  EventProcessingScheduler newProcessingScheduler(Queue<Event> eventQueue, org.axonframework.eventhandling.EventProcessingScheduler.ShutdownCallback shutDownCallback)
          Creates a new scheduler instance for the eventListener that schedules events on the executor service for the managed EventListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsynchronousEventHandlerWrapper

public AsynchronousEventHandlerWrapper(EventListener eventListener,
                                       TransactionManager transactionManager,
                                       EventSequencingPolicy eventSequencingPolicy,
                                       Executor executor)
Initialize the AsynchronousEventHandlerWrapper for the given eventListener using the given executor and transactionManager. The transaction manager is used to start and stop any underlying transactions necessary for event processing.

Parameters:
eventListener - The event listener this instance manages
transactionManager - The transaction manager that will manage underlying transactions for this event
eventSequencingPolicy - The sequencing policy for concurrent execution of events
executor - The executor that processes the events

AsynchronousEventHandlerWrapper

public AsynchronousEventHandlerWrapper(EventListener eventListener,
                                       EventSequencingPolicy eventSequencingPolicy,
                                       Executor executor)
Initialize the AsynchronousEventHandlerWrapper for the given eventListener using the given executor.

Note that the underlying bean will not be notified of any transactions.

Parameters:
eventListener - The event listener this instance manages
eventSequencingPolicy - The sequencing policy for concurrent execution of events
executor - The executor that processes the events
See Also:
AsynchronousEventHandlerWrapper(EventListener, TransactionManager, EventSequencingPolicy, java.util.concurrent.Executor)
Method Detail

handle

public void handle(Event event)
Handles the event by scheduling it for execution by the target event handler.

Specified by:
handle in interface EventListener
Parameters:
event - The event to schedule

newProcessingScheduler

protected EventProcessingScheduler newProcessingScheduler(org.axonframework.eventhandling.EventProcessingScheduler.ShutdownCallback shutDownCallback)
Creates a new scheduler instance for the eventListener that schedules events on the executor service for the managed EventListener.

Parameters:
shutDownCallback - The callback that needs to be notified when the scheduler stops processing.
Returns:
a new scheduler instance

newProcessingScheduler

protected EventProcessingScheduler newProcessingScheduler(Queue<Event> eventQueue,
                                                          org.axonframework.eventhandling.EventProcessingScheduler.ShutdownCallback shutDownCallback)
Creates a new scheduler instance for the eventListener that schedules events on the executor service for the managed EventListener. The Scheduler must get events from the given eventQueue.

Parameters:
eventQueue - The event queue from which the scheduler must fetch events
shutDownCallback - The callback that needs to be notified when the scheduler stops processing.
Returns:
a new scheduler instance

getTarget

public Object getTarget()
Description copied from interface: EventListenerProxy
Returns the instance that this proxy delegates all event handling to

Specified by:
getTarget in interface EventListenerProxy
Returns:
the instance that this proxy delegates all event handling to


Copyright © 2011. All Rights Reserved.