|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.sposh.executor.BehaviorWorkExecutor
public class BehaviorWorkExecutor
Executor for posh plans that will execute annotated methods on the object.
You put behavior objects into thisIWorkExecutor
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.
Nested Class Summary | |
---|---|
protected class |
BehaviorWorkExecutor.BehaviorMethod
Class for storing methods that can be executed as primitives. |
Field Summary | |
---|---|
protected List<JavaBehaviour> |
behaviors
|
protected HashMap<String,BehaviorWorkExecutor.BehaviorMethod> |
primitives
Map that maps name of primitives into behavior methods. |
Constructor Summary | |
---|---|
BehaviorWorkExecutor()
Create BehaviorWorkExecutor with no methods. |
|
BehaviorWorkExecutor(JavaBehaviour behavior)
Create BehaviorWorkExecutor with primitives from behavior. |
Method Summary | |
---|---|
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)
Uses executePrimitive(String, VariableContext) . |
Object |
executeSense(String primitive,
VariableContext ctx)
Uses executePrimitive(String, VariableContext) . |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final HashMap<String,BehaviorWorkExecutor.BehaviorMethod> primitives
protected List<JavaBehaviour> behaviors
Constructor Detail |
---|
public BehaviorWorkExecutor()
public BehaviorWorkExecutor(JavaBehaviour behavior)
behavior
- object from which we will add primitives into this worker.Method Detail |
---|
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)
executePrimitive(String, VariableContext)
.
executeSense
in interface IWorkExecutor
primitive
- name of primitivectx
- variable context for sense containing possible parameters
public ActionResult executeAction(String primitive, VariableContext ctx)
executePrimitive(String, VariableContext)
.
executeAction
in interface IWorkExecutor
primitive
- name of primitivectx
- variable context for action containing possible parameters
public void logicAfterPlan()
ILogicWorkExecutor
logicAfterPlan
in interface ILogicWorkExecutor
public void logicBeforePlan()
ILogicWorkExecutor
logicBeforePlan
in interface ILogicWorkExecutor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |