[rules-users] Importing functionS from another drl in 5.5.0

Mark Proctor mproctor at codehaus.org
Fri Jul 19 20:20:15 EDT 2013


6.0 now has dynamic jars that can contain drl and java. Any .java can be dynamically added, but not removed or updated (limitations of a class loader). We put all java classes into the root class loader. So you can do this for classes with static methods, and they will be available to all rules in all packages.  


6.x had class loader performance issues, when trying to resolve across packages, and it was even possible to put it into an infinite loop - we used a composite class loader approach. To keep rules dynamic, and to keep fast and robust class loaders we use the more traditional hierarchical class loader now, instead of a composite. So each drl namespace gets its own class loader, that is dropped and reloaded each time a rule is updated, but it's parent is the root class loader,and that's all it can see - not other peer drl class loaders.

Mark

On 19 Jul 2013, at 09:46, Sonata <plz.write.to at gmail.com> wrote:

> Mark Proctor wrote
>> Unfortunately not, and in 6.0 that won't be possible as there is stricter
>> class loader isolation between drl namespace files (limitation of a
>> dynamic system on the JVM). However functions are just static java
>> methods, and those work fine too, when defined on a class in the parent
>> class loader.
>> 
>> Mark
> 
> Thanks Mark. So in 6.0, we are not even able to use drl functions from
> another drl?
> I sort of require that because I will have rules that are added to the kbase
> in runtime with updated functions.
> 
> Then what about this? If I create a java class with all the static functions
> wrapped in jar (instead of defining them in drl), would that be possible to
> dynamically load the jar into the current kbase first and then let those
> rules added in runtime to use functions from that jar by simply adding
> import function mydynamicjar.MyFunc.*; ?
> 
> A simple code snippet on how to achieve that would be nice, thanks a lot!
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://drools.46999.n3.nabble.com/Importing-functionS-from-another-drl-in-5-5-0-tp4025050p4025053.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list