| ILOG JRules User Guide > Executing Rules > Tasks > Executing a Ruleset Using a Native Rule Engine > Setting the Classpath to Contain the XOM and the Rule Engine |
Setting the Classpath to Contain the XOM and the Rule Engine |
PREVIOUS NEXT |
You can set the classpath of your Java application to contain the XOM and the rule engine from within Rule Studio. You can also set the XOM classpath by creating your own class loader.
To set the XOM and rule engine classpath in Rule Studio:
<InstallDir>/studio/lib directory and select the following JAR files, then click OK:
The XOM and rule engine classpath is now set and you can start writing a ruleset execution method.
You can also set the XOM classpath by creating your own class loader. An IlrReflect object uses a class loader to load the XOM classes when a rule is parsed. The class loader that is set is not the only one to be used; it is the one that is used in priority. If a class cannot be retrieved using the set class loader, the class loader used to load the IlrReflect class is used. The following methods are defined by the IlrObjectModel interface, which is implemented by IlrReflect.
package ilog.rules.bom;
public interface IlrObjectModel
{
public ClassLoader getClassLoader();
public void setClassLoader(ClassLoader classLoader);
}
Java classes can be loaded only after the class loader has been set.
| Note |
| Only one class loader can be set. Since JDK 1.2, class loaders are supposed to delegate loading a class to the parent class loader. |
| Important |
The class loader is lost if the IlrReflect object is serialized and then deserialized.
|
If you use Java serialization, you can use the following method to prevent the loss of the class loader:
public class IlrReflect
{
public static void linkClassLoader(ObjectInputStream str,
ClassLoader loader) { ... }
};
This method is called by passing the specific ObjectInputStream containing the IlrReflect to be deserialized, and specifying a class loader when the IlrReflect is read from the stream. The call must be placed before the IlrReflect is deserialized.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |