Below is the procedure to create custom functions in OPA (Oracle Policy Automation).
- Copy the determinations-engine.jar file to library path from OPA (the file exists under the path <project>\Release\web-determinations\WEB-INF\lib\)
- Create a java class by extending the class “CustomFunction”. Note that a separate class is required to define for every custom function to be used in OPA
- Overwrite the “evaluate” method which will handle the user request
public Object evaluate(EntityInstance entityInstance, Object[] objects)
- The class would be like below
public class GetLocCountry extends CustomFunction {
public GetLocCountry() {
super();
}
public Object evaluate(EntityInstance entityInstance, Object[] objects) {
return null;
}
}
- Make jar to the class file (or include all the classes created into a single jar file)
- Copy the jar file to the below path of the OPA project
<OPA project>\Development\Extensions\lib\
- Create extension.xml file under Extensions folder. See below sample extension.xml file
<extension>
<functions>
<function name="getLocation" return-type="text">
<arg name="country_name" type="text"/>
<handler platform="java” class="cf.services.GetLocCountry"/>
</function>
</functions>
</extension>
- Build and Run the OPA project
No comments:
Post a Comment