jadex.application.space.envsupport.environment
Class ComponentActionList

java.lang.Object
  extended by jadex.application.space.envsupport.environment.ComponentActionList

public class ComponentActionList
extends Object

The list of scheduled component actions and convenience methods for executing selected actions. This implementation is not thread-safe, i.e. methods should only be called from threads that are already synchronized with the environment space monitor.


Nested Class Summary
static class ComponentActionList.ActionEntry
          Entry for a scheduled action.
 
Field Summary
protected  Set actions
          The scheduled actions.
protected  ICommand cmd
          The schedule command.
protected  Collection executed
          The executed actions where actors still need to be woken up.
protected  IEnvironmentSpace space
          The environment space.
 
Constructor Summary
ComponentActionList(IEnvironmentSpace space)
          Create a new action list.
 
Method Summary
 void addComponentAction(ComponentActionList.ActionEntry entry)
          Add an component action.
 void executeActions(IFilter filter, boolean wakeup)
          Should be called on environment thread only.
 ComponentActionList.ActionEntry[] getActionEntries()
          Get the queued entries, which have not yet been executed.
 void removeComponentAction(ComponentActionList.ActionEntry entry)
          Remove an component action.
 void scheduleComponentAction(ISpaceAction action, Map parameters, IResultListener listener)
          Schedules an component action.
 void setOrdering(Comparator comp)
          Set an ordering used for executing actions.
 void setScheduleCommand(ICommand cmd)
          Set the schedule command to be invoked, when an action should be scheduled.
 void wakeupComponents(IFilter filter)
          Should be called on environment thread only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

space

protected IEnvironmentSpace space
The environment space.


actions

protected Set actions
The scheduled actions.


executed

protected Collection executed
The executed actions where actors still need to be woken up.


cmd

protected ICommand cmd
The schedule command.

Constructor Detail

ComponentActionList

public ComponentActionList(IEnvironmentSpace space)
Create a new action list.

Method Detail

scheduleComponentAction

public void scheduleComponentAction(ISpaceAction action,
                                    Map parameters,
                                    IResultListener listener)
Schedules an component action.

Parameters:
action - The action.
parameters - parameters for the action (may be null)
listener - the result listener

addComponentAction

public void addComponentAction(ComponentActionList.ActionEntry entry)
Add an component action.

Parameters:
entry - The action entry.

removeComponentAction

public void removeComponentAction(ComponentActionList.ActionEntry entry)
Remove an component action.

Parameters:
entry - The action entry.

getActionEntries

public ComponentActionList.ActionEntry[] getActionEntries()
Get the queued entries, which have not yet been executed.


setOrdering

public void setOrdering(Comparator comp)
Set an ordering used for executing actions.

Parameters:
comp - The comparator representing the ordering.

executeActions

public void executeActions(IFilter filter,
                           boolean wakeup)
Should be called on environment thread only.

Parameters:
filter - A filter to select only a subset of actions (or null for all actions).
wakeup - Immediately wake up each calling component after its action has been executed (otherwise wakeupComponents() has to be called separately).

wakeupComponents

public void wakeupComponents(IFilter filter)
Should be called on environment thread only.

Parameters:
filter - A filter to select only a subset of actions (or null for all actions). (otherwise wakeupComponents() has to be called separately).

setScheduleCommand

public void setScheduleCommand(ICommand cmd)
Set the schedule command to be invoked, when an action should be scheduled. Per default, an action is added to the list, but custom commands might decide to execute action immediately or alter the list in arbitrary ways. The command parameter is of type ActionEntry.



Copyright © 2010. All Rights Reserved.