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

Nicholas Hemley nic.hemley at sidonis.com
Wed Oct 14 10:02:45 EDT 2009


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091014/c0822292/attachment.html 


More information about the rules-users mailing list