You can use multiple drl files in one KnowledgeBase using KnowledgeBuilder.add. So, you can put your common functions in one drl file and reuse it with each of your other drl files. This is true for drools 4.x as well.


From: David Sinclair [mailto:dsinclair@chariotsolutions.com]
Sent: Wednesday, April 15, 2009 7:01 AM
To: Rules Users List
Subject: Re: [rules-users] How to create global functions?

Package scoped means that the function can only be used within the same rule package. The package may be split across multiple DRLs, but as long as in the same package, all would be able to access the function. See documentation for more info

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-expert/html_single/index.html#d0e4032


On Tue, Apr 14, 2009 at 6:32 PM, dhai <sdhari@hotmail.com> wrote:

Thanks Mark.

What do you mean by package scoped? In my scenario I have all rules with
same package declaration but in various .DRL files. Is it possible I create
common function in one file and use them in others? If yes, please write
some code to explain it.

We do not want to use Java static method as we have 2 different projects,
one for authoring the rules and another business application will use the
rules. By creating faction in Java classes add dependencies for the rules.
We will need to deploy Java classes with the rules.


Mark Proctor wrote:
>
> dhai wrote:
>> Is it possible to create functions global and call them from various .drl
>> files? I have common code that I want to call from various consequences
>> of
>> rules written in separate .drl files. I do not want to write helper Java
>> class.
>>
> functions are currently scoped to their package namespace. You can
> always use static methods on a class in external java code and import
> those from any .drl.
>
> Mark
>
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

--
View this message in context: http://www.nabble.com/How-to-create-global-functions--tp23031639p23049316.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users