org.keridwen.core.messaging
Class EventBuilder

java.lang.Object
  extended by org.keridwen.core.messaging.EventBuilder

public final class EventBuilder
extends Object

An EventBuilder is a helper class used to create and trigger Events.


Method Summary
static
<ReturnType,MessageType>
EventBuilder
event(Event event)
          Initializes the builder with the given event.
static
<ReturnType,MessageType>
EventBuilder
event(EventKey key, MessageType message)
          Builds an Event with the given key and message.
static
<ReturnType,MessageType>
EventBuilder
event(String keyId, MessageType message)
           
static EventBuilder getInstance()
          Gets the unique instance of the class.
 boolean isEventRegistered()
           
 void setDispatcher(EventDispatcher aDispatcher)
          Method used to set a different event dispatcher than the default one.
<ReturnType>
ReturnType
triggerCallEvent()
          Triggers the event synchronously.
<ReturnType>
Supervisor<ReturnType>
triggerChangeEvent(Condition condition)
          Triggers the event as soon as the change Condition becomes true.
<ReturnType>
Supervisor<ReturnType>
triggerSignalEvent()
          Triggers the event asynchronously.
<ReturnType>
Supervisor<ReturnType>
triggerSignalEvent(int i)
           
<ReturnType>
Supervisor<ReturnType>
triggerTimeEvent(long delay, TimeUnit unit)
          Triggers the event after the given delay.
<ReturnType>
Supervisor<ReturnType>
triggerTimeEventAtFixedDelay(long initialDelay, long delay, TimeUnit unit)
          Triggers the event after the given delay with the given delay between two executions.
<ReturnType>
Supervisor<ReturnType>
triggerTimeEventAtFixedRate(long initialDelay, long period, TimeUnit unit)
          Triggers the event after the given delay and at a given period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static EventBuilder getInstance()
Gets the unique instance of the class.

Returns:
the instance

setDispatcher

public void setDispatcher(EventDispatcher aDispatcher)
Method used to set a different event dispatcher than the default one.

Parameters:
aDispatcher - the dispatcher to set.

event

public static <ReturnType,MessageType> EventBuilder event(EventKey key,
                                                          MessageType message)
Builds an Event with the given key and message.

Type Parameters:
ReturnType - the type of the result returned by the command
MessageType - the type of the message sent by the event
Parameters:
key - the key of the event to trigger
message - the message to transmit
Returns:
the unique instance of the builder

event

public static <ReturnType,MessageType> EventBuilder event(String keyId,
                                                          MessageType message)

event

public static <ReturnType,MessageType> EventBuilder event(Event event)
Initializes the builder with the given event.

Parameters:
event - the event to set
Returns:
the unique instance of the builder

triggerCallEvent

public <ReturnType> ReturnType triggerCallEvent()
Triggers the event synchronously.

Type Parameters:
ReturnType - the type of the result returned by the command
Returns:
the result of the command

triggerChangeEvent

public <ReturnType> Supervisor<ReturnType> triggerChangeEvent(Condition condition)
Triggers the event as soon as the change Condition becomes true.

Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
condition - the Condition to watch
Returns:
the command result

triggerSignalEvent

public <ReturnType> Supervisor<ReturnType> triggerSignalEvent()
Triggers the event asynchronously.

Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Returns:
the command result

triggerSignalEvent

public <ReturnType> Supervisor<ReturnType> triggerSignalEvent(int i)

triggerTimeEvent

public <ReturnType> Supervisor<ReturnType> triggerTimeEvent(long delay,
                                                            TimeUnit unit)
Triggers the event after the given delay.

Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
delay - the time from now to delay execution
unit - the time unit of the delay parameter
Returns:
the command result

triggerTimeEventAtFixedDelay

public <ReturnType> Supervisor<ReturnType> triggerTimeEventAtFixedDelay(long initialDelay,
                                                                        long delay,
                                                                        TimeUnit unit)
Triggers the event after the given delay with the given delay between two executions.

Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
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:
a future object to allow cancellation of the recursive call

triggerTimeEventAtFixedRate

public <ReturnType> Supervisor<ReturnType> triggerTimeEventAtFixedRate(long initialDelay,
                                                                       long period,
                                                                       TimeUnit unit)
Triggers the event after the given delay and at a given period.

Type Parameters:
ReturnType - type of the data returned by the command triggered by the event.
Parameters:
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:
a future object to allow cancellation of the recursive call

isEventRegistered

public boolean isEventRegistered()


Copyright © 2010-2013 Artenum. All Rights Reserved.