Martin,
You may find some useful information here:
http://markproctor.blogspot.com/2006/12/dynamically-generated-class-beans...
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(a)reisys.com>
------------------------------------------------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)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