Using the CA Rule Engine › Construction of Java Client Applications › Add and Retrieve Inference Engine Objects › Difference between Objects for Static and Dynamic Instances
Difference between Objects for Static and Dynamic Instances
RDL makes a distinction between static and dynamic instances. Static instances are declared in the definition of RDL class. Dynamic instances are created by the engine based on rule actions or is created by the client if the RDL class is declared to be application creatable.
For the same RDL class, even though objects of the same Java wrapper class are used for both static and dynamic instances, client should note the following subtle differences between them so as to avoid potential problems:
- A static instance is always known to the engine. In principle, it is only necessary to add an object corresponding to a static instance if it contains pre and or post condition fields. For example, if the RDL class is intended for an enumeration type and static instances defined in that class represents values of the enumeration, it is only necessary to create objects for values which are actually referred by other objects, and to add them to the session prior to inference. CA Rule Engine will create additional objects for the remaining values when needed. However, it is always correct to add all objects for static instances to a rule session prior to inference.
- An object for a static instance should never be removed from a stateful rule session. This is again due to the fact that static instances are always known to the engine which makes it meaningless to remove such an object.
- The CA Rule Engine can create objects for dynamic instances of any defined RDL class. Client can only create objects for dynamic instances of RDL classes which have been declared application creatable.
- Any client created objects for dynamic instances must be added to the session for CA Rule Engine to be aware of their existence. However, such objects can be created or added prior to inference and during initialization callback.
- Client created objects for dynamic instances can be removed from a stateful rule session.