public class BehaviorWorkExecutor extends Object implements ILogicWorkExecutor
IWorkExecutor that have some methods
annotated with SPOSHAction or SPOSHSense. Names of these methods
are used stored as primitives. There can't be two behavior methods with same
names, (e.g. testMethod() from behavior object A and testMethod() from object B or
testMethod(String) from object A). If such sitation occurs,
BehaviorWorkExecutor#addBehavior(java.lang.Object) will throw
IllegalArgumentException.
When PoshEngine asks to execute some primitive, this executor will look
in list of primitives it is capable to execute (names of annotated methods
from behavior objects) and if it has some behavior method with same name, it executed it
and returns value.| Modifier and Type | Class and Description |
|---|---|
protected class |
BehaviorWorkExecutor.BehaviorMethod
Class for storing methods that can be executed as primitives.
|
| Modifier and Type | Field and Description |
|---|---|
protected List<JavaBehaviour> |
behaviors |
protected HashMap<String,BehaviorWorkExecutor.BehaviorMethod> |
primitives
Map that maps name of primitives into behavior methods.
|
| Constructor and Description |
|---|
BehaviorWorkExecutor()
Create BehaviorWorkExecutor with no methods.
|
BehaviorWorkExecutor(JavaBehaviour behavior)
Create BehaviorWorkExecutor with primitives from behavior.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBehavior(JavaBehaviour behavior)
Take the behavior object, find its methods annotated with either
SPOSHAction or SPOSHSense and add them as primitives this
work executor can process. |
ActionResult |
executeAction(String primitive,
VariableContext ctx)
|
Object |
executeSense(String primitive,
VariableContext ctx)
|
void |
logicAfterPlan()
Method that is triggered every time the plan for executor is evaluated.
|
void |
logicBeforePlan()
Method that is triggered every time the plan for executor is evaluated.
|
protected final HashMap<String,BehaviorWorkExecutor.BehaviorMethod> primitives
protected List<JavaBehaviour> behaviors
public BehaviorWorkExecutor()
public BehaviorWorkExecutor(JavaBehaviour behavior)
behavior - object from which we will add primitives into this worker.public void addBehavior(JavaBehaviour behavior)
SPOSHAction or SPOSHSense and add them as primitives this
work executor can process.behavior - IllegalArgumentException - if behavior contains primitive method with same name, that is
already contained in primitives of this worker.public Object executeSense(String primitive, VariableContext ctx)
executeSense in interface IWorkExecutorprimitive - name of primitivectx - variable context for sense containing possible parameterspublic ActionResult executeAction(String primitive, VariableContext ctx)
executeAction in interface IWorkExecutorprimitive - name of primitivectx - variable context for action containing possible parameterspublic void logicAfterPlan()
ILogicWorkExecutorlogicAfterPlan in interface ILogicWorkExecutorpublic void logicBeforePlan()
ILogicWorkExecutorlogicBeforePlan in interface ILogicWorkExecutorCopyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.