01: package org.osbl.agent.model;
02:
03: import java.util.Hashtable;
04:
05: /**
06: * This class contains all relevant information that a Rule needs to access when its
07: * Conditions are evaluated and its Actions executed.
08: *
09: * One of the elemental objects that can be found in this class is the target
10: * instance for which the Conditions are evaluated and the Actions executed.
11: *
12: * Any other information found depends on the context.
13: *
14: * @see Condition#evaluate(RuleContext)
15: * @see Action#execute(RuleContext)
16: * @author Sebastian Nozzi.
17: */
18: public class RuleContext extends Hashtable<String, Object> {
19:
20: /** The Constant RUNTIME_OBJECT_CLASS (for the class of the target instance). */
21: public static final String RUNTIME_OBJECT_CLASS = "RUNTIME_OBJECT_CLASS";
22:
23: /** The Constant PROCESS_NAME_KEY (for a con:cern Process name). */
24: public static final String PROCESS_NAME_KEY = "process";
25:
26: /** The Constant ACTIVITY_NAME_KEY (for a con:cern Activity name). */
27: public static final String ACTIVITY_NAME_KEY = "activity";
28:
29: /** The Constant TARGET_INSTANCE (for the target instance, used by the methods below). */
30: private static final String TARGET_INSTANCE = "target";
31:
32: /** The Constant SUBJECT_ID (for the con:cern Subject instance). */
33: public static final String SUBJECT_ID = "subject_id";
34:
35: /** The Constant BEAN_META (for con:form BeanMeta information of the target object). */
36: public static final String BEAN_META = "beanMeta";
37:
38: /**
39: * Sets the target object. Rules expect at least this object to be present in a RuleContext.
40: *
41: * @param targetObject the target object on which the Rule is run.
42: */
43: public void setTargetObject(Object targetObject) {
44: put(TARGET_INSTANCE, targetObject);
45: }
46:
47: /**
48: * Gets the target object.
49: *
50: * @return the target object on which the Rule is run.
51: */
52: public Object getTargetObject() {
53: return get(TARGET_INSTANCE);
54: }
55:
56: }
|