Rules for Constructing Java Classes

To be able to exchange information between the CA Rule Engine inference engine and its Java client application, it is necessary to have wrapper (stub) Java classes that wrap the corresponding rulebase level RDL classes that define pre- and post-condition (input and output) fields. A wrapper class only needs to declare property fields that correspond to RDL fields which are part of the rulebase application interface. At runtime, user instantiates objects of wrapper classes, initializes the pre-condition fields and adds the objects to rule session for inference and obtains inference results through the post-condition fields of those objects. The CA Rule Engine inference engine may also instantiate objects of wrapper classes due to rule actions.

The CA Rule Engine inference engine uses Java reflection technique to automatically match any user Java objects (instances) of wrapper classes added to the session with its internal instances of corresponding RDL classes. In addition to establishing correspondence between the wrapper class and the RDL class for just that added object, CA Rule Engine also establishes class correspondence for any instance reference fields defined in the class of that object. It will also implicitly and recursively add any objects as values of instance reference fields. When necessary, CA Rule Engine will also search for any wrapper classes in the package of the class of that added object.

In addition to matching objects of a wrapper class, CA Rule Engine also accepts objects of classes that are derived from that wrapper class and matches those objects to internal instances of the RDL class that corresponds to the wrapper class. In addition to normal Java class, the Java wrapper class for an RDL class may be a Java interface and CA Rule Engine accepts any objects of a class that implements that interface and matches those objects to internal instances of the RDL class that corresponds to the interface.

For this matching to work correctly, the Java classes of objects added to the inference engine must comply with specific rules described in the following sections. The requirements can be met through inheritance or implemented interface in addition to direct implementation in that class.

Rules for Public No-Argument Constructor and Property Accessors follow Java rules for the construction of bean classes. The Java classes should also implement the Serializable interface if serialization is needed. The other rules are unique to using CA Rule Engine.

For more information on Java beans, please see the Java Beans tutorial at http://java.sun.com

Note: Java client classes that represent rulebase classes must implement the Serializable interface if the rule session needs to be serialized. The WrapperMaker tool automatically generates serializable classes.