Configuration resource
A configuration resource is a file, a reader, or a stream. The engine loads it to pass property values to the execution process.
To configure the execution engine, you can use a configuration resource. A configuration resource can be a file, named engine.conf. The rule engine systematically looks for the engine.conf file and, if it finds it, loads it and passes the values that it contains to the execution process. The configuration resource can also be a reader or a stream.
The following example shows a simple configuration resource file:
node meta
{
element name = "java.lang";
};
node java.lang.String
{
element useIntern = true;
element maxHashCharacters = 24;
element paddingCharacter = '#';
};
This file is written in the true syntax of the engine configuration format. The configuration file contains properties grouped in blocks, starting with node. A node can in turn contain leaf elements and child nodes. The full property names are formed by the concatenation of all the names in the path of the property.
The following table describes the properties defined in the example above.
| Property name | Value | Type |
|---|---|---|
| meta.name | java.lang | String |
| java.lang.String.useIntern | true | boolean |
| java.lang.String.maxHashCharacters | 24 | int |
| java.lang.String.paddingCharacter | # | char |
How these properties are used depends on the specific code. In the example, you could develop a string manipulation algorithm to take these properties into account.
Each time a string is created, it is interned because the useIntern property is set to true. The property base name useIntern is predefined. The full property name is then obtained by concatenating the class name of String and the property base name.
In the same way, the algorithm hashes a String object using its first 24 characters at most. This is determined by the maxHashCharacters property .
The property meta.name is not designed to be used by the algorithms. A metanode provides identification information about a property file. When this file is read, the value of the meta.name property is kept. This way, the resource file is marked as read.
The configuration resource file has the following characteristics:
A node can contain elements or subnodes. All the elements are considered as terminal and must be assigned a value. A subnode is in turn a block that can itself contain elements or subnodes.
You can use any valid Java™ package name as a property name. The name can be a simple Java identifier (_MyID or a$b) or identifiers separated by a dot (.).
With nodes and subnodes, you can easily specify properties in a hierarchical way. For example, the properties attached to a Java class make up a node with elements that correspond to the properties of the class itself and subnodes that correspond to the properties attached to its fields.
You specify values by using the same literals as in IRL (ILOG® Rule Language). In particular, you must enclose strings between double quotes (for example,
Business Rules
) and characters between simple quotes (for example, ‘$’). Floating-point literals are also allowed and you can use the scientific notation (1.3e-2). A convenient syntax is available for arrays.Unicode escape sequences are preprocessed as in Java and in Decision Server rule languages. Use them as a way to put Unicode characters in the property names. For example, you can use these three Chinese characters\u67ef\u6ca7\u6d77 as a property name.