[rules-users] [guvnor] How to use a rule in a java application

Mario Viertel Mario.Viertel at medav.de
Wed Apr 20 07:39:16 EDT 2011


Hi all,

I am new in Guvnor and have a lot of questions.
I have created a decision table with the Guvnor web app. I have also 
created some test. All seems to be fine.

Now I want to use the rules in a web application. Unfortunately Guvnor 
doesn't provide a web service interface so I must develop an own web 
service to deal with the rules. But thats not so easy ...

In the Guvnor documentation I can see how to create KnowledgeBases and 
builders and how to fire rules. But I cannot see how to receive rule 
results.

Example:

The decision table looks similar like this:

rule 1 "under age"
if person.age < 18 then "under age"

rule 2 "pensioner female"
if person.age > 64 and person.gender == "female" then "pensioner"

rule 3 "pensioner male"
if person.age > 67 and person.gender == "male" then "pensioner"

rule 4 "full age"
* then "full age"


In my java application I create a person object:

Person p = new Person();
p.setBirthday(...);
p.setGender(...);

Now I miss a method in the Guvnor api to exectute the rules and receive 
the result like this:

Person result = (Person) rules.execute(p);

Can somebody explain how to execute a rule and receive the result.

Thanks in Advance
Mario Viertel
Germany



More information about the rules-users mailing list