|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.keridwen.core.messaging.DefaultBundleController
public class DefaultBundleController
This abstract class defines the default behaviour of a BundleController
. Each bundle then has to
implement how the controller deals with the model.
Constructor Summary | |
---|---|
DefaultBundleController(DataModel applicationModel,
DataModel bundleModel)
Creates a bundle controller for the given application data model and bundle data model. |
Method Summary | ||
---|---|---|
void |
clean()
Removes all registered Event s/Command s 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. |
|
|
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)
|
|
|
runAfterDelay(Command<ReturnType,MessageType> command,
MessageType message,
long delay,
TimeUnit unit)
Runs the given Command after the given delay. |
|
|
runAsynchronously(Command<ReturnType,MessageType> command,
MessageType message)
Runs the given Command asynchronously. |
|
|
runAsynchronously(Command<ReturnType,MessageType> command,
MessageType message,
int nbThreads)
|
|
|
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. |
|
|
runOnCondition(Command<ReturnType,MessageType> command,
MessageType message,
Condition condition)
Runs the given Command as soon as the Condition becomes valid. |
|
|
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 EventKey s. |
|
void |
validityChanged(Condition condition,
boolean validity)
Method called when the validity of a Condition has changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultBundleController(DataModel applicationModel, DataModel bundleModel)
applicationModel
- the application data modelbundleModel
- the bundle data modelMethod Detail |
---|
public void registerEvent(DefaultEventKey<?,?>... keyArray)
BundleController
EventKey
array.
registerEvent
in interface BundleController
keyArray
- the array of unique keys of the Event
s triggering an associated Command
spublic void registerEvent(String keyId, Class<? extends Command<?,?>> commandClass)
registerEvent
in interface BundleController
public void unregisterEvent(EventKey... keyArray)
BundleController
Command
associated to the given EventKey
s.
unregisterEvent
in interface BundleController
keyArray
- the unique keys of the Event
s triggering the associated Command
spublic final void clean()
BundleController
Event
s/Command
s associations.
clean
in interface BundleController
public final boolean containsEventKey(EventKey key)
BundleController
containsEventKey
in interface BundleController
key
- the event key to check
public <ReturnType,MessageType> Command<ReturnType,MessageType> getCommandForEvent(Event<ReturnType,MessageType> event)
BundleController
Command
(if any) associated with the given Event
.
getCommandForEvent
in interface BundleController
ReturnType
- the return type of the commandMessageType
- the type of the message transported by the Event
event
- the event
Command
(if any)public final <ReturnType,MessageType> Future<ReturnType> runAsynchronously(Command<ReturnType,MessageType> command, MessageType message)
BundleController
Command
asynchronously.
runAsynchronously
in interface BundleController
ReturnType
- type of the data returned by the command.MessageType
- type of the message to handlecommand
- the command to executemessage
- the message to be handled by the command
public final <ReturnType,MessageType> Future<ReturnType> runAsynchronously(Command<ReturnType,MessageType> command, MessageType message, int nbThreads)
runAsynchronously
in interface BundleController
public final <ReturnType,MessageType> Future<ReturnType> runOnCondition(Command<ReturnType,MessageType> command, MessageType message, Condition condition)
BundleController
Command
as soon as the Condition
becomes valid.
runOnCondition
in interface BundleController
ReturnType
- type of the data returned by the command.MessageType
- type of the message to handlecommand
- the command to executemessage
- the message to be handled by the commandcondition
- the Condition
to watch
public final void validityChanged(Condition condition, boolean validity)
ConditionListener
Condition
has changed.
validityChanged
in interface ConditionListener
condition
- the watched condition.validity
- the new validity of the condition.public final <ReturnType,MessageType> ScheduledFuture<?> runAfterDelay(Command<ReturnType,MessageType> command, MessageType message, long delay, TimeUnit unit)
BundleController
Command
after the given delay.
runAfterDelay
in interface BundleController
ReturnType
- type of the data returned by the command.MessageType
- type of the message to handlecommand
- the command to executemessage
- the message to be handled by the commanddelay
- the time from now to delay executionunit
- the time unit of the delay parameter
public final <ReturnType,MessageType> ScheduledFuture<?> runWithFixedDelay(Command<ReturnType,MessageType> command, MessageType message, long initialDelay, long delay, TimeUnit unit)
BundleController
Command
after the given delay with the given delay between two executions.
runWithFixedDelay
in interface BundleController
ReturnType
- type of the data returned by the command.MessageType
- type of the message to handlecommand
- the command to executemessage
- the message to be handled by the commandinitialDelay
- the time from now to delay the first executiondelay
- the delay between termination of one execution and the commencement of the nextunit
- the time unit of the parameters
public final <ReturnType,MessageType> ScheduledFuture<?> runAtFixedRate(Command<ReturnType,MessageType> command, MessageType message, long initialDelay, long period, TimeUnit unit)
BundleController
Command
after the given delay and at a given period.
runAtFixedRate
in interface BundleController
ReturnType
- type of the data returned by the command.MessageType
- type of the message to handlecommand
- the command to executemessage
- the message to be handled by the commandinitialDelay
- the time from now to delay the first executionperiod
- the period between two consecutive executionsunit
- the time unit of the parameters
public final void terminate()
BundleController
terminate
in interface BundleController
public final DataModel getApplicationModel()
BundleController
getApplicationModel
in interface BundleController
public final DataModel getBundleModel()
BundleController
getBundleModel
in interface BundleController
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |