[rules-users] dynamically generated classes, drools classloader, and jsr-94

Edson Tirelli tirelli at post.com
Tue Mar 13 19:08:21 EDT 2007


 
   Martin,

   You may find some useful information here:

http://markproctor.blogspot.com/2006/12/dynamically-generated-class-beans-as.html

   Thank you for the patch. I will take a look.

    []s
    Edson


Martin Schoch wrote:

>The application I'm working on will use facts which are dynamically
>generated classes.  After reading
>http://jira.jboss.com/jira/browse/JBRULES-557 I figured out the trick to
>get this working was to pass the ClassLoader responsible for the dynamic
>classes to drools.  So I set things up something like:
>
>  PackageBuilderConfiguration pbc = new PackageBuilderConfiguration();
>  pbc.setCompiler(PackageBuilderConfiguration.JANINO);
> 
>pbc.setClassLoader(instanceOfDynamicallyGeneratedClass.getClass().getCla
>ssLoader());
>  PackageBuilder builder = new PackageBuilder(pbc);
>
>Using this approach I am able to execute rules which interact with the
>properties of the dynamically generated classes.  The problem I've run
>into is that I'd really like to work with the JSR-94 API.  I have two
>questions:
>
>1. Is the code I referenced above using the correct approach?  Or am I
>already headed down the wrong path?
>2. Would passing additional configuration details into the properties
>argument of the call
>ruleExecutionSetProvider.createRuleExecutionSet(drlStream, properties)
>be advisable?  I have created a proof of concept to test this and
>included a patch.  Using this approach the application code looks
>something like this:
>
>  PackageBuilderConfiguration pbc = new PackageBuilderConfiguration();
>  pbc.setCompiler(PackageBuilderConfiguration.JANINO);
> 
>pbc.setClassLoader(instanceOfDynamicallyGeneratedClass.getClass().getCla
>ssLoader());
>
>  Map localProperties = new HashMap();
>  localProperties.put("packageBuilderConfiguration", pbc);
>
>  RuleExecutionSet ruleExecutionSet =
>ruleExecutionSetProvider.createRuleExecutionSet(drlStream,
>localProperties);
>
>Obviously this introduces a JBossRules dependency into my application
>code, but I am otherwise able to stick to the JSR-94 APIs.
>
>I have attached a patch to support this new property and welcome
>comments on this solution.
>
>Thanks,
>
>Marty Schoch
><mschoch at reisys.com>
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>rules-users mailing list
>rules-users at lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com





More information about the rules-users mailing list