Class ComponentActionList
- java.lang.Object
-
- jadex.extension.envsupport.environment.ComponentActionList
-
public class ComponentActionList extends java.lang.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
Nested Classes Modifier and Type Class Description static class
ComponentActionList.ActionEntry
Entry for a scheduled action.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<ComponentActionList.ActionEntry>
actions
The scheduled actions.protected ICommand
cmd
The schedule command.protected java.util.Collection<ComponentActionList.ActionEntry>
executed
The executed actions where actors still need to be woken up.protected IEnvironmentSpace
space
The environment space.
-
Constructor Summary
Constructors Constructor Description ComponentActionList(IEnvironmentSpace space)
Create a new action list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComponentAction(ComponentActionList.ActionEntry entry)
Add an component action.void
cancelComponentAction(int id)
Cancels a 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.int
scheduleComponentAction(ISpaceAction action, java.util.Map parameters, IResultListener listener)
Schedules an component action.void
setOrdering(java.util.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.
-
-
-
Field Detail
-
space
protected IEnvironmentSpace space
The environment space.
-
actions
protected java.util.Set<ComponentActionList.ActionEntry> actions
The scheduled actions.
-
executed
protected java.util.Collection<ComponentActionList.ActionEntry> 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 int scheduleComponentAction(ISpaceAction action, java.util.Map parameters, IResultListener listener)
Schedules an component action.- Parameters:
action
- The action.parameters
- parameters for the action (may be null)listener
- the result listener
-
cancelComponentAction
public void cancelComponentAction(int id)
Cancels a component action.
-
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(java.util.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.
-
-