Creating a class driver

You can use the XOM API to create your own class driver.

About this task

When rules use a dynamic class, the rule engine must know the runtime policy for the class. The runtime policy is provided by a class driver and includes field getters and setters, and method and constructor bodies.

The runtime policy is defined through the following interfaces:

Procedure

To create a class driver:

  1. Code an implementation of the IlrClassDriver interface.
  2. Provide a static public method with the following signature:
    public static IlrClassDriver create(IlrReflect reflect)
    {
      // Do something to create and return the driver.
    }

    An implementation of a class driver must include a method with this signature, which is called by introspection to construct a driver object.

Results

With a class driver, you can implement a dynamic class using any type of class, such as implementing all the dynamic classes of an application using hash tables.

Note:

It is not necessary to create and set the fields in a way that depends on the implementation. Once the class drivers are defined, the dynamic classes provide the means for creating and manipulating objects without knowing the implementation details of a particular driver.

Examples:

A class driver that supports a constructor with no arguments:

A hash driver class:

Adding a Java object belonging to the class Person: