File-Based Configuration
In addition to the management console-based configurations discussed in previous sections, there are also configuration file-based changes specific to WSO2 BRS as follows.
Rule Engine ConfigurationÂ
Rule engine config information can be specified in <PRODUCT_HOME>
\repository\conf\rule-engine-config.xml
. Its default configuration is as follows.
Â
<ruleEngineConfig xmlns="xs:string"> <ruleEngineProvider className="xs:string"> <property name="xs:string" value="xs:string"/>* </ruleEngineProvider> </ruleEngineConfig>
Â
- ruleEngineProvider: The "ClassName" specifies the rule service provider implementation. By default, it is org.wso2.carbon.rule.engine.jsr94.JSR94BackendRuntimeFactory. The default JSR94 API provider is the open source Drools rule engine.
- Properties: Specify configuration information for the rule service provider. For example, for "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 above configuration provides 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
- input/output facts definitions
Rule Service Configuration
When creating a rule service, you configure an .rsl file with the following elements:
<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 should be specified per operation. Facts are inserted into the rule engine from the incoming message and are also 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 in constructing out-message of the WSDL for a rule service.
An example of a .drl for a rule service is shown below.
Â
<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>