Menu

Create Custom functions in OPA

ADF By Jun 07, 2012 No Comments
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>Releaseweb-determinationsWEB-INFlib)
  • 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>DevelopmentExtensionslib
  • 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

Leave a comment

Hi, Welcome here.
JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.