Oracle® SOA Suite Developer's Guide 10g (10.1.3.1.0) Part Number B28764-01 |
|
|
View PDF |
Before defining the rules that specify conditions for a BPEL Decide Activity to evaluate using rules, you must define an Oracle Business Rules data model. A data model contains business data definitions for facts or data objects used in rules, including XML facts that are based on an XML schema.
For example, the SOA Order Booking application includes the OrderBookingRules.xsd
file. This file specifies the schema for the customer information that the Decision Service sends as facts to the rules engine, and that the rules engine processes to determine if manual approval is required for an order. Oracle Business Rules binds an XML schema to Java classes using Java Architecture for XML Binding (JAXB). For details on using custom binding declarations, see Java Architecture for XML Binding (JAXB) Specification,
http://java.sun.com/webservices/jaxb/index.jsp
You need to process the XML schema and import the processed XML schema elements into the data model so that you can use the business objects when you define the business rules.
Before you can use XML elements in a data model, Rule Author must generate the classes representing the XML elements found in the XML schema. This step generates the JAXB classes and makes the generated classes and packages associated with the XML schema visible to Rule Author.
To use Rule Author to prepare a schema:
If necessary, load the dictionary by clicking the Repository tab.
Click the Definitions tab. The navigation tree shows the Definitions folder that contains the available definitions.
The Definitions folder in the tree contains the facts folder, which includes the available fact types: JavaFact, XMLFact, and RLFact. You use a JavaFact to work with business objects based on Java classes. A Java fact type allows selected properties and methods of a Java class to be declared so that rules can access, create, modify, and delete instances of the Java class. You use an RLFact to work with Oracle Business Rules RL Language fact. An RL Language fact contains a list of members of either RL Language fact type, Java fact type, or primitive type. RL Language fact types can be used to extend a business model by providing virtual dynamic types that are available when the rules engine runs.
Click XMLFact to view the XML Fact Summary page (see Figure 8-6). An XML fact type allows selected attributes and subelements of an XML element or complexType
to be declared so that instances of it can be accessed, created, modified, and deleted by rules. For example, this is the type that you use to define the business objects in the SOA Order Booking application.
Figure 8-6 Rule Author Definitions XML Fact Summary Page
Click Create.
Rule Author shows the XML Schema Selector page.
On the XML Schema Selector page, in the XML Schema field, enter either the path or HTTP URL for the schema. For example, you could use either of the following:
C:/demo/OrderBookingRules.xsd
http://www.myCompany.com/xsd/product.xsd
In the JAXB Class Directory field, enter the directory where you want Rule Author to store the JAXB-generated classes (the directory that you specify must be writable). For example, enter:
c:/demo/xml
Enter a value for the Target Package Name field. If you leave this field empty, the JAXB classes package name is generated from the target namespace of the XML schema using the default JAXB XML-to-Java mapping rule. For example, the namespace rules.oracle.com is mapped to com.oracle.rules.
The value you enter specifies the generated classes package name. For example, generated
. Although this example uses the name generated, there is nothing special about the name generated. This value specifies the package name for the JAXB-generated classes (see Figure 8-7).
Figure 8-7 Rule Author XML Schema Selection Page
Click Add Schema.
Rule Author processes the schema and compiles the JAXB, so depending on the size of the schema, you may need to wait for this step to complete. When this step completes, the page shows the cleared Add Schema text entry fields and Rule Author updates the Current XML Schemas field and shows the Generated JAXB Classes box (see Figure 8-8).
Figure 8-8 Rule Author Definitions XML Schema Selector After Adding XML Schema
This step brings the JAXB-generated classes representing the XML schema elements into the data model (from the sample schema OrderBookingRules.xsd
).
To import the schema representing the data required to build the rules and to output results:
Click the Definitions tab to view the Definitions page.
Click the XMLFact folder in the navigation tree.
Click Create on the XML Fact Summary page. This shows the XML Schema Selector page.
In the Generated JAXB Classes box on the XML Schema Selector page, expand the navigation tree until you see ApproveType
, Approve
, and ObjectFactory
.
Select the generated folder check box.
Click Import.
Rule Author shows a confirmation message: "1 class or package has been imported" (see Figure 8-9).
Expand the Generated node in the Generated JAXB Classes box to see the imported classes.
Note: After an element is imported, the element is shown in bold. |
Figure 8-9 Rule Author XML Schema Selector with Confirmation Message
When you import XML schema into the data model, Rule Author updates the data model to include the types and elements you imported. This allows Rule Author to present these elements and types in the lists you see when you use Rule Author to create and modify rules.
When you save a dictionary, Rule Author stores the rules and the data model associated with the dictionary using the specified version name.
If you choose to access the XML schema with a URL, and a proxy server is involved, then you must set the following system properties:
proxyHost = $YourProxyHost proxyPort = $YourProxyPort proxySet = true
For example:
-DproxyHost=www-proxy.myCompany.com -DproxyPort=80 -DproxySet=true
For more information about setting system properties in an OC4J instance, see Oracle Containers for J2EE Configuration and Administration Guide.