How to Add a Decision Point Using Decision Point Builder

7-10 Oracle Fusion Middleware Users Guide for Oracle Business Rules using Decision Point. Table 7–1 provides a summary of the different versions of the car rental sample. For more information on working with the Rules SDK Decision Point API, see Oracle Fusion Middleware Java API Reference for Oracle Business Rules.

7.3.1 How to Add a Decision Point Using Decision Point Builder

To use a Decision Point you create a DecisionPoint instance using DecisionPointBuilder , as shown in Example 7–1 . Example 7–1 Using the Decision Point Builder static { try { specifying the Decision Function and a pre-loaded RuleDictionary instance m_decisionPoint = new DecisionPointBuilder .withDF_NAME .withloadRuleDictionary .build; } catch SDKException e { System.err.printlnFailed to build Decision Point: + e.getMessage; e.printStackTrace; } } Table 7–1 Java Files in the Decision Point Sample CarRentalProject Base Java Filename Description CarRental This is the base class for all of the examples. It contains constant values for using the CarRental dictionary and a method createDrivers which creates instances of the Driver class. CarRentalWithDecisionPoint Contains a static attribute of type DecisionPoint and a method checkDriver that invokes a Decision Point with a specified instance of the Driver class. This class includes these methods for the sample application so that both the MDS repository and pre-loaded dictionary examples can share the same checkDriver implementation. CarRentalWithDecisionPointUsi ngMdsRepository Contains an example of creating a Decision Point that uses MDS to access and load the rule dictionary. In a production environment, most applications use the Decision Point API with MDS. CarRentalWithDecisionPointUsi ngPreloadedDictionary Contains an example of creating a Decision Point from an instance of the RuleDictionary class. This example also contains code for manually loading the dictionary to create a RuleDictionary instance. CarRentalWithRuleSession Contains an advanced usage of the Engine API that is documented further in the comments. CarRentalWithRuleSessionPool Contains an advanced usage of the Engine API that is documented further in the comments. Denial Contains the class that defines the Denial fact type used to create the rules and Decision Table. Driver Contains the class that defines the Driver fact type used to create the rules and Decision Table. DriverCheckerRunnable Contains the class which can be used as a thread for simulating concurrent users invoking the Decision Point. Working with Rules SDK Decision Point API 7-11 Example 7–1 shows the DecisionPointBuilder supports a fluent interface pattern, so all methods can easily be chained together when you create a Decision Point. The three most common methods for configuring the Decision Point with DecisionPointBuilder are overloaded to have the name with. Each with method takes a single argument of type RuleDictionary, DictionaryFQN, or String . The DecisionPointBuilder also supports similar set and get methods: getDecisionFunction , setDecisionFunction, getDictionary, setDictionary , getDictionaryFQN, setDictionaryFQN. This chain shown in Example 7–1 includes the following steps: 1. The first step is to create a DecisionPointBuilder instance with code such as the following: new DecisionPointBuilder 2. The with method using a String argument defines the name of the decision function that the Decision Point executes. Calling this method is mandatory. .withDF_NAME The DF_NAME specifies the name of the decision function you define for your application. For example for the sample car rental application DF_NAME is defined in CarRental.java as CarRentalDecisionFunction. 3. Call only one of the other two with methods. In this case the sample code uses a pre-loaded Rule Dictionary instance, containing the specified decision function. The loadDictionary method loads an instance of RuleDictionary from a file. Example 7–2 shows the loadDictionary method. For more information, see Section 7.3.2, How to Use a Decision Point with a Pre-loaded Dictionary