public class ExecutionComponentFeature extends AbstractComponentFeature implements IExecutionFeature, IInternalExecutionFeature, jadex.commons.concurrent.IExecutable
Modifier and Type | Class and Description |
---|---|
static class |
ExecutionComponentFeature.ExecuteWaitForStep
Step to execute a wait for entry.
|
static class |
ExecutionComponentFeature.StepInfo
Info struct for steps.
|
protected class |
ExecutionComponentFeature.TimerWrapper
Wrap a timer and remove it from the agent when it is cancelled.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
available
Flag to indicate that the execution service has become available during bootstrapping (only for platform, hack???).
|
protected java.util.Map<java.lang.Object,jadex.commons.concurrent.Executor> |
blocked
The blocked threads by monitor.
|
protected boolean |
bootstrap
Flag to indicate bootstrapping execution of main thread (only for platform, hack???).
|
protected int |
bpstepid
The id of the step at which the execution was stopped because of a breakpoint.
|
protected java.lang.Thread |
componentthread
The thread currently executing the component (null for none).
|
static boolean |
DEBUG
Debug flag.
|
protected jadex.commons.future.Future<java.lang.Void> |
endagenda
Future for signalling that end of agenda execution has been reached.
|
protected int |
endstepcnt
The step at which the endstate begins.
|
protected boolean |
executing
Flag for testing double execution.
|
protected java.util.List<jadex.commons.Tuple2<jadex.commons.future.Future<?>,jadex.commons.future.IResultListener<?>>> |
notifications
Retained listener notifications when switching threads due to blocking.
|
protected IInternalExecutionFeature |
parenta
The parent adapter (cached for speed).
|
protected java.util.Map<IComponentStep<?>,java.lang.Exception> |
stepadditions |
protected int |
stepcnt
The stepcnt - used to keep insertion order of same priority elements in the queue.
|
protected jadex.commons.future.Future<java.lang.Void> |
stepfuture
The future to be informed, when the requested step is finished.
|
protected java.lang.String |
stepinfo
The flag for a requested step (true when a step is allowed in stepwise execution).
|
protected java.util.TreeSet<ExecutionComponentFeature.StepInfo> |
steps
The component steps.
|
protected java.util.Set<IInternalExecutionFeature> |
subcomponents
The synchronous subcomponents that want to be executed (if any).
|
protected java.util.List<ITimer> |
timers
The current timer.
|
static java.lang.String |
TYPE_STEP
Constant for step event.
|
cinfo, component, guesser
STEP_PRIORITY_IMMEDIATE, STEP_PRIORITY_NOMRAL
LOCAL
Constructor and Description |
---|
ExecutionComponentFeature(IInternalAccess component,
ComponentCreationInfo cinfo)
Create the feature.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addStep(ExecutionComponentFeature.StepInfo step)
Add a new step.
|
void |
addSubcomponent(IInternalExecutionFeature sub)
Add a synchronous subcomponent that will run on its parent's thread.
|
protected void |
afterBlock()
Called after unblocking the component thread.
|
protected void |
beforeBlock()
Called before blocking the component thread.
|
void |
block(java.lang.Object monitor,
long timeout)
Block the current thread and allow execution on other threads.
|
IComponentFeature |
createInstance(IInternalAccess access,
ComponentCreationInfo info)
Create an instance of the feature.
|
<T> jadex.commons.future.IIntermediateResultListener<T> |
createResultListener(jadex.commons.future.IIntermediateResultListener<T> listener)
Create a result listener that is executed on the
component thread.
|
<T> jadex.commons.future.IResultListener<T> |
createResultListener(jadex.commons.future.IResultListener<T> listener)
Create a result listener that is executed on the
component thread.
|
protected <T> jadex.commons.future.Future<T> |
createStepFuture(IComponentStep<T> step)
Create intermediate of direct future.
|
jadex.commons.future.IFuture<java.lang.Void> |
doStep(java.lang.String stepinfo)
Do a step of a suspended component.
|
boolean |
execute()
Execute the executable.
|
protected boolean |
executeCycle()
Components with autonomous behavior may override this method
to implement a recurring execution cycle.
|
java.util.List<IMonitoringEvent> |
getCurrentStateEvents()
Get the current state as events.
|
java.util.List<ExecutionComponentFeature.StepInfo> |
getCurrentSteps()
Get the current steps.
|
int |
getEndstateStart()
Get the step number when endstate began.
|
java.util.Map<java.lang.String,java.lang.String> |
getStepDetails(ExecutionComponentFeature.StepInfo step)
Get the details of a step.
|
java.lang.Class<?> |
getType()
Get the user interface type of the feature.
|
boolean |
isAtBreakpoint(java.lang.String[] breakpoints)
Test if the agent's execution is currently at one of the
given breakpoints.
|
boolean |
isComponentThread()
Test if current thread is the component thread.
|
void |
publishStepEvent(ExecutionComponentFeature.StepInfo step,
java.lang.String type)
Publish a step event.
|
protected ExecutionComponentFeature.StepInfo |
removeStep()
Remove a new step.
|
void |
removeSubcomponent(IInternalExecutionFeature sub)
Remove a synchronous subcomponent.
|
<T> jadex.commons.future.ISubscriptionIntermediateFuture<T> |
repeatStep(long initialDelay,
long delay,
IComponentStep<T> step)
Repeats a ComponentStep periodically, until terminate() is called on result future or a failure occurs in a step.
|
<T> jadex.commons.future.ISubscriptionIntermediateFuture<T> |
repeatStep(long initialDelay,
long delay,
IComponentStep<T> step,
boolean ignorefailures)
Repeats a ComponentStep periodically, until terminate() is called on result future.
|
<T> jadex.commons.future.IFuture<T> |
scheduleStep(IComponentStep<T> step)
Execute a component step.
|
<T> jadex.commons.future.IFuture<T> |
scheduleStep(int priority,
IComponentStep<T> step)
Execute a component step.
|
jadex.commons.future.IFuture<java.lang.Void> |
shutdown()
Shutdown the feature.
|
boolean |
testIfBreakpoint(java.lang.String[] breakpoints)
Kernel specific test if the step is a breakpoint.
|
void |
unblock(java.lang.Object monitor,
java.lang.Throwable exception)
Unblock the thread waiting for the given monitor
and cease execution on the current thread.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitForDelay(long delay)
Wait for some time.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitForDelay(long delay,
boolean realtime)
Wait for some time.
|
<T> jadex.commons.future.IFuture<T> |
waitForDelay(long delay,
IComponentStep<T> step)
Wait for some time and execute a component step afterwards.
|
<T> jadex.commons.future.IFuture<T> |
waitForDelay(long delay,
IComponentStep<T> step,
boolean realtime)
Wait for some time and execute a component step afterwards.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitForTick()
Wait for the next tick.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitForTick(IComponentStep<java.lang.Void> run)
Wait for the next tick.
|
void |
wakeup()
Trigger component execution.
|
body, getComponent, getExternalFacade, getExternalFacadeType, getParameterGuesser, getValueFetcher, init
public static boolean DEBUG
public static final java.lang.String TYPE_STEP
protected java.util.TreeSet<ExecutionComponentFeature.StepInfo> steps
protected int stepcnt
protected int bpstepid
protected int endstepcnt
protected java.util.List<ITimer> timers
protected java.util.List<jadex.commons.Tuple2<jadex.commons.future.Future<?>,jadex.commons.future.IResultListener<?>>> notifications
protected volatile boolean executing
protected java.lang.Thread componentthread
protected java.util.Map<java.lang.Object,jadex.commons.concurrent.Executor> blocked
protected java.lang.String stepinfo
protected jadex.commons.future.Future<java.lang.Void> stepfuture
protected IInternalExecutionFeature parenta
protected java.util.Set<IInternalExecutionFeature> subcomponents
protected jadex.commons.future.Future<java.lang.Void> endagenda
protected java.util.Map<IComponentStep<?>,java.lang.Exception> stepadditions
protected volatile boolean bootstrap
protected volatile boolean available
public ExecutionComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo)
public jadex.commons.future.IFuture<java.lang.Void> shutdown()
shutdown
in interface IComponentFeature
shutdown
in class AbstractComponentFeature
public java.lang.Class<?> getType()
public IComponentFeature createInstance(IInternalAccess access, ComponentCreationInfo info)
public <T> jadex.commons.future.IFuture<T> scheduleStep(IComponentStep<T> step)
scheduleStep
in interface IExecutionFeature
step
- The component step.public <T> jadex.commons.future.IFuture<T> scheduleStep(int priority, IComponentStep<T> step)
scheduleStep
in interface IExecutionFeature
step
- The component step.priority
- The step priority (0 is default).public <T> jadex.commons.future.ISubscriptionIntermediateFuture<T> repeatStep(long initialDelay, long delay, IComponentStep<T> step)
repeatStep
in interface IExecutionFeature
initialDelay
- delay before first execution in millisecondsdelay
- delay between scheduled executions of the step in millisecondsstep
- The component steppublic <T> jadex.commons.future.ISubscriptionIntermediateFuture<T> repeatStep(long initialDelay, long delay, IComponentStep<T> step, boolean ignorefailures)
repeatStep
in interface IExecutionFeature
initialDelay
- delay before first execution in millisecondsdelay
- delay between scheduled executions of the step in millisecondsstep
- The component stepignorefailures
- Don't terminate repeating after a failed step.public <T> jadex.commons.future.IFuture<T> waitForDelay(long delay, IComponentStep<T> step)
waitForDelay
in interface IExecutionFeature
public <T> jadex.commons.future.IFuture<T> waitForDelay(long delay, IComponentStep<T> step, boolean realtime)
waitForDelay
in interface IExecutionFeature
public jadex.commons.future.IFuture<java.lang.Void> waitForDelay(long delay)
waitForDelay
in interface IExecutionFeature
public jadex.commons.future.IFuture<java.lang.Void> waitForDelay(long delay, boolean realtime)
waitForDelay
in interface IExecutionFeature
public jadex.commons.future.IFuture<java.lang.Void> waitForTick(IComponentStep<java.lang.Void> run)
waitForTick
in interface IExecutionFeature
time
- The time.public jadex.commons.future.IFuture<java.lang.Void> waitForTick()
waitForTick
in interface IExecutionFeature
time
- The time.public void wakeup()
wakeup
in interface IInternalExecutionFeature
public jadex.commons.future.IFuture<java.lang.Void> doStep(java.lang.String stepinfo)
doStep
in interface IInternalExecutionFeature
public boolean isComponentThread()
isComponentThread
in interface IExecutionFeature
public <T> jadex.commons.future.IResultListener<T> createResultListener(jadex.commons.future.IResultListener<T> listener)
createResultListener
in interface IExecutionFeature
public <T> jadex.commons.future.IIntermediateResultListener<T> createResultListener(jadex.commons.future.IIntermediateResultListener<T> listener)
createResultListener
in interface IExecutionFeature
public void addSubcomponent(IInternalExecutionFeature sub)
addSubcomponent
in interface IInternalExecutionFeature
sub
- The subcomponent.public void removeSubcomponent(IInternalExecutionFeature sub)
removeSubcomponent
in interface IInternalExecutionFeature
sub
- The subcomponent.public void block(java.lang.Object monitor, long timeout)
block
in interface IInternalExecutionFeature
monitor
- The monitor to wait for.public void unblock(java.lang.Object monitor, java.lang.Throwable exception)
unblock
in interface IInternalExecutionFeature
monitor
- The monitor to notify.protected void beforeBlock()
protected void afterBlock()
public boolean execute()
execute
in interface IInternalExecutionFeature
execute
in interface jadex.commons.concurrent.IExecutable
protected boolean executeCycle()
protected <T> jadex.commons.future.Future<T> createStepFuture(IComponentStep<T> step)
protected void addStep(ExecutionComponentFeature.StepInfo step)
protected ExecutionComponentFeature.StepInfo removeStep()
public void publishStepEvent(ExecutionComponentFeature.StepInfo step, java.lang.String type)
public java.util.Map<java.lang.String,java.lang.String> getStepDetails(ExecutionComponentFeature.StepInfo step)
public java.util.List<ExecutionComponentFeature.StepInfo> getCurrentSteps()
public java.util.List<IMonitoringEvent> getCurrentStateEvents()
public boolean isAtBreakpoint(java.lang.String[] breakpoints)
breakpoints
- An array of breakpoints.public boolean testIfBreakpoint(java.lang.String[] breakpoints)
public int getEndstateStart()
getEndstateStart
in interface IInternalExecutionFeature