[rules-users] KnowledgeBase & Classloader - reload class or re-create Knowledgebase?

Edson Tirelli ed.tirelli at gmail.com
Wed Oct 14 10:40:48 EDT 2009


   Nicholas,

   I assume that you are using your classes not only in the consequence, but
in the LHS of the rules as well, right? In this case, a knowledge base
recompilation will be necessary. That is because Drools must indeed keep
references to your class in order to be able to properly match incoming
facts, extract their attribute values, etc. Drools already provides
re-wiring for most of its artifacts, but providing the same to user defined
classes would be close to recompile the knowledge base again.

   Now, I am curious about your use case? why do you need to re-load your
classes?

   []s
   Edson

2009/10/14 Nicholas Hemley <nic.hemley at sidonis.com>

>  Hello,
>
>
>
> I am using various classes in the consequences of my rules and I would like
> to dynamically re-load the classes.
>
>
>
> Currently, I include the following code snippet which sets the class
> loader:
>
>
>
> KnowledgeBaseConfiguration kbConf =
> KnowledgeBaseFactory.newKnowledgeBaseConfiguration(properties,
> MyClassLoader.getInstance());
>
> KnowledgeBase knowledgeBase =
> KnowledgeBaseFactory.newKnowledgeBase(kbConf);
>
>
>
> However, if I change the underlying jar and inform my classloader of this
> change, the old class is still used in the rule consequences.
>
>
>
> I therefore assume that Drools is storing a reference to the old class in
> the previously created KnowledgeBases so MyClassLoader.loadClass() is only
> invoked the first time the class is required.
>
>
>
> My question is thus: Is there any way to force a class reload on a
> KnowledgeBase or do I have to re-create the Knowledgebase?
>
>
>
> If so, would it be a case of getAllFactHandles() (or similar) and assert
> these into a newly created KnowledgeBase with a new instance of
> MyClassloader?
>
>
>
> Cheerio,
>
> Nic
>
>
>
> *Nicholas Hemley*
>
> *Senior Developer*
>
> *Sidonis | Powering a New Generation of Service Assurance*
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091014/cf42a7d6/attachment.html 


More information about the rules-users mailing list