[jboss-svn-commits] JBL Code SVN: r19418 - in labs/jbossrules/trunk: drools-core/src/main/java/org/drools/common and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 4 09:45:45 EDT 2008


Author: mingjin
Date: 2008-04-04 09:45:44 -0400 (Fri, 04 Apr 2008)
New Revision: 19418

Added:
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java
Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectData.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectDatas.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectData.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java
Log:
JBRULES-1535 User provided packages with the same name were merged/changed after calling
- AbstractRuleBase: new Package for each new name space.
- DialectData: added clone().
- DialectDatas: cloning DialectData during merge
- JavaDialectData: implemented clone
- MVELDialectData: implemented clone

Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java	2008-04-04 13:45:44 UTC (rev 19418)
@@ -0,0 +1,90 @@
+package org.drools.reteoo;
+
+import org.drools.integrationtests.LargeRuleBase;
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.RuleBaseConfiguration;
+
+import java.io.StringReader;
+
+import org.drools.rule.Package;
+import org.drools.rule.Rule;
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA. User: SG0521861 Date: Mar 20, 2008 Time: 2:36:47 PM To change this template use File |
+ * Settings | File Templates.
+ */
+public class ReteooBuilderPerformanceTest extends TestCase {
+    private static final int    RULE_COUNT  = Integer.parseInt(System.getProperty("rule.count", "1000"));
+    private static final int    RETEBUILDER_COUNT  = Integer.parseInt(System.getProperty("retebuilder.count", "1"));
+
+    public void testReteBuilder() throws DroolsParserException {
+        addRules(generatePackage(RULE_COUNT));
+    }
+
+    private static void addRules(Package pkg) {
+        ReteooBuilder[]  reteBuilders   = getReteBuilders(RETEBUILDER_COUNT);
+
+        System.out.println("Adding rules to ReteBuilder");
+        long    start   = System.currentTimeMillis();
+        for (ReteooBuilder reteBuilder : reteBuilders) {
+            for (Rule rule : pkg.getRules())
+                reteBuilder.addRule(rule);
+        }
+        System.out.println("Added "+RULE_COUNT+" rules to each ReteBuilder's in "+
+                           format(System.currentTimeMillis()-start));
+    }
+
+    private static ReteooBuilder[] getReteBuilders(int count) {
+        System.out.println("Creating "+count+" ReteBuilder's");
+        ReteooBuilder[]  reteBuilders   = new ReteooBuilder[count];
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+
+        for (int i = 0; i < reteBuilders.length; i++) {
+            reteBuilders[i] = new ReteooBuilder(new ReteooRuleBase( conf ));
+        }
+        return reteBuilders;
+    }
+
+    private static Package generatePackage(int ruleCount) throws DroolsParserException {
+        StringReader    reader  = new StringReader(generateRules(ruleCount));
+
+        System.out.println("Parsing rules");
+        PackageDescr pkgDescr = new DrlParser().parse(reader);
+
+        System.out.println("Generating packages");
+        PackageBuilder pkgBuilder = new PackageBuilder(new PackageBuilderConfiguration());
+        pkgBuilder.addPackage(pkgDescr);
+
+        return pkgBuilder.getPackage();
+    }
+
+    private static String generateRules(int ruleCount) {
+        System.out.println("Generating "+ruleCount+" rules");
+        StringBuilder   sb  = new StringBuilder(LargeRuleBase.getHeader());
+
+        for (int i = 1; i <= ruleCount; i++) {
+            sb.append(LargeRuleBase.getTemplate1("testrule"+i, i));
+        }
+        return sb.toString();
+    }
+
+    private static final int    MILLIS_IN_SECOND   = 1000;
+    private static final int    MILLIS_IN_MINUTE    = MILLIS_IN_SECOND*60;
+    private static final int    MILLIS_IN_HOUR      = MILLIS_IN_MINUTE*60;
+
+    private static String format(long time) {
+        StringBuilder   sb  = new StringBuilder();
+
+        sb.append(time/MILLIS_IN_HOUR).append(':');
+        time = time % MILLIS_IN_HOUR;
+        sb.append(time/MILLIS_IN_MINUTE).append(':');
+        time = time % MILLIS_IN_MINUTE;
+        sb.append(time*1.0/MILLIS_IN_SECOND);
+        return sb.toString();
+    }
+}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-04-04 13:22:05 UTC (rev 19417)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-04-04 13:45:44 UTC (rev 19418)
@@ -43,14 +43,8 @@
 import org.drools.event.RuleBaseEventSupport;
 import org.drools.objenesis.Objenesis;
 import org.drools.process.core.Process;
-import org.drools.rule.CompositePackageClassLoader;
-import org.drools.rule.DialectDatas;
-import org.drools.rule.ImportDeclaration;
-import org.drools.rule.InvalidPatternException;
-import org.drools.rule.MapBackedClassLoader;
+import org.drools.rule.*;
 import org.drools.rule.Package;
-import org.drools.rule.Rule;
-import org.drools.rule.TypeDeclaration;
 import org.drools.spi.ExecutorServiceFactory;
 import org.drools.spi.FactHandleFactory;
 import org.drools.util.ObjectHashSet;
@@ -88,7 +82,7 @@
     protected transient MapBackedClassLoader           classLoader;
 
     private transient Objenesis                        objenesis;
-	
+
     /** The fact handle factory. */
     protected FactHandleFactory                        factHandleFactory;
 
@@ -223,7 +217,7 @@
                                                   ClassNotFoundException {
         // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
         DroolsObjectInput droolsStream = null;
-        boolean isDrools = in instanceof DroolsObjectInputStream;
+        boolean isDrools = in instanceof DroolsObjectInput;
 
         if ( isDrools ) {
             droolsStream = (DroolsObjectInput) in;
@@ -276,7 +270,7 @@
     }
 
 	/**
-	 * Creates Objenesis instance for the RuleBase. 
+	 * Creates Objenesis instance for the RuleBase.
 	 * @return a standart Objenesis instanse with caching turned on.
 	 */
 	protected Objenesis createObjenesis() {
@@ -413,7 +407,7 @@
     public synchronized void addPackage(final Package newPkg) {
         newPkg.checkValidity();
         synchronized ( this.pkgs ) {
-            final Package pkg = (Package) this.pkgs.get( newPkg.getName() );
+            Package pkg = this.pkgs.get( newPkg.getName() );
 
             // only acquire the lock if it hasn't been done explicitely
             boolean doUnlock = false;
@@ -425,37 +419,46 @@
 
             this.eventSupport.fireBeforePackageAdded( newPkg );
 
-            if ( pkg != null ) {
-                mergePackage( pkg,
-                              newPkg );
-            } else {
-                this.pkgs.put( newPkg.getName(),
-                               newPkg );
+            if ( pkg == null ) {
+                pkg = new Package(newPkg.getName(),
+                                  newPkg.getDialectDatas().getParentClassLoader());
+                pkgs.put(pkg.getName(), pkg);
+                this.packageClassLoader.addClassLoader( pkg.getDialectDatas().getClassLoader());
             }
+            else {
+                this.packageClassLoader.addClassLoader( newPkg.getDialectDatas().getClassLoader() );
+            }
 
+            mergePackage( pkg,
+                          newPkg );
+
             final Map newGlobals = newPkg.getGlobals();
 
-            // Check that the global data is valid, we cannot change the type
-            // of an already declared global variable
-            for ( final Iterator it = newGlobals.keySet().iterator(); it.hasNext(); ) {
-                final String identifier = (String) it.next();
-                final Class type = (Class) newGlobals.get( identifier );
-                final boolean f = this.globals.containsKey( identifier );
-                if ( f ) {
-                    final boolean y = !this.globals.get( identifier ).equals( type );
-                    if ( f && y ) {
-                        throw new PackageIntegrationException( pkg );
+            if (newGlobals != null) {
+                // Check that the global data is valid, we cannot change the type
+                // of an already declared global variable
+                for ( final Iterator it = newGlobals.keySet().iterator(); it.hasNext(); ) {
+                    final String identifier = (String) it.next();
+                    final Class type = (Class) newGlobals.get( identifier );
+                    final boolean f = this.globals.containsKey( identifier );
+                    if ( f ) {
+                        final boolean y = !this.globals.get( identifier ).equals( type );
+                        if ( f && y ) {
+                            throw new PackageIntegrationException( pkg );
+                        }
                     }
                 }
+                this.globals.putAll( newGlobals );
             }
-            this.globals.putAll( newGlobals );
 
-            // Add type declarations
-            for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
-                // should we allow overrides?
-                if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
-                    this.classTypeDeclaration.put( type.getTypeClass(),
-                                                   type );
+            if (newPkg.getTypeDeclarations() != null) {
+                // Add type declarations
+                for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
+                    // should we allow overrides?
+                    if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
+                        this.classTypeDeclaration.put( type.getTypeClass(),
+                                                       type );
+                    }
                 }
             }
 
@@ -467,7 +470,7 @@
             }
 
             //and now the rule flows
-            if ( newPkg.getRuleFlows() != Collections.EMPTY_MAP ) {
+            if ( newPkg.getRuleFlows() != null ) {
                 final Map flows = newPkg.getRuleFlows();
                 for ( final Iterator iter = flows.entrySet().iterator(); iter.hasNext(); ) {
                     final Entry flow = (Entry) iter.next();
@@ -476,8 +479,6 @@
                 }
             }
 
-            this.packageClassLoader.addClassLoader( newPkg.getDialectDatas().getClassLoader() );
-
             this.eventSupport.fireAfterPackageAdded( newPkg );
 
             // only unlock if it had been acquired implicitely
@@ -502,27 +503,38 @@
         // Merge imports
         imports.putAll( newPkg.getImports() );
 
-        // Add globals
-        for ( final Iterator it = newPkg.getGlobals().keySet().iterator(); it.hasNext(); ) {
-            final String identifier = (String) it.next();
-            final Class type = (Class) globals.get( identifier );
-            if ( globals.containsKey( identifier ) && !globals.get( identifier ).equals( type ) ) {
-                throw new PackageIntegrationException( "Unable to merge new Package",
-                                                       newPkg );
+        if (newPkg.getGlobals() != null) {
+            // Add globals
+            for ( final Iterator it = newPkg.getGlobals().keySet().iterator(); it.hasNext(); ) {
+                final String identifier = (String) it.next();
+                final Class type = (Class) globals.get( identifier );
+                if ( globals.containsKey( identifier ) && !globals.get( identifier ).equals( type ) ) {
+                    throw new PackageIntegrationException( "Unable to merge new Package",
+                                                           newPkg );
+                }
             }
+            if (globals == Collections.EMPTY_MAP) {
+                for (Object object : newPkg.getGlobals().entrySet()) {
+                    Map.Entry   entry   = (Map.Entry)object;
+                    pkg.addGlobal((String)entry.getKey(), (Class)entry.getValue());
+                }
+            } else {
+                globals.putAll( newPkg.getGlobals() );
+            }
         }
-        globals.putAll( newPkg.getGlobals() );
 
-        // add type declarations
-        for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
-            // should we allow overrides?
-            if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
-                this.classTypeDeclaration.put( type.getTypeClass(),
-                                               type );
+        if (newPkg.getTypeDeclarations() != null) {
+            // add type declarations
+            for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
+                // should we allow overrides?
+                if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
+                    this.classTypeDeclaration.put( type.getTypeClass(),
+                                                   type );
+                }
+                if ( !pkg.getTypeDeclarations().containsKey( type.getTypeName() ) ) {
+                    pkg.addTypeDeclaration( type );
+                }
             }
-            if ( !pkg.getTypeDeclarations().containsKey( type.getTypeName() ) ) {
-                pkg.addTypeDeclaration( type );
-            }
         }
 
         //Add rules into the RuleBase package
@@ -541,7 +553,7 @@
         }
 
         //and now the rule flows
-        if ( newPkg.getRuleFlows() != Collections.EMPTY_MAP ) {
+        if ( newPkg.getRuleFlows() != null ) {
             final Map flows = newPkg.getRuleFlows();
             for ( final Iterator iter = flows.values().iterator(); iter.hasNext(); ) {
                 final Process flow = (Process) iter.next();
@@ -551,6 +563,13 @@
 
         pkg.getDialectDatas().merge( newPkg.getDialectDatas() );
 
+        if ( newPkg.getFunctions() != null) {
+            for (Object object : newPkg.getFunctions().entrySet()) {
+                Map.Entry entry = (Map.Entry)object;
+                pkg.addFunction((Function)entry.getValue());
+            }
+        }
+
         if ( this.reloadPackageCompilationData == null ) {
             this.reloadPackageCompilationData = new ReloadPackageCompilationData();
         }
@@ -777,16 +796,16 @@
                                                                                       this.packageClassLoader );
         streamWithLoader.setRuleBase( this );
 
-        final StatefulSession session = (StatefulSession) streamWithLoader.readObject();                
+        final StatefulSession session = (StatefulSession) streamWithLoader.readObject();
 
         synchronized ( this.pkgs ) {
             ((InternalWorkingMemory) session).setRuleBase( this );
             ((InternalWorkingMemory) session).setId( (nextWorkingMemoryCounter()) );
-                        
 
+
             ExecutorService executor = ExecutorServiceFactory.createExecutorService( this.config.getExecutorService() );
-            executor.setCommandExecutor( new CommandExecutor( session ) );            
-            ((InternalWorkingMemory) session).setExecutorService( executor );            
+            executor.setCommandExecutor( new CommandExecutor( session ) );
+            ((InternalWorkingMemory) session).setExecutorService( executor );
 
             if ( keepReference ) {
                 addStatefulSession( session );
@@ -795,7 +814,7 @@
                 }
             }
 
-            return (StatefulSession) session;
+            return session;
         }
     }
 
@@ -851,11 +870,11 @@
         implements
         RuleBaseAction {
         private static final long serialVersionUID = 1L;
-        private Set               set;
+        private Set<DialectDatas> set;
 
         public void readExternal(ObjectInput in) throws IOException,
                                                 ClassNotFoundException {
-            set = (Set) in.readObject();
+            set = (Set<DialectDatas>) in.readObject();
         }
 
         public void writeExternal(ObjectOutput out) throws IOException {
@@ -864,15 +883,14 @@
 
         public void addDialectDatas(final DialectDatas dialectDatas) {
             if ( this.set == null ) {
-                this.set = new HashSet();
+                this.set = new HashSet<DialectDatas>();
             }
-
-            this.set.add( dialectDatas );
+            if (!this.set.contains(dialectDatas))
+                this.set.add( dialectDatas );
         }
 
         public void execute(final InternalRuleBase ruleBase) {
-            for ( final Iterator it = this.set.iterator(); it.hasNext(); ) {
-                final DialectDatas dialectDatas = (DialectDatas) it.next();
+            for ( final DialectDatas dialectDatas : this.set ) {
                 dialectDatas.reloadDirty();
             }
         }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectData.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectData.java	2008-04-04 13:22:05 UTC (rev 19417)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectData.java	2008-04-04 13:45:44 UTC (rev 19418)
@@ -1,13 +1,17 @@
 package org.drools.rule;
 
-public interface DialectData {    
+public interface DialectData extends Cloneable {
     public void removeRule(Package pkg, Rule rule);
-    
+
     public void removeFunction(Package pkg, Function function);
-                
+
     public void merge(DialectData newData);
-    
+
     public boolean isDirty();
-    
+
     public void reload();
+
+    public DialectData clone();
+
+    public void setDialectDatas(DialectDatas datas);
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectDatas.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectDatas.java	2008-04-04 13:22:05 UTC (rev 19417)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectDatas.java	2008-04-04 13:45:44 UTC (rev 19418)
@@ -89,20 +89,20 @@
     }
 
     public void merge(DialectDatas newDatas) {
-        for(Iterator it = newDatas.dialects.entrySet().iterator(); it.hasNext(); ) {
-            Entry entry = ( Entry ) it.next();
-            DialectData data = ( DialectData ) this.dialects.get( entry.getKey() );
-            data.merge( ( DialectData ) entry.getValue() );
-        }
-
-        if ( this.lineMappings != null ) {
-            // merge line mappings
-            this.lineMappings.putAll( newDatas.getLineMappings() );
+        for (Entry<String, DialectData> entry : newDatas.dialects.entrySet()) {
+            DialectData data = this.dialects.get( entry.getKey() );
+            if (data == null) {
+                DialectData dialectData = entry.getValue().clone();
+                dialectData.setDialectDatas(this);
+                this.dialects.put(entry.getKey(), dialectData);
         } else {
-            this.lineMappings = newDatas.getLineMappings();
+                data.merge( entry.getValue() );
         }
     }
 
+       getLineMappings().putAll(newDatas.getLineMappings());
+    }
+
     public boolean isDirty() {
         return true;
     }
@@ -146,10 +146,13 @@
     }
 
     public void addClassLoader(ClassLoader classLoader) {
-        if (this.classLoader == null) {
+        this.classLoader.addClassLoader( classLoader );
+    }
 
+    public void removeClassLoader(ClassLoader classLoader) {
+        if (classLoader != null) {
+            this.classLoader.removeClassLoader(classLoader);
         }
-        this.classLoader.addClassLoader( classLoader );
     }
 
     public void clear() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectData.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectData.java	2008-04-04 13:22:05 UTC (rev 19417)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectData.java	2008-04-04 13:45:44 UTC (rev 19418)
@@ -25,17 +25,13 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
 import org.drools.RuntimeDroolsException;
 import org.drools.base.accumulators.JavaAccumulatorFunctionExecutor;
-import org.drools.common.DroolsObjectInputStream;
-import org.drools.common.DroolsObjectOutputStream;
 import org.drools.common.DroolsObjectInput;
 import org.drools.spi.Accumulator;
 import org.drools.spi.Consequence;
@@ -95,6 +91,17 @@
         this.dirty = false;
     }
 
+    public DialectData clone() {
+        DialectData cloneOne = new JavaDialectData();
+
+        cloneOne.merge(this);
+        return cloneOne;
+    }
+
+    public void setDialectDatas(DialectDatas datas) {
+        this.datas  = datas;
+    }
+
     public boolean isDirty() {
         return this.dirty;
     }
@@ -131,6 +138,13 @@
         this.dirty  = droolsStream.readBoolean();
     }
 
+    protected Map getStore() {
+        if (store == null) {
+            store = new HashMap();
+        }
+        return store;
+    }
+
     public ClassLoader getClassLoader() {
         return this.classLoader;
     }
@@ -157,12 +171,21 @@
     public void merge(DialectData newData) {
         JavaDialectData newJavaData = (JavaDialectData) newData;
 
+        this.dirty = newData.isDirty();
+        if (this.classLoader == null) {
+            this.classLoader    = new PackageClassLoader(newJavaData.getClassLoader().getParent(), this);
+            this.dirty = true;
+        }
+
         // First update the binary files
         // @todo: this probably has issues if you add classes in the incorrect order - functions, rules, invokers.
-        final String[] files = newJavaData.list();
-        for ( int i = 0, length = files.length; i < length; i++ ) {
-            write( files[i],
-                   newJavaData.read( files[i] ) );
+        for ( String file : newJavaData.list()) {
+            // no need to wire, as we already know this is done in a merge
+            if (getStore().put( file,
+                                newJavaData.read( file ) ) != null ) {
+                // we are updating an existing class so reload();
+                this.dirty = true;
+            }
         }
 
         // Add invokers
@@ -199,15 +222,15 @@
     public byte[] read(final String resourceName) {
         byte[] bytes = null;
 
-        if ( this.store != null && !this.store.isEmpty()) {
-            bytes = (byte[]) this.store.get( resourceName );
+        if ( !getStore().isEmpty()) {
+            bytes = (byte[])getStore().get( resourceName );
         }
         return bytes;
     }
 
     public void write(final String resourceName,
                       final byte[] clazzData) throws RuntimeDroolsException {
-        if ( this.store.put( resourceName,
+        if ( getStore().put( resourceName,
                              clazzData ) != null ) {
             // we are updating an existing class so reload();
             //reload();
@@ -224,8 +247,8 @@
     }
 
     public boolean remove(final String resourceName) throws RuntimeDroolsException {
-        this.invokerLookups.remove( resourceName );
-        if ( this.store.remove( convertClassToResourcePath( resourceName ) ) != null ) {
+        getInvokers().remove( resourceName );
+        if (getStore().remove( convertClassToResourcePath( resourceName ) ) != null ) {
             // we need to make sure the class is removed from the classLoader
             // reload();
             this.dirty = true;
@@ -235,17 +258,13 @@
     }
 
     public String[] list() {
-        if ( this.store == null ) {
-            return new String[0];
-        }
-        final List names = new ArrayList();
+        String[] names = new String[getStore().size()];
+        int i = 0;
 
-        for ( final Iterator it = this.store.keySet().iterator(); it.hasNext(); ) {
-            final String name = (String) it.next();
-            names.add( name );
+        for ( Object object : getStore().keySet()) {
+            names[i++] = (String)object;
         }
-
-        return (String[]) names.toArray( new String[this.store.size()] );
+        return names;
     }
 
     /**
@@ -254,13 +273,14 @@
      */
     public void reload() throws RuntimeDroolsException {
         // drops the classLoader and adds a new one
+        this.datas.removeClassLoader( this.classLoader );
         this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader(), this );
         this.datas.addClassLoader( this.classLoader );
 
         // Wire up invokers
         try {
-            for ( final Iterator it = this.invokerLookups.entrySet().iterator(); it.hasNext(); ) {
-                Entry entry = (Entry) it.next();
+            for ( final Object object : getInvokers().entrySet() ) {
+                Entry entry = (Entry) object;
                 wire( (String) entry.getKey(),
                       entry.getValue() );
             }
@@ -278,8 +298,8 @@
     }
 
     public void clear() {
-        this.store.clear();
-        this.invokerLookups.clear();
+        getStore().clear();
+        getInvokers().clear();
         this.AST = null;
         reload();
     }
@@ -287,7 +307,7 @@
     public void wire(final String className) throws ClassNotFoundException,
                                             InstantiationException,
                                             IllegalAccessException {
-        final Object invoker = this.invokerLookups.get( className );
+        final Object invoker = getInvokers().get( className );
         wire( className,
               invoker );
     }
@@ -323,26 +343,29 @@
     }
 
     public String toString() {
-        return this.getClass().getName() + this.store.toString();
+        return this.getClass().getName() +getStore().toString();
     }
 
     public void putInvoker(final String className,
                            final Object invoker) {
-        this.invokerLookups.put( className,
+        getInvokers().put( className,
                                  invoker );
     }
 
     public void putAllInvokers(final Map invokers) {
-        this.invokerLookups.putAll( invokers );
+        getInvokers().putAll( invokers );
 
     }
 
     public Map getInvokers() {
+        if (this.invokerLookups == null) {
+            this.invokerLookups = new HashMap();
+        }
         return this.invokerLookups;
     }
 
     public void removeInvoker(final String className) {
-        this.invokerLookups.remove( className );
+        getInvokers().remove( className );
     }
 
     public Object getAST() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java	2008-04-04 13:22:05 UTC (rev 19417)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java	2008-04-04 13:45:44 UTC (rev 19418)
@@ -27,6 +27,15 @@
 		this.functionFactory = new MapFunctionResolverFactory();
 	}
 
+    public DialectData clone() {
+        DialectData clone = new MVELDialectData();
+        clone.merge(this);
+        return clone;
+    }
+
+    public void setDialectDatas(DialectDatas datas) {
+    }
+
 	public MapFunctionResolverFactory getFunctionFactory() {
 		return this.functionFactory;
 	}




More information about the jboss-svn-commits mailing list