wCMF Wiki : JBossRules

HomePage :: Categories :: PageIndex :: RecentChanges :: Login/Register
For the Java generator framework we plan to enable the genration of business rules. To facilitate this, we want to integrate a rule framework (engine). A good product seems to be JBoss Rules (Drools):

"JBoss Rules is an open source and standards-based business rules engine for easy business policy access, change, and management. JBoss Rules is a fast, highly efficient rules engine that makes it easy for a business analyst or auditor to view business rules, as they are encoded in your IT application infrastructure, to verify that the encoded rules indeed implement the documented business policies. JBoss Rules also supports a variety of language and decision table inputs, making it easy to quickly modify business policies to respond to opportunities and competitive threats."

Drools rules are defined in declarative language. Rules are defined like this:

rule "name"
attributes
when
LHS
then
RHS
end

A set of rules is defined in rule base. The data used as input for the applicable rules is called facts. The Working Memory is a container for the facts.

Drools may be easily integrated in Seam:

First, the rule based must be defined in the Seam components.xml:

<drools:rule-base name="policyPricingRules" dsl-file="policyPricing.dsl">
<drools:rule-files>
<value>policyPricingRules</value>
</drools:rule-files>
</drools:rule-base>

The WorkingMemory needs to be inserted in the Seam conversation:

<drools:managed-working-memory name="policyPricingWorkingMemory" auto-create="true" rule-base="#{policyPricingRules}"/>

In the Seam component, the engine is used like this:

@In WorkingMemory policyPricingWorkingMemory;

@In Policy policy;
@In Customer customer;

public void pricePolicy() throws FactException
{
policyPricingWorkingMemory.assertObject(policy);
policyPricingWorkingMemory.assertObject(customer);
policyPricingWorkingMemory.fireAllRules();
}

The policy and customer objects (the facts) are added to the working memory. Then the rules processing is started.


Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0347 seconds