Java API

OpenRules Decision Manager provides a very simple Java API for invocation of business decision models from your Java applications. It uses two new Java classes “DecisionModel” and “Goal” that support the Goal-Oriented Decision Modeling approach described in this book . The provided Java launchers demonstrate how to execute decision models against real data instances. Here is what you usually should do:

  • Create an instance of the class DecisionModel using the automatically generated Java class (which name is defined in settings.bat as MODEL_NAME), e.g.
    DecisionModel model = new DecisionModelVacationDays();
  • Ask the model to create an instance of the class Goal, e.g.
    Goal goal = model.createGoal(“Vacations Days”);
  • Ask the goal to use your own business objects, e.g.
    goal.use(“Employee”,employee);
  • Execute the goal using the standard Goal’s method
    goal.execute();

Here is an example of how the decision model “Vacation Days” can be invoked using Launcher.java:

 

It will calculate the number of vacation days for the employee Mary Grant. Of course, an employee may come from a database, from your UI or from JSON.