Introduction to Decision Point API How to Obtain the Car Rental Sample Application

7 Working with Rules SDK Decision Point API 7-1 7 Working with Rules SDK Decision Point API Oracle Business Rules SDK Rules SDK lets you write applications that access, create, modify, and execute rules in Oracle Business Rules dictionaries and work with the contents of a dictionary. This chapter provides a brief description of Rules SDK and shows how to work with the Rules SDK Decision Point API. This chapter includes the following sections: ■ Section 7.1, Introduction to Rules SDK and the Car Rental Sample Application ■ Section 7.2, Creating a Dictionary for Use with a Decision Point ■ Section 7.3, Creating a Java Application Using Rules SDK Decision Point ■ Section 7.4, Running the Car Rental Sample ■ Section 7.5, What You Need to Know About Using Decision Point in a Production Environment ■ Section 7.6, What You Need to Know About Decision Point and Decision Tracing For more information, see Oracle Fusion Middleware Java API Reference for Oracle Business Rules.

7.1 Introduction to Rules SDK and the Car Rental Sample Application

The Rules SDK consists of four areas: ■ Engine: provides for rules execution ■ Storage: provides access to rule dictionaries and repositories ■ Editing: provides a programatic way to create and modify dictionary components ■ Decision Point: provides an interface to access a dictionary and execute a decision function Other than for explanation purposes, there is not an explicit distinction between these areas in Rules SDK. For example, to edit rules you also need to use the storage area of Rules SDK to access a dictionary. These parts of the Rules SDK are divided to help describe the different modes of usage, rather than to describe distinct Rules SDK APIs.

7.1.1 Introduction to Decision Point API

The Decision Point API provides a concise way to execute rules. Most users create Oracle Business Rules artifacts, including data model elements, rules, Decision Tables, and rulesets using the Rules Designer extension to Oracle JDeveloper. Thus, most users do not need to work directly with the engine, storage, or editing parts of Rules SDK. 7-2 Oracle Fusion Middleware Users Guide for Oracle Business Rules To work with the Rules SDK Decision Point package you need to understand three important classes: ■ DecisionPoint : is a helper class that follows the factory design pattern to create instances of DecisionPointInstance. In most applications there should be one DecisionPoint object that is shared by all application threads. A caller uses the getInstance method of DecisionPoint to get an instance of DecisionPointInstance which can be used to call the defined Decision Point. ■ DecisionPointBuilder : follows the Builder design pattern to construct a Decision Point. ■ DecisionPointInstance : users call invoke in this class to assert facts and execute a decision function. The DecisionPoint classes support a fluent interface model so that methods can be chained together. For more information, see http:www.martinfowler.comblikiFluentInterface.html A Decision Point manages several aspects of rule execution, including: ■ Use of oracle.rules.rl.RuleSession objects ■ Reloading of a dictionary when the dictionary is updated To create a Decision Point in a Java application you need the following: ■ Either the name of a dictionary to be loaded from an MDS repository or a pre-loaded oracle.rules.sdk2.dictionary.RuleDictionary instance. ■ The name of a decision function stored in the specified dictionary.

7.1.2 How to Obtain the Car Rental Sample Application

This chapter shows a car rental application that demonstrates the use of Rules SDK and the Decision Point API. You can obtain the sample application in a ZIP file, CarRentalApplication.zip . This ZIP contains a complete JDeveloper application and project. The source code for Oracle Business Rules-specific samples is available online at https:www.samplecode.oracle.comsfgopage1497 For SOA samples online visit https:www.samplecode.oracle.comsfprojectssoasamples To work with the sample unzip CarRentalApplication.zip into an appropriate directory. The car rental application project contains a rules dictionary and several Java examples using Rules SDK.

7.1.3 How to Open the Car Rental Sample Application and Project