org.keridwen.core.messaging
Interface BundleController

All Known Implementing Classes:
DefaultBundleController

public interface BundleController

This interface defines the methods to be implemented by an BundleController. An event controller receives the Events raised by the application modules and executes the associated Command (s).


Method Summary
 void clean()
          Removes all registered Events/Commands associations.
 boolean containsEventKey(EventKey key)
          Checks whether the given key is registered in the controller.
 DataModel getApplicationModel()
          Gets the data model of the application.
 DataModel getBundleModel()
          Gets the data model of the bundle.
<ReturnType,MessageType>
Command<ReturnType,MessageType>
getCommandForEvent(Event<ReturnType,MessageType> event)
          Gets the Command (if any) associated with the given Event.
 void registerEvent(DefaultEventKey<?,?>... keyArray)
          Registers the given EventKey array.
 void registerEvent(String keyId, Class<? extends Command<?,?>> commandClass)
           
<ReturnType,MessageType>
ScheduledFuture<?>
runAfterDelay(Command<ReturnType,MessageType> command, MessageType message, long delay, TimeUnit unit)
          Runs the given Command after the given delay.
<ReturnType,MessageType>
Future<ReturnType>
runAsynchronously(Command<ReturnType,MessageType> command, MessageType message)
          Runs the given Command asynchronously.
<ReturnType,MessageType>
Future<ReturnType>
runAsynchronously(Command<ReturnType,MessageType> command, MessageType message, int nbThreads)
           
<ReturnType,MessageType>
ScheduledFuture<?>
runAtFixedRate(Command<ReturnType,MessageType> command, MessageType message, long initialDelay, long period, TimeUnit unit)
          Runs the gievn Command after the given delay and at a given period.
<ReturnType,MessageType>
Future<ReturnType>
runOnCondition(Command<ReturnType,MessageType> command, MessageType message, Condition condition)
          Runs the given Command as soon as the Condition becomes valid.
<ReturnType,MessageType>
ScheduledFuture<?>
runWithFixedDelay(Command<ReturnType,MessageType> command, MessageType message, long initialDelay, long delay, TimeUnit unit)
          Runs the given Command after the given delay with the given delay between two executions.
 void terminate()
          Terminates all threads running in the controller.
 void unregisterEvent(EventKey... keyArray)
          Unregisters the Command associated to the given EventKeys.
 

Method Detail

runAsynchronously

<ReturnType,MessageType> Future<ReturnType> runAsynchronously(Command<ReturnType,MessageType> command,
                                                              MessageType message)
Runs the given Command asynchronously.

Type Parameters:
ReturnType - type of the data returned by the command.
MessageType - type of the message to handle
Parameters:
command - the command to execute
message - the message to be handled by the command
Returns:
a future representing the pending completion of the command

runAsynchronously

<ReturnType,MessageType> Future<ReturnType> runAsynchronously(Command<ReturnType,MessageType> command,
                                                              MessageType message,
                                                              int nbThreads)

runOnCondition

<ReturnType,MessageType> Future<ReturnType> runOnCondition(Command<ReturnType,MessageType> command,
                                                           MessageType message,
                                                           Condition condition)
Runs the given Command as soon as the Condition becomes valid.

Type Parameters:
ReturnType - type of the data returned by the command.
MessageType - type of the message to handle
Parameters:
command - the command to execute
condition - the Condition to watch
message - the message to be handled by the command
Returns:
a future representing the pending completion of the command

runAfterDelay

<ReturnType,MessageType> ScheduledFuture<?> runAfterDelay(Command<ReturnType,MessageType> command,
                                                          MessageType message,
                                                          long delay,
                                                          TimeUnit unit)
Runs the given Command after the given delay.

Type Parameters:
ReturnType - type of the data returned by the command.
MessageType - type of the message to handle
Parameters:
command - the command to execute
message - the message to be handled by the command
delay - the time from now to delay execution
unit - the time unit of the delay parameter
Returns:
a scheduled future representing the pending completion of the scheduled command and whose get() method will return null upon completion

runWithFixedDelay

<ReturnType,MessageType> ScheduledFuture<?> runWithFixedDelay(Command<ReturnType,MessageType> command,
                                                              MessageType message,
                                                              long initialDelay,
                                                              long delay,
                                                              TimeUnit unit)
Runs the given Command after the given delay with the given delay between two executions.

Type Parameters:
ReturnType - type of the data returned by the command.
MessageType - type of the message to handle
Parameters:
command - the command to execute
message - the message to be handled by the command
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:
scheduled future representing the pending completion of the scheduled command

runAtFixedRate

<ReturnType,MessageType> ScheduledFuture<?> runAtFixedRate(Command<ReturnType,MessageType> command,
                                                           MessageType message,
                                                           long initialDelay,
                                                           long period,
                                                           TimeUnit unit)
Runs the gievn Command after the given delay and at a given period.

Type Parameters:
ReturnType - type of the data returned by the command.
MessageType - type of the message to handle
Parameters:
command - the command to execute
message - the message to be handled by the command
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:
scheduled future representing the pending completion of the scheduled command

registerEvent

void registerEvent(DefaultEventKey<?,?>... keyArray)
Registers the given EventKey array.

Parameters:
keyArray - the array of unique keys of the Events triggering an associated Commands

registerEvent

void registerEvent(String keyId,
                   Class<? extends Command<?,?>> commandClass)

unregisterEvent

void unregisterEvent(EventKey... keyArray)
Unregisters the Command associated to the given EventKeys.

Parameters:
keyArray - the unique keys of the Events triggering the associated Commands

clean

void clean()
Removes all registered Events/Commands associations.


getCommandForEvent

<ReturnType,MessageType> Command<ReturnType,MessageType> getCommandForEvent(Event<ReturnType,MessageType> event)
Gets the Command (if any) associated with the given Event.

Type Parameters:
ReturnType - the return type of the command
MessageType - the type of the message transported by the Event
Parameters:
event - the event
Returns:
the Command (if any)

containsEventKey

boolean containsEventKey(EventKey key)
Checks whether the given key is registered in the controller.

Parameters:
key - the event key to check
Returns:
true is the event key is registered

terminate

void terminate()
Terminates all threads running in the controller.


getApplicationModel

DataModel getApplicationModel()
Gets the data model of the application.

Returns:
the data model of the application

getBundleModel

DataModel getBundleModel()
Gets the data model of the bundle.

Returns:
the data model of the bundle


Copyright © 2010-2013 Artenum. All Rights Reserved.