It is possible that at some point during development, an rule-based application may require a rulebase to perform a calculation that cannot be done (or cannot be done easily) using the built-in functions of the Oracle Determinations Engine. To handle these situations, a custom function can be written to perform the calculation required.
Custom functions are written in the same language as the application using Oracle Determinations Engine for example, in Java if using the Determinations Engine API for Java), and must be contained inside a class that implements the CustomFunctionHandler interface. An instance of this class must be registered with the session using Session.setCustomFunctionHandler () before any inferencing is performed on the session. There can only be only one custom function handler installed on a session, but that custom function handler can handle multiple custom functions.
Custom functions and their arguments are described as in the following example:
<function name="SubString" return-type="text" description="Returns portion of a string">
<arg name="text" type="text" />
<arg name="start" type="number" />
<arg name="length" type="number" />
</function>
The return-type and type attributes must be one of the following:
Boolean arguments only work correctly when used as the last parameter of a custom function, due to a limitation in the Oracle Policy Modeling sentence parser.
Entities are not supported with this style of custom function.
To call a custom function, use the following syntax:
callcustomfunction("<function name>","<first input>,<second input>,<n input>")
For information on calling a custom function from Oracle policy Modeling, refer to the topic Write a rule that uses a custom function in the Oracle Policy Modeling Help.
Install Custom Functions, Custom Formatters and Inferencing Listeners
Customize the inferencing cycle with custom functions and inferencing listeners