Adding global variables
About this task
You can use the ilog.rules.studio.javascript plug-in in conjunction with Eclipse to automate tasks on a preconfigured workspace or a folder containing the rule projects.
The following example demonstrates how to add a global
variable named out to replace a fully qualified call
to:
java.lang.System.out.println(<text message>);
Procedure
To add global variables:
Results
The plug-in Extensions tab now includes the new plug-in project:

You must now add the implementation of the factory. Factories contain a single method named getDOMroot. This method creates the Java instance of the class to which the method calls are forwarded.
The following SystemOutDOMFactory example
returns System.out static instances:
package javascriptsystem.dom;
import ilog.rules.studio.eclipsemonkey.dom.IMonkeyDOMFactory;
public class SystemOutDOMFactory implements IMonkeyDOMFactory {
public Object getDOMroot() {
return System.out;
}
}
By adding this global variable, you simplify each print command to the standard output. You can also create a more complex object that provides methods such as formatting text messages with parameters, as shown in the following example:
function main() {
// instead of java.lang.System.out.println("my message");
out.println("my message");
}