org.keridwen.core.messaging.internal
Class CoreEventDispatcher

java.lang.Object
  extended by org.keridwen.core.messaging.internal.CoreEventDispatcher
All Implemented Interfaces:
EventDispatcher

public final class CoreEventDispatcher
extends Object
implements EventDispatcher

This class provides a default implementation of an EventDispatcher.


Method Summary
 void clean()
          Removes all registered BundleControllers and EventDispatchers.
static EventDispatcher getInstance()
          Returns the singleton instance of the event dispatcher.
 boolean isEventRegistered(Event<?,?> event)
           
 void registerBundle(BundleController controller)
          Registers the given BundleController to be called on Event dispatch.
 void registerEventDispatcher(EventDispatcher dispatcher)
          Registers the given EventDispatcher to be called on Event dispatch.
 void terminate()
          Terminates all threads running in the registred controllers.
<ReturnType>
Supervisor<ReturnType>
triggerChangeEvent(Event<ReturnType,?> event, Condition condition)
          Triggers the given Event that will trigger the command execution as soon as the change Condition becomes true.
<ReturnType>
Supervisor<ReturnType>
triggerEvent(Event<ReturnType,?> event)
          Triggers the given Event asynchronously.
<ReturnType>
Supervisor<ReturnType>
triggerEvent(Event<ReturnType,?> event, int nbThreads)
           
<ReturnType>
Supervisor<ReturnType>
triggerTimeEvent(Event<ReturnType,?> event, long delay, TimeUnit unit)
          Triggers the given Event after the given delay.
<ReturnType>
Supervisor<ReturnType>
triggerTimeEventAtFixedRate(Event<ReturnType,?> event, long initialDelay, long period, TimeUnit unit)
          Triggers the given Event after the given delay and at a given period.
<ReturnType>
Supervisor<ReturnType>
triggerTimeEventWithFixedDelay(Event<ReturnType,?> event, long initialDelay, long delay, TimeUnit unit)
          Triggers the given Event after the given delay with the given delay between two executions.
 void unregisterBundle(BundleController controller)
          Unregisters the given BundleController.
 void unregisterEventDispatcher(EventDispatcher dispatcher)
          Unregisters the given EventDispatcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static EventDispatcher getInstance()
Returns the singleton instance of the event dispatcher.

Returns:
the event dispatcher instance

registerEventDispatcher

public void registerEventDispatcher(EventDispatcher dispatcher)
Description copied from interface: EventDispatcher
Registers the given EventDispatcher to be called on Event dispatch.

Specified by:
registerEventDispatcher in interface EventDispatcher
Parameters:
dispatcher - the EventDispatcher to register

unregisterEventDispatcher

public void unregisterEventDispatcher(EventDispatcher dispatcher)
Description copied from interface: EventDispatcher
Unregisters the given EventDispatcher.

Specified by:
unregisterEventDispatcher in interface EventDispatcher
Parameters:
dispatcher - the EventDispatcher to unregister

registerBundle

public void registerBundle(BundleController controller)
Description copied from interface: EventDispatcher
Registers the given BundleController to be called on Event dispatch.

Specified by:
registerBundle in interface EventDispatcher
Parameters:
controller - the BundleController to register

unregisterBundle

public void unregisterBundle(BundleController controller)
Description copied from interface: EventDispatcher
Unregisters the given BundleController.

Specified by:
unregisterBundle in interface EventDispatcher
Parameters:
controller - the BundleController to unregister

clean

public void clean()
Description copied from interface: EventDispatcher
Removes all registered BundleControllers and EventDispatchers.

Specified by:
clean in interface EventDispatcher

triggerEvent

public <ReturnType> Supervisor<ReturnType> triggerEvent(Event<ReturnType,?> event)
Description copied from interface: EventDispatcher
Triggers the given Event asynchronously.

Specified by:
triggerEvent in interface EventDispatcher
Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
event - the event to trigger
Returns:
the command supervisor

triggerEvent

public <ReturnType> Supervisor<ReturnType> triggerEvent(Event<ReturnType,?> event,
                                                        int nbThreads)
Specified by:
triggerEvent in interface EventDispatcher

triggerChangeEvent

public <ReturnType> Supervisor<ReturnType> triggerChangeEvent(Event<ReturnType,?> event,
                                                              Condition condition)
Description copied from interface: EventDispatcher
Triggers the given Event that will trigger the command execution as soon as the change Condition becomes true.

Specified by:
triggerChangeEvent in interface EventDispatcher
Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
event - the event to trigger
condition - the Condition to watch
Returns:
the command supervisor

triggerTimeEvent

public <ReturnType> Supervisor<ReturnType> triggerTimeEvent(Event<ReturnType,?> event,
                                                            long delay,
                                                            TimeUnit unit)
Description copied from interface: EventDispatcher
Triggers the given Event after the given delay.

Specified by:
triggerTimeEvent in interface EventDispatcher
Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
event - the event to trigger
delay - the time from now to delay execution
unit - the time unit of the delay parameter
Returns:
the scheduled command supervisor

triggerTimeEventWithFixedDelay

public <ReturnType> Supervisor<ReturnType> triggerTimeEventWithFixedDelay(Event<ReturnType,?> event,
                                                                          long initialDelay,
                                                                          long delay,
                                                                          TimeUnit unit)
Description copied from interface: EventDispatcher
Triggers the given Event after the given delay with the given delay between two executions.

Specified by:
triggerTimeEventWithFixedDelay in interface EventDispatcher
Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
event - the event to trigger
initialDelay - the time from now to delay the first execution
delay - the delay between termination of one execution and the commencement of the next
unit - the time unit of the parameters
Returns:
the scheduled command supervisor

triggerTimeEventAtFixedRate

public <ReturnType> Supervisor<ReturnType> triggerTimeEventAtFixedRate(Event<ReturnType,?> event,
                                                                       long initialDelay,
                                                                       long period,
                                                                       TimeUnit unit)
Description copied from interface: EventDispatcher
Triggers the given Event after the given delay and at a given period.

Specified by:
triggerTimeEventAtFixedRate in interface EventDispatcher
Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
event - the event to trigger
initialDelay - the time from now to delay the first execution
period - the period between two consecutive executions
unit - the time unit of the parameters
Returns:
the scheduled command supervisor

terminate

public void terminate()
Description copied from interface: EventDispatcher
Terminates all threads running in the registred controllers.

Specified by:
terminate in interface EventDispatcher

isEventRegistered

public boolean isEventRegistered(Event<?,?> event)
Specified by:
isEventRegistered in interface EventDispatcher


Copyright © 2010-2013 Artenum. All Rights Reserved.