SV: [rules-users] Writing rules using java..

Mark Proctor mproctor at codehaus.org
Sat Mar 3 14:39:27 EST 2007


Aeinehchi,

If you want to go this route you'll have to learn how the system works. 
First write some basic DRLS, then use the DrlParser to build a 
PackageDescr. PackageDescr is an intermediate AST that represent your 
rules with String for all the values. PackageBuilder can then build 
those PackageDescr. However I would still recommend you generate drls at 
runtime, with reflection on field names you can still achieve some level 
of refactoring.

Mark
Aeinehchi Nader wrote:
> I would very much like to wire my application with the rule engine.  By doing this, I would benefit from compiler, refactoring,....  Let me an example:
>
> Car car = new Car();
> car.setSpeed(100);
>
>
> Fact requirement = new Fact(car.getSpeed() > 120);
>
> if (requirement){
> Rule rule = new Rule(car.isOverspeeding(true));
> }
>
> How does the above fit to DRL?  Can this be done in compile-time with DRL?  Or can it be done by using Drools API?
>
> Thanks.
>
>
> Vennlig hilsen/Best regards
> Nader Aeinehchi
> Sjefsarkitekt /Chief Architect 
> EDB Business Partner Norge AS
> Telefon: +47 22 52 80 80, Direkte + 47 23 32 02 88, mobil: +47 41 44 29 57
> E-post: nader at edb.com
> http://www.edb.com 
> "EDB - En sterk og nær IT-partner"
>
>
>
> -----Opprinnelig melding-----
> Fra: rules-users-bounces at lists.jboss.org på vegne av Mark Proctor
> Sendt: lø 3/3/2007 2:48
> Til: Rules Users List
> Emne: Re: [rules-users] Writing rules using java..
>  
> Just generate a drl from your model using a template langauge such 
> velocity, freemarker or stringtemplate. you can generate and load the 
> drl at runtime, this is what the decision table does. You can program 
> agains the API yourself, but its quite complex, and certainly not 
> recommended for a noobie.
>
> Mark
> Kolla, Sandeep wrote:
>   
>> Hi Rahul,
>>
>> Its not about storing the whole file into the database.
>>
>> I would have a Table representing the parameteres required to 
>> construct a rule.
>>
>> For example.
>>
>> Tables:
>>
>> *RuleSetTable:*
>> Ruleset_id
>> Ruleset_name
>>
>> *RuleTable:*
>> Rule_id
>> Rule_name
>> Rule_saliance
>> Rule_condition
>> Rule_consequence
>> Ruleset_id
>>
>> Now while loading the rules the application basically should read from 
>> the DB, and construct the rules, as everything required to construct 
>> the rules is avaliable in the tables.
>>
>> This requirement had come up because as the rules keep changing quite 
>> frequently, we don't want to bring down the application to load a new 
>> DRL file.
>>
>> Hope you understood what I want to achieve.
>>
>> Thanks much,
>> Sandeep.
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>   
>>     
>
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070303/fe40ec92/attachment.html 


More information about the rules-users mailing list