Jadex 0.96-beta1

jadex.runtime
Class JavaStandardPlanExecutor

java.lang.Object
  extended by jadex.runtime.JavaStandardPlanExecutor
All Implemented Interfaces:
IPlanExecutor, Serializable

public class JavaStandardPlanExecutor
extends Object
implements IPlanExecutor, Serializable

A plan executor for plans that run on their own thread and therefore may perform blocking wait operations. Plan bodies have to inherit from @link{Plan}.

See Also:
Serialized Form

Nested Class Summary
static class JavaStandardPlanExecutor.BodyAborted
          An error thrown to abort the execution of the plan body.
static class JavaStandardPlanExecutor.PlanTerminated
          An error allowing the agent to terminate the execution of a plan.
 
Field Summary
static String MAX_PLANSTEP_TIME
           
static int n
           
 
Constructor Summary
JavaStandardPlanExecutor(jadex.runtime.impl.RBDIAgent agent)
          Create a new threadbased plan executor.
 
Method Summary
 void cleanup(jadex.runtime.impl.RPlan rplan)
          Called on termination of a plan.
 Object createPlanBody(jadex.runtime.impl.RPlan plan)
          Create the body of a plan.
 jadex.runtime.impl.IREvent eventWaitFor(jadex.runtime.impl.RPlan rplan, jadex.runtime.impl.WaitAbstraction wa)
          Called from a plan.
 boolean executeAbortedStep(jadex.runtime.impl.RPlan plan)
          Execute a step of the plans aborted() code.
 boolean executeFailedStep(jadex.runtime.impl.RPlan plan)
          Execute a step of the plans failed() code.
 boolean executePassedStep(jadex.runtime.impl.RPlan plan)
          Execute a step of the plans passed() code.
 boolean executePlanStep(jadex.runtime.impl.RPlan plan)
          Execute a step of a plan.
 boolean executeStep(jadex.runtime.impl.RPlan plan, String steptype)
          Execute a step of a plan.
 Thread getExecutionThread(jadex.runtime.impl.RPlan rplan)
          Get the executing thread of a plan.
 void interruptPlanStep(jadex.runtime.impl.RPlan plan)
          Interrupt a plan step during execution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PLANSTEP_TIME

public static final String MAX_PLANSTEP_TIME
See Also:
Constant Field Values

n

public static int n
Constructor Detail

JavaStandardPlanExecutor

public JavaStandardPlanExecutor(jadex.runtime.impl.RBDIAgent agent)
Create a new threadbased plan executor.

Method Detail

createPlanBody

public Object createPlanBody(jadex.runtime.impl.RPlan plan)
                      throws Exception
Create the body of a plan.

Specified by:
createPlanBody in interface IPlanExecutor
Parameters:
plan - The plan.
Returns:
The created body. May throw any kind of exception, when the body creation fails
Throws:
Exception

executeStep

public boolean executeStep(jadex.runtime.impl.RPlan plan,
                           String steptype)
                    throws Exception
Execute a step of a plan. Executing a step should cause the latest event to be handled. Will be called by the scheduler for every event to be handled. May throw any kind of exception, when the plan execution fails

Returns:
True, if the plan step was interrupted (interrupted flag).
Throws:
Exception

executePlanStep

public boolean executePlanStep(jadex.runtime.impl.RPlan plan)
                        throws Exception
Execute a step of a plan. Executing a step should cause the latest event to be handled. Will be called by the scheduler for every event to be handled. May throw any kind of exception, when the plan execution fails

Specified by:
executePlanStep in interface IPlanExecutor
Returns:
True, if plan was interrupted (micro plan step).
Throws:
Exception

executePassedStep

public boolean executePassedStep(jadex.runtime.impl.RPlan plan)
                          throws Exception
Execute a step of the plans passed() code. This method is called, after the plan has finished successfully (i.e. without exception). Will be called by the scheduler for the first time and every subsequent event to be handled. May throw any kind of exception, when the execution fails

Specified by:
executePassedStep in interface IPlanExecutor
Returns:
True, if execution was interrupted (micro plan step).
Throws:
Exception

executeFailedStep

public boolean executeFailedStep(jadex.runtime.impl.RPlan plan)
                          throws Exception
Execute a step of the plans failed() code. This method is called, when the plan has failed (i.e. due to an exception occurring in the plan body). Will be called by the scheduler for the first time and every subsequent event to be handled. May throw any kind of exception, when the execution fails

Specified by:
executeFailedStep in interface IPlanExecutor
Returns:
True, if execution was interrupted (micro plan step).
Throws:
Exception

executeAbortedStep

public boolean executeAbortedStep(jadex.runtime.impl.RPlan plan)
                           throws Exception
Execute a step of the plans aborted() code. This method is called, when the plan is terminated from the outside (e.g. when the corresponding goal is dropped or the context condition of the plan becomes invalid) Will be called by the scheduler for the first time and every subsequent event to be handled. May throw any kind of exception, when the execution fails

Specified by:
executeAbortedStep in interface IPlanExecutor
Returns:
True, if execution was interrupted (micro plan step).
Throws:
Exception

interruptPlanStep

public void interruptPlanStep(jadex.runtime.impl.RPlan plan)
Interrupt a plan step during execution. The plan is requested to stop the execution to allow consequences of performed plan actions (like belief changes) taking place. If the method is not implemented the plan step will be NOT be interrupted.

Specified by:
interruptPlanStep in interface IPlanExecutor

cleanup

public void cleanup(jadex.runtime.impl.RPlan rplan)
Called on termination of a plan. Free all associated ressources, stop threads, etc.

Specified by:
cleanup in interface IPlanExecutor

getExecutionThread

public Thread getExecutionThread(jadex.runtime.impl.RPlan rplan)
Get the executing thread of a plan.

Specified by:
getExecutionThread in interface IPlanExecutor
Parameters:
rplan - The plan.
Returns:
The executing thread (if any).

eventWaitFor

public jadex.runtime.impl.IREvent eventWaitFor(jadex.runtime.impl.RPlan rplan,
                                               jadex.runtime.impl.WaitAbstraction wa)
Called from a plan. Registers the plan to wait for a event. Blocks plan when body method is finished. Note: This method cannot be synchronized, because when a thread comes in and waits it still owns the BDIAgent lock.

Specified by:
eventWaitFor in interface IPlanExecutor
Parameters:
rplan - The planinstance.
wa - The wait abstraction.

Jadex 0.96-beta1

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.