Skip to content

Commit

Permalink
[JBRULES-3347] set a ClassLoader on the ClassPathResource after deser…
Browse files Browse the repository at this point in the history
…ialization
  • Loading branch information
mariofusco committed Apr 3, 2012
1 parent 13f361f commit fb82996
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public KnowledgeAgentImpl(String name,
this.newInstance = ((KnowledgeAgentConfigurationImpl) configuration).isNewInstance();
this.useKBaseClassLoaderForCompiling = ((KnowledgeAgentConfigurationImpl) configuration).isUseKBaseClassLoaderForCompiling();
this.notifier = (ResourceChangeNotifierImpl) ResourceFactory.getResourceChangeNotifierService();
if ( ((KnowledgeAgentConfigurationImpl) configuration).isMonitorChangeSetEvents() ) {
if ( configuration.isMonitorChangeSetEvents() ) {
monitor = true;
}

Expand Down Expand Up @@ -1143,6 +1143,10 @@ public boolean addDefinitionMapping(Resource resource,

boolean isNewDefinition = true;

if ( resource instanceof ClassPathResource && ((ClassPathResource)resource).getClassLoader() == null ) {
((ClassPathResource)resource).setClassLoader( ((InternalRuleBase)((KnowledgeBaseImpl) kbase).getRuleBase()).getRootClassLoader() );
}

if ( definition != null ) {
isNewDefinition = this.registeredResources.putDefinition( resource,
definition );
Expand Down Expand Up @@ -1378,6 +1382,7 @@ public void dispose() {
*/
@Override
protected void finalize() throws Throwable {
super.finalize();
// users should turn off monitoring, but just in case when this class is
// GC'd we turn off the thread
if ( this.changeSetNotificationDetector != null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.drools.io.impl;

import java.io.Externalizable;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ public ClassLoader getClassLoader() {
return this.classLoader;
}

public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}

public Class<?> getClazz() {
return this.clazz;
}
Expand Down

0 comments on commit fb82996

Please sign in to comment.