The CIC Engine supports the use of custom Java classes as Actions in your Ruleset. Once created, these custom Actions then reside in your Project and are available from the Ruleset editor, just as other Cleo-supplied Actions.
Creating custom Actions provides the ability to use a centralized function that can be called from multiple Rulesets, instead of having to recreate the same rule across many Rulesets.
Code Requirements
Please be aware that the Java class you create must meet the following:
-
- The class created needs to extend the AbstractAction class.
- The
com.extol.ebi.land.annotations.EbiName
andcom.extol.ebi.reactor.lib.AbstractAction
packages must be imported. - The class created must have an execute method. This method will be called by the CIC Engine when the program is called from the Ruleset.
- EbiName tags are required so that Class names and parameters are correctly displayed in the Ruleset.
This simple example shows a Java program containing the requirements noted above.
package com.a.test;
import com.cleo.common.lang.annotations.Name;
import com.extol.ebi.reactor.lib.AbstractAction;
@Name("AddNumbers")
public class AddNumbers extends AbstractAction {
public com.extol.ebi.ruleset.lang.core.Number execute(
@Name("a") com.extol.ebi.ruleset.lang.core.Number a,
@Name("b") com.extol.ebi.ruleset.lang.core.Number b) {
return asNumber(a.asJavaInteger() + b.asJavaInteger());
}
}
Steps
- From your Project Explorer, select the appropriate Project/Package you wish to use the action. This class must be in the same Project as your Ruleset or inside a Project with a set dependency to the Project holding the Ruleset.
- Right-click and select New>Class.
- Define the class and save. When creating Java classes, ensure you follow coding standards and best practices for clarity, maintainability, and efficiency.
Once you’ve successfully created the class, it will appear in your Project and as a callable Action in the Actions panel of your Ruleset editor.
Comments
0 comments
Please sign in to leave a comment.