The goal of this guide is to provide a detailed description about the configurations specific to the BRS. There are two types of configurations: rule-engine-config.xml and services.xml and next sections discuss those in detail.
Rule engine configuration is to provide the capability to define the Rule engine information. The configuration for the rule-engine-config.xml is shown bellow.
<ruleEngineConfig xmlns="xs:string"> <ruleEngineProvider className="xs:string"> <property name="xs:string" value="xs:string"/>* </ruleEngineProvider> </ruleEngineConfig>
RuleEngineProvider : The className is to specify the rule service provider implementation. The default one is org.wso2.carbon.rule.engine.jsr94.JSR94BackendRuntimeFactory. The default JSR94 API provider is the open source Drools rule engine. Properties are to be used to specify configuration information for the rule service provider. For example, for the JSR94BackendRuntimeFactory , there are two important properties : class and uri. The class is to provide the JSR 94 rule service provider and the default value for it is org.drools.jsr94.rules.RuleServiceProviderImpl. The uri is to provide the JSR 94 rule service provider URI and the default value of it is http://drools.org/.Another import property is default.properties.provider, which can be used to provide default properties to be used when creating rule execution sets and loading rule service provider.
A example rule-engine-config.xml is shown bellow.
<ruleEngineConfig xmlns="http://wso2.org/carbon/rules/conf"> <ruleEngineProvider className="org.wso2.carbon.rule.backend.drools.DroolsBackendRuntimeFactory"/> </ruleEngineConfig>
The configuration to be used to provide information required to expose a rule script as a web service. There are two important parts in the services.xml of a rule service: rule set definition and input/output facts definitions.
<ruleService name="xs:string" xmlns="xs:string" targetNamespace="xs:string"> <ruleSet> <rule resourceType="regular|dtable" sourceType="inline|registry|file|url""> </rule> </ruleSet> <properties> <property></property>* </properties> <operation name="xs:string"> <input wrapperElementName="xs:string" namespace="xs:string"> <fact elementName="xs:string" namespace="xs:string" type="xs:string"></fact>* </input> <output wrapperElementName="xs:string" namespace="xs:string"> <fact elementName="xs:string" namespace="xs:string" type="xs:string"></fact>* </output> </operation> </ruleService>
RuleSet definition
ruleset configuration is to specify the rule script which can be in the classpath, registry, or in-lined.
Facts/Results definitions
Facts/results configuration is should be specified per operation. Facts are used for formulating the facts to be inserted into the rule engine from the incoming message. These also are used in constructing in-message of the WSDL for a rule service. Results are used to extract the results of a rule engine execution and used in constructing out-message of the WSDL for a rule service.
An example for a .drl for a rule service is shown bellow.
OrderApprovalService Rule Service Configuration - OrderApprovalService.drl
<ruleService name="OrderApprovalService" xmlns="http://wso2.org/carbon/rules" targetNamespace="http://com.test/orderApproval"> <ruleSet> <rule resourceType="regular" sourceType="file">orderApprovalRules.drl</rule> </ruleSet> <operation name="placeOrder"> <input wrapperElementName="placeOrder" namespace="http://com.test/placeorder"> <fact elementName="order" namespace="http://com.test/placeorder" type="samples.userguide.PlaceOrder"></fact> </input> <output wrapperElementName="placeOrderRespone" namespace="http://com.test/placeorder"> <fact elementName="orderAccept" namespace="http://com.test/placeorder" type="samples.userguide.OrderAccept"></fact> <fact elementName="orderReject" namespace="http://com.test/placeorder" type="samples.userguide.OrderReject"></fact> </output> </operation> </ruleService>