[jboss-svn-commits] JBL Code SVN: r20703 - in labs/jbossrules/trunk/drools-core: src/main/java/org/drools/base/mvel and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jun 23 13:36:39 EDT 2008


Author: mark.proctor at jboss.com
Date: 2008-06-23 13:36:39 -0400 (Mon, 23 Jun 2008)
New Revision: 20703

Added:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeData.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeRegistry.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectRuntimeData.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectRuntimeData.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Namespaceable.java
Removed:
   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
Modified:
   labs/jbossrules/trunk/drools-core/.classpath
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java
Log:
JBRULES-1657 Allow RuleBases to be attached to a PackageBuilder for incremental build and use
JBRULES-1656 PackageBulder to support multiple namespaces

Modified: labs/jbossrules/trunk/drools-core/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-core/.classpath	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/.classpath	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,12 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-  <classpathentry kind="src" path="src/main/java"/>
-  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
-  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/classes"/>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/2.0-SNAPSHOT/mvel-2.0-SNAPSHOT.jar"/>
-</classpath>
\ No newline at end of file
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
+	<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
+	<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/mvel/mvel/2.0-SNAPSHOT/mvel-2.0-SNAPSHOT.jar"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -27,7 +27,7 @@
 import org.drools.WorkingMemory;
 import org.drools.common.InternalFactHandle;
 import org.drools.rule.Declaration;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.Accumulator;
 import org.drools.spi.Tuple;
@@ -106,7 +106,7 @@
         DroolsMVELFactory factory = (DroolsMVELFactory) workingMemoryContext;
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = (MVELDialectData) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -7,7 +7,7 @@
 import java.io.Serializable;
 
 import org.drools.WorkingMemory;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.Action;
 import org.drools.spi.KnowledgeHelper;
@@ -59,7 +59,7 @@
         
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }        
         

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,7 +1,7 @@
 package org.drools.base.mvel;
 
 import org.drools.WorkingMemory;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.Consequence;
 import org.drools.spi.KnowledgeHelper;
@@ -55,7 +55,7 @@
 
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -8,7 +8,7 @@
 
 import org.drools.WorkingMemory;
 import org.drools.rule.Declaration;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.EvalExpression;
 import org.drools.spi.Tuple;
@@ -61,7 +61,7 @@
 
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -2,7 +2,7 @@
 
 import org.drools.WorkingMemory;
 import org.drools.rule.Declaration;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.PredicateExpression;
 import org.drools.spi.Tuple;
@@ -57,7 +57,7 @@
 
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,7 +1,7 @@
 package org.drools.base.mvel;
 
 import org.drools.WorkingMemory;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.ReturnValueEvaluator;
 import org.mvel.MVEL;
@@ -56,7 +56,7 @@
         
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }
         

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -2,7 +2,7 @@
 
 import org.drools.WorkingMemory;
 import org.drools.rule.Declaration;
-import org.drools.rule.MVELDialectData;
+import org.drools.rule.MVELDialectRuntimeData;
 import org.drools.rule.Package;
 import org.drools.spi.FieldValue;
 import org.drools.spi.ReturnValueExpression;
@@ -48,7 +48,7 @@
 
         Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
         if ( pkg != null ) {
-            MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
+            MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
             factory.setNextFactory( data.getFunctionFactory() );
         }
 

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-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -43,7 +43,8 @@
 import org.drools.marshalling.Marshaller;
 import org.drools.process.core.Process;
 import org.drools.rule.CompositePackageClassLoader;
-import org.drools.rule.DialectDatas;
+import org.drools.rule.DialectRuntimeData;
+import org.drools.rule.DialectRuntimeRegistry;
 import org.drools.rule.FactType;
 import org.drools.rule.Function;
 import org.drools.rule.ImportDeclaration;
@@ -239,7 +240,7 @@
         this.packageClassLoader.addClassLoader( this.classLoader );
 
         for ( final Object object : this.pkgs.values() ) {
-            this.packageClassLoader.addClassLoader( ((Package) object).getDialectDatas().getClassLoader() );
+            this.packageClassLoader.addClassLoader( ((Package) object).getDialectRuntimeRegistry().getClassLoader() );
         }
         // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
         this.id = (String) droolsStream.readObject();
@@ -344,7 +345,7 @@
         return (Package[]) this.pkgs.values().toArray( new Package[this.pkgs.size()] );
     }
 
-    public Map getPackagesMap() {
+    public Map<String, Package> getPackagesMap() {
         return this.pkgs;
     }
 
@@ -432,10 +433,10 @@
                                    newPkg.getPackageScopeClassLoader() );
                 pkgs.put( pkg.getName(),
                           pkg );
-                this.packageClassLoader.addClassLoader( pkg.getDialectDatas().getClassLoader() );
+                this.packageClassLoader.addClassLoader( pkg.getDialectRuntimeRegistry().getClassLoader() );
             } else {
                 pkg.getPackageScopeClassLoader().getStore().putAll( newPkg.getPackageScopeClassLoader().getStore() );
-                this.packageClassLoader.addClassLoader( newPkg.getDialectDatas().getClassLoader() );
+                this.packageClassLoader.addClassLoader( newPkg.getDialectRuntimeRegistry().getClassLoader() );
             }
 
             final Map<String, Class> newGlobals = newPkg.getGlobals();
@@ -565,7 +566,7 @@
             }
         }
 
-        pkg.getDialectDatas().merge( newPkg.getDialectDatas() );
+        pkg.getDialectRuntimeRegistry().merge( newPkg.getDialectRuntimeRegistry() );
 
         if ( newPkg.getFunctions() != null ) {
             for ( Map.Entry<String, Function> entry : newPkg.getFunctions().entrySet() ) {
@@ -576,14 +577,14 @@
         if ( this.reloadPackageCompilationData == null ) {
             this.reloadPackageCompilationData = new ReloadPackageCompilationData();
         }
-        this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectDatas() );
+        this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectRuntimeRegistry() );
     }
 
     public TypeDeclaration getTypeDeclaration(Class< ? > clazz) {
         return this.classTypeDeclaration.get( clazz );
     }
 
-    private synchronized void addRule(final Package pkg,
+    public synchronized void addRule(final Package pkg,
                                       final Rule rule) throws InvalidPatternException {
         this.eventSupport.fireBeforeRuleAdded( pkg,
                                                rule );
@@ -622,7 +623,7 @@
                                 rules[i] );
                 }
 
-                this.packageClassLoader.removeClassLoader( pkg.getDialectDatas().getClassLoader() );
+                this.packageClassLoader.removeClassLoader( pkg.getDialectRuntimeRegistry().getClassLoader() );
 
                 // getting the list of referenced globals
                 final Set referencedGlobals = new HashSet();
@@ -688,7 +689,7 @@
             if ( this.reloadPackageCompilationData == null ) {
                 this.reloadPackageCompilationData = new ReloadPackageCompilationData();
             }
-            this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectDatas() );
+            this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectRuntimeRegistry() );
 
             // only unlock if it had been acquired implicitely
             if ( doUnlock ) {
@@ -697,7 +698,7 @@
         }
     }
 
-    private void removeRule(final Package pkg,
+    public void removeRule(final Package pkg,
                             final Rule rule) {
         this.eventSupport.fireBeforeRuleRemoved( pkg,
                                                  rule );
@@ -728,7 +729,7 @@
             if ( this.reloadPackageCompilationData == null ) {
                 this.reloadPackageCompilationData = new ReloadPackageCompilationData();
             }
-            this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectDatas() );
+            this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectRuntimeRegistry() );
 
             this.eventSupport.fireAfterFunctionRemoved( pkg,
                                                         functionName );
@@ -839,27 +840,27 @@
         implements
         RuleBaseAction {
         private static final long serialVersionUID = 1L;
-        private Set<DialectDatas> set;
+        private Set<DialectRuntimeRegistry> set;
 
         public void readExternal(ObjectInput in) throws IOException,
                                                 ClassNotFoundException {
-            set = (Set<DialectDatas>) in.readObject();
+            set = (Set<DialectRuntimeRegistry>) in.readObject();
         }
 
         public void writeExternal(ObjectOutput out) throws IOException {
             out.writeObject( set );
         }
 
-        public void addDialectDatas(final DialectDatas dialectDatas) {
+        public void addDialectDatas(final DialectRuntimeRegistry registry) {
             if ( this.set == null ) {
-                this.set = new HashSet<DialectDatas>();
+                this.set = new HashSet<DialectRuntimeRegistry>();
             }
-            if ( !this.set.contains( dialectDatas ) ) this.set.add( dialectDatas );
+            if ( !this.set.contains( registry ) ) this.set.add( registry );
         }
 
         public void execute(final InternalRuleBase ruleBase) {
-            for ( final DialectDatas dialectDatas : this.set ) {
-                dialectDatas.reloadDirty();
+            for ( final DialectRuntimeRegistry registry : this.set ) {
+                registry.reloadDirty();
             }
         }
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -19,8 +19,8 @@
     InternalWorkingMemory getWorkingMemory();
     Package getPackage();
     void setPackage(Package pkg);
-    DialectDatas getDialectDatas();
-    void setDialectDatas(DialectDatas dialectDatas);
+    DialectRuntimeRegistry getDialectRuntimeRegistry();
+    void setDialectRuntimeRegistry(DialectRuntimeRegistry dialectDatas);
     ClassFieldAccessorCache getExtractorFactory();
     void setExtractorFactory(ClassFieldAccessorCache extractorFactory);
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -23,7 +23,7 @@
 import java.util.concurrent.atomic.AtomicReferenceArray;
 
 import org.drools.base.ClassFieldAccessorCache;
-import org.drools.rule.DialectDatas;
+import org.drools.rule.DialectRuntimeRegistry;
 import org.drools.rule.Package;
 
 public class DroolsObjectInputStream
@@ -58,7 +58,7 @@
     private InternalRuleBase         ruleBase;
     private InternalWorkingMemory    workingMemory;
     private Package                  pkg;
-    private DialectDatas             dialectDatas;
+    private DialectRuntimeRegistry             dialectRegistry;
     private ClassFieldAccessorCache extractorFactory;
 
     /**
@@ -102,11 +102,11 @@
             DroolsObjectInputStream.this.setPackage(pkg);
         }
 
-        public DialectDatas getDialectDatas() {
-            return DroolsObjectInputStream.this.getDialectDatas();
+        public DialectRuntimeRegistry getDialectRuntimeRegistry() {
+            return DroolsObjectInputStream.this.getDialectRuntimeRegistry();
         }
-        public void setDialectDatas(DialectDatas dialectDatas) {
-            DroolsObjectInputStream.this.setDialectDatas(dialectDatas);
+        public void setDialectRuntimeRegistry(DialectRuntimeRegistry dialectRuntimeRegistry) {
+            DroolsObjectInputStream.this.setDialectRuntimeRegistry(dialectRuntimeRegistry);
         }
 
         public ClassFieldAccessorCache getExtractorFactory() {
@@ -171,11 +171,11 @@
         this.pkg    = pkg;
     }
 
-    public DialectDatas getDialectDatas() {
-        return dialectDatas;
+    public DialectRuntimeRegistry getDialectRuntimeRegistry() {
+        return this.dialectRegistry;
     }
-    public void setDialectDatas(DialectDatas dialectDatas) {
-        this.dialectDatas   = dialectDatas;
+    public void setDialectRuntimeRegistry(DialectRuntimeRegistry dialectRegistry) {
+        this.dialectRegistry   = dialectRegistry;
     }
 
     public ClassFieldAccessorCache getExtractorFactory() {

Deleted: 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-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectData.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,19 +0,0 @@
-package org.drools.rule;
-
-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 setDirty(boolean dirty);
-
-    public void reload();
-
-    public DialectData clone();
-
-    public void setDialectDatas(DialectDatas datas);
-}

Deleted: 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-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectDatas.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,170 +0,0 @@
-package org.drools.rule;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.drools.common.DroolsObjectInput;
-
-public class DialectDatas implements Externalizable {
-    private transient ClassLoader parentClassLoader;
-    private CompositePackageClassLoader classLoader;
-
-    private Map<String, DialectData> dialects;
-
-    private Map                           lineMappings;
-
-    /**
-     * Default constructor - for Externalizable. This should never be used by a user, as it
-     * will result in an invalid state for the instance.
-     */
-    public DialectDatas() {
-        this(null);
-    }
-
-    public DialectDatas(ClassLoader classLoader) {
-        setParentClassLoader(classLoader);
-        this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
-        this.dialects = new HashMap<String, DialectData>();
-    }
-
-    /**
-     * Handles the write serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
-     * default methods. The PackageCompilationData holds a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
-     *
-     */
-    public void writeExternal(final ObjectOutput stream) throws IOException {
-        stream.writeObject(this.dialects);
-        stream.writeObject( this.lineMappings );
-    }
-
-    /**
-     * Handles the read serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
-     * default methods. The PackageCompilationData holds a reference to the generated bytecode; which must be restored before any Rules.
-     * A custom ObjectInputStream, able to resolve classes against the bytecode, is used to restore the Rules.
-     *
-     */
-    public void readExternal(final ObjectInput stream) throws IOException,
-                                                              ClassNotFoundException {
-        DroolsObjectInput   droolsStream    = (DroolsObjectInput)stream;
-
-        setParentClassLoader(droolsStream.getClassLoader());
-        this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
-        droolsStream.setDialectDatas(this);
-        droolsStream.setClassLoader(this.classLoader);
-
-        this.dialects       = (Map<String, DialectData>)droolsStream.readObject();
-        this.lineMappings   = (Map) stream.readObject();
-    }
-
-    public void addDialectData(String dialect, DialectData dialectData) {
-        this.dialects.put( dialect, dialectData );
-    }
-
-    public void setDialectData(String name, DialectData data) {
-        this.dialects.put( name, data );
-    }
-
-    public DialectData getDialectData(String dialect) {
-        return this.dialects.get( dialect );
-    }
-
-    public DialectData removeRule(final Package pkg, final Rule rule) {
-        DialectData dialect = this.dialects.get( rule.getDialect() );
-        dialect.removeRule( pkg, rule );
-        return dialect;
-    }
-
-    public DialectData removeFunction(final Package pkg, final Function function) {
-        DialectData dialect = this.dialects.get( function.getDialect() );
-        dialect.removeFunction( pkg, function );
-        return dialect;
-    }
-
-    public void merge(DialectDatas newDatas) {
-        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 {
-                data.merge( entry.getValue() );
-        }
-    }
-
-       getLineMappings().putAll(newDatas.getLineMappings());
-    }
-
-    public boolean isDirty() {
-        return true;
-    }
-
-    public void reloadDirty() {
-        // detect if any dialect is dirty, if so reload() them all
-        boolean isDirty = false;
-        for(Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
-            DialectData data = ( DialectData ) it.next();
-            if ( data.isDirty() ) {
-                isDirty = true;
-                break;
-            }
-        }
-
-        if ( isDirty ) {
-            this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
-            for(Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
-                DialectData data = ( DialectData ) it.next();
-                data.reload();
-            }
-        }
-    }
-
-    public ClassLoader getParentClassLoader() {
-        return this.parentClassLoader;
-    }
-
-    public void setParentClassLoader(ClassLoader classLoader) {
-        if (classLoader == null) {
-            classLoader = Thread.currentThread().getContextClassLoader();
-            if ( classLoader == null ) {
-                classLoader = getClass().getClassLoader();
-            }
-        }
-        this.parentClassLoader = classLoader;
-    }
-
-    public ClassLoader getClassLoader() {
-        return this.classLoader;
-    }
-
-    public void addClassLoader(ClassLoader classLoader) {
-        this.classLoader.addClassLoader( classLoader );
-    }
-
-    public void removeClassLoader(ClassLoader classLoader) {
-        if (classLoader != null) {
-            this.classLoader.removeClassLoader(classLoader);
-        }
-    }
-
-    public void clear() {
-        this.dialects.clear();
-    }
-
-    public LineMappings getLineMappings(final String className) {
-        return (LineMappings) getLineMappings().get( className );
-    }
-
-    public Map getLineMappings() {
-        if ( this.lineMappings == null ) {
-            this.lineMappings = new HashMap();
-        }
-        return this.lineMappings;
-    }
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeData.java (from rev 20678, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectData.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeData.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeData.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -0,0 +1,17 @@
+package org.drools.rule;
+
+public interface DialectRuntimeData extends Cloneable {
+    public void removeRule(Package pkg, Rule rule);
+
+    public void removeFunction(Package pkg, Function function);
+
+    public void merge(DialectRuntimeData newData);
+
+    public boolean isDirty();
+
+    public void setDirty(boolean dirty);
+
+    public void reload();
+
+    public DialectRuntimeData clone();
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeRegistry.java (from rev 20678, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectDatas.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeRegistry.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/DialectRuntimeRegistry.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -0,0 +1,175 @@
+package org.drools.rule;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.drools.common.DroolsObjectInput;
+
+public class DialectRuntimeRegistry
+    implements
+    Externalizable {
+    private transient ClassLoader           parentClassLoader;
+    private CompositePackageClassLoader     classLoader;
+
+    private Map<String, DialectRuntimeData> dialects;
+
+    private Map                             lineMappings;
+
+    /**
+     * Default constructor - for Externalizable. This should never be used by a user, as it
+     * will result in an invalid state for the instance.
+     */
+    public DialectRuntimeRegistry() {
+        this( null );
+    }
+
+    public DialectRuntimeRegistry(ClassLoader classLoader) {
+        setParentClassLoader( classLoader );
+        this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
+        this.dialects = new HashMap<String, DialectRuntimeData>();
+    }
+
+    /**
+     * Handles the write serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
+     * default methods. The PackageCompilationData holds a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
+     *
+     */
+    public void writeExternal(final ObjectOutput stream) throws IOException {
+        stream.writeObject( this.dialects );
+        stream.writeObject( this.lineMappings );
+    }
+
+    /**
+     * Handles the read serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
+     * default methods. The PackageCompilationData holds a reference to the generated bytecode; which must be restored before any Rules.
+     * A custom ObjectInputStream, able to resolve classes against the bytecode, is used to restore the Rules.
+     *
+     */
+    public void readExternal(final ObjectInput stream) throws IOException,
+                                                      ClassNotFoundException {
+        DroolsObjectInput droolsStream = (DroolsObjectInput) stream;
+
+        setParentClassLoader( droolsStream.getClassLoader() );
+        this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
+        droolsStream.setDialectRuntimeRegistry( this );
+        droolsStream.setClassLoader( this.classLoader );
+
+        this.dialects = (Map<String, DialectRuntimeData>) droolsStream.readObject();
+        this.lineMappings = (Map) stream.readObject();
+    }
+
+    public void setDialectData(String name,
+                               DialectRuntimeData data) {
+        this.dialects.put( name,
+                           data );
+    }
+
+    public DialectRuntimeData getDialectData(String dialect) {
+        return this.dialects.get( dialect );
+    }
+
+    public DialectRuntimeData removeRule(final Package pkg,
+                                         final Rule rule) {
+        DialectRuntimeData dialect = this.dialects.get( rule.getDialect() );
+        dialect.removeRule( pkg,
+                            rule );
+        return dialect;
+    }
+
+    public DialectRuntimeData removeFunction(final Package pkg,
+                                             final Function function) {
+        DialectRuntimeData dialect = this.dialects.get( function.getDialect() );
+        dialect.removeFunction( pkg,
+                                function );
+        return dialect;
+    }
+
+    public void merge(DialectRuntimeRegistry newDatas) {
+        for ( Entry<String, DialectRuntimeData> entry : newDatas.dialects.entrySet() ) {
+            DialectRuntimeData data = this.dialects.get( entry.getKey() );
+            if ( data == null ) {
+                DialectRuntimeData dialectData = entry.getValue().clone();
+                //dialectData.setDialectRuntimeRegistry( this );
+                this.dialects.put( entry.getKey(),
+                                   dialectData );
+            } else {
+                data.merge( entry.getValue() );
+            }
+        }
+
+        getLineMappings().putAll( newDatas.getLineMappings() );
+    }
+
+    public boolean isDirty() {
+        return true;
+    }
+
+    public void reloadDirty() {
+        // detect if any dialect is dirty, if so reload() them all
+        boolean isDirty = false;
+        for ( Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
+            DialectRuntimeData data = (DialectRuntimeData) it.next();
+            if ( data.isDirty() ) {
+                isDirty = true;
+                break;
+            }
+        }
+
+        if ( isDirty ) {
+            this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
+            for ( Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
+                DialectRuntimeData data = (DialectRuntimeData) it.next();
+                data.reload();
+            }
+        }
+    }
+
+    public ClassLoader getParentClassLoader() {
+        return this.parentClassLoader;
+    }
+
+    public void setParentClassLoader(ClassLoader classLoader) {
+        if ( classLoader == null ) {
+            classLoader = Thread.currentThread().getContextClassLoader();
+            if ( classLoader == null ) {
+                classLoader = getClass().getClassLoader();
+            }
+        }
+        this.parentClassLoader = classLoader;
+    }
+
+    public ClassLoader getClassLoader() {
+        return this.classLoader;
+    }
+
+    public void addClassLoader(ClassLoader classLoader) {
+        this.classLoader.addClassLoader( classLoader );
+    }
+
+    public void removeClassLoader(ClassLoader classLoader) {
+        if ( classLoader != null ) {
+            this.classLoader.removeClassLoader( classLoader );
+        }
+    }
+
+    public void clear() {
+        this.dialects.clear();
+    }
+
+    public LineMappings getLineMappings(final String className) {
+        return (LineMappings) getLineMappings().get( className );
+    }
+
+    public Map getLineMappings() {
+        if ( this.lineMappings == null ) {
+            this.lineMappings = new HashMap();
+        }
+        return this.lineMappings;
+    }
+}

Deleted: 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-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectData.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,493 +0,0 @@
-package org.drools.rule;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.drools.RuntimeDroolsException;
-import org.drools.base.accumulators.JavaAccumulatorFunctionExecutor;
-import org.drools.common.DroolsObjectInput;
-import org.drools.spi.Accumulator;
-import org.drools.spi.Consequence;
-import org.drools.spi.EvalExpression;
-import org.drools.spi.PredicateExpression;
-import org.drools.spi.ReturnValueEvaluator;
-import org.drools.spi.ReturnValueExpression;
-import org.drools.util.StringUtils;
-import org.drools.workflow.core.node.ActionNode;
-import org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator;
-
-public class JavaDialectData
-    implements
-    DialectData,
-    Externalizable {
-
-    /**
-     *
-     */
-    private static final long             serialVersionUID = 400L;
-
-    private static final ProtectionDomain PROTECTION_DOMAIN;
-
-    private Map                           invokerLookups;
-
-    private Object                        AST;
-
-    private Map                           store;
-
-    private DialectDatas                  datas;
-
-    private transient PackageClassLoader  classLoader;
-
-    private boolean                       dirty;
-
-    static {
-        PROTECTION_DOMAIN = (ProtectionDomain) AccessController.doPrivileged( new PrivilegedAction() {
-            public Object run() {
-                return JavaDialectData.class.getProtectionDomain();
-            }
-        } );
-    }
-
-    /**
-     * Default constructor - for Externalizable. This should never be used by a user, as it
-     * will result in an invalid state for the instance.
-     */
-    public JavaDialectData() {
-    }
-
-    public JavaDialectData(final DialectDatas datas) {
-        this.datas = datas;
-        this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader(), this );
-        this.datas.addClassLoader( this.classLoader );
-        this.invokerLookups = new HashMap();
-        this.store = new HashMap();
-        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;
-    }
-
-    public void setDirty(boolean dirty) {
-        this.dirty = dirty;
-    }
-
-    /**
-     * Handles the write serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
-     * default methods. The PackageCompilationData holds a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
-     *
-     */
-    public void writeExternal(ObjectOutput stream) throws IOException {
-        stream.writeObject( this.store );
-        stream.writeObject( this.AST );
-        stream.writeObject( this.invokerLookups );
-        stream.writeBoolean( this.dirty );
-    }
-
-    /**
-     * Handles the read serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
-     * default methods. The PackageCompilationData holds a reference to the generated bytecode; which must be restored before any Rules.
-     * A custom ObjectInputStream, able to resolve classes against the bytecode, is used to restore the Rules.
-     *
-     */
-    public void readExternal(ObjectInput stream) throws IOException,
-                                                      ClassNotFoundException {
-        DroolsObjectInput droolsStream = (DroolsObjectInput)stream;
-
-        this.datas          = droolsStream.getDialectDatas();
-        this.classLoader    = new PackageClassLoader( this.datas.getParentClassLoader(), this );
-        this.datas.addClassLoader( this.classLoader );
-
-        this.store = (Map) stream.readObject();
-        this.AST = stream.readObject();
-        this.invokerLookups = (Map) droolsStream.readObject();
-        this.dirty  = droolsStream.readBoolean();
-    }
-
-    protected Map getStore() {
-        if (store == null) {
-            store = new HashMap();
-        }
-        return store;
-    }
-
-    public ClassLoader getClassLoader() {
-        return this.classLoader;
-    }
-
-    public void removeRule(Package pkg,
-                           Rule rule) {
-        final String consequenceName = rule.getConsequence().getClass().getName();
-
-        // check for compiled code and remove if present.
-        if ( remove( consequenceName ) ) {
-            removeClasses( rule.getLhs() );
-
-            // Now remove the rule class - the name is a subset of the consequence name
-            remove( consequenceName.substring( 0,
-                                               consequenceName.indexOf( "ConsequenceInvoker" ) ) );
-        }
-    }
-
-    public void removeFunction(Package pkg,
-                               Function function) {
-        remove( pkg.getName() + "." + StringUtils.ucFirst( function.getName() ) );
-    }
-
-    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.
-        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
-        putAllInvokers( newJavaData.getInvokers() );
-    }
-
-    private void removeClasses(final ConditionalElement ce) {
-        if ( ce instanceof GroupElement ) {
-            final GroupElement group = (GroupElement) ce;
-            for ( final Iterator it = group.getChildren().iterator(); it.hasNext(); ) {
-                final Object object = it.next();
-                if ( object instanceof ConditionalElement ) {
-                    removeClasses( (ConditionalElement) object );
-                } else if ( object instanceof Pattern ) {
-                    removeClasses( (Pattern) object );
-                }
-            }
-        } else if ( ce instanceof EvalCondition ) {
-            remove( ((EvalCondition) ce).getEvalExpression().getClass().getName() );
-        }
-    }
-
-    private void removeClasses(final Pattern pattern) {
-        for ( final Iterator it = pattern.getConstraints().iterator(); it.hasNext(); ) {
-            final Object object = it.next();
-            if ( object instanceof PredicateConstraint ) {
-                remove( ((PredicateConstraint) object).getPredicateExpression().getClass().getName() );
-            } else if ( object instanceof ReturnValueConstraint ) {
-                remove( ((ReturnValueConstraint) object).getExpression().getClass().getName() );
-            }
-        }
-    }
-
-    public byte[] read(final String resourceName) {
-        byte[] bytes = null;
-
-        if ( !getStore().isEmpty()) {
-            bytes = (byte[])getStore().get( resourceName );
-        }
-        return bytes;
-    }
-
-    public void write(final String resourceName,
-                      final byte[] clazzData) throws RuntimeDroolsException {
-        if ( getStore().put( resourceName,
-                             clazzData ) != null ) {
-            // we are updating an existing class so reload();
-            //reload();
-            this.dirty = true;
-        } else {
-            try {
-                wire( convertResourceToClassName( resourceName ) );
-            } catch ( final Exception e ) {
-                e.printStackTrace();
-                throw new RuntimeDroolsException( e );
-            }
-        }
-
-    }
-
-    public boolean remove(final String resourceName) throws RuntimeDroolsException {
-        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;
-            return true;
-        }
-        return false;
-    }
-
-    public String[] list() {
-        String[] names = new String[getStore().size()];
-        int i = 0;
-
-        for ( Object object : getStore().keySet()) {
-            names[i++] = (String)object;
-        }
-        return names;
-    }
-
-    /**
-     * This class drops the classLoader and reloads it. During this process  it must re-wire all the invokeables.
-     * @throws RuntimeDroolsException
-     */
-    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 Object object : getInvokers().entrySet() ) {
-                Entry entry = (Entry) object;
-                wire( (String) entry.getKey(),
-                      entry.getValue() );
-            }
-        } catch ( final ClassNotFoundException e ) {
-            throw new RuntimeDroolsException( e );
-        } catch ( final InstantiationError e ) {
-            throw new RuntimeDroolsException( e );
-        } catch ( final IllegalAccessException e ) {
-            throw new RuntimeDroolsException( e );
-        } catch ( final InstantiationException e ) {
-            throw new RuntimeDroolsException( e );
-        } finally {
-            this.dirty = false;
-        }
-    }
-
-    public void clear() {
-        getStore().clear();
-        getInvokers().clear();
-        this.AST = null;
-        reload();
-    }
-
-    public void wire(final String className) throws ClassNotFoundException,
-                                            InstantiationException,
-                                            IllegalAccessException {
-        final Object invoker = getInvokers().get( className );
-        wire( className,
-              invoker );
-    }
-
-    public void wire(final String className,
-                     final Object invoker) throws ClassNotFoundException,
-                                          InstantiationException,
-                                          IllegalAccessException {
-        final Class clazz = ((CompositePackageClassLoader)this.datas.getClassLoader()).findClass( className );
-
-        if (clazz != null) {
-            if ( invoker instanceof ReturnValueRestriction ) {
-                ((ReturnValueRestriction) invoker).setReturnValueExpression( (ReturnValueExpression) clazz.newInstance() );
-            } else if ( invoker instanceof PredicateConstraint ) {
-                ((PredicateConstraint) invoker).setPredicateExpression( (PredicateExpression) clazz.newInstance() );
-            } else if ( invoker instanceof EvalCondition ) {
-                ((EvalCondition) invoker).setEvalExpression( (EvalExpression) clazz.newInstance() );
-            } else if ( invoker instanceof Accumulate ) {
-                ((Accumulate) invoker).setAccumulator( (Accumulator) clazz.newInstance() );
-            } else if ( invoker instanceof Rule ) {
-                ((Rule) invoker).setConsequence( (Consequence) clazz.newInstance() );
-            } else if ( invoker instanceof JavaAccumulatorFunctionExecutor ) {
-                ((JavaAccumulatorFunctionExecutor) invoker).setExpression( (ReturnValueExpression) clazz.newInstance() );
-            } else if ( invoker instanceof ActionNode ) {
-                ((ActionNode) invoker).setAction( clazz.newInstance() );
-            } else if ( invoker instanceof ReturnValueConstraintEvaluator ) {
-                ((ReturnValueConstraintEvaluator) invoker).setEvaluator( (ReturnValueEvaluator) clazz.newInstance() );
-            }
-        }
-        else {
-            throw new ClassNotFoundException(className);
-        }
-    }
-
-    public String toString() {
-        return this.getClass().getName() +getStore().toString();
-    }
-
-    public void putInvoker(final String className,
-                           final Object invoker) {
-        getInvokers().put( className,
-                                 invoker );
-    }
-
-    public void putAllInvokers(final Map invokers) {
-        getInvokers().putAll( invokers );
-
-    }
-
-    public Map getInvokers() {
-        if (this.invokerLookups == null) {
-            this.invokerLookups = new HashMap();
-        }
-        return this.invokerLookups;
-    }
-
-    public void removeInvoker(final String className) {
-        getInvokers().remove( className );
-    }
-
-    public Object getAST() {
-        return this.AST;
-    }
-
-    public void setAST(final Object ast) {
-        this.AST = ast;
-    }
-
-    /**
-     * Lifted and adapted from Jakarta commons-jci
-     *
-     * @author mproctor
-     *
-     */
-    public static class PackageClassLoader extends ClassLoader
-        implements
-        DroolsClassLoader {
-        private JavaDialectData parent;
-
-        public PackageClassLoader() {
-        }
-
-        public PackageClassLoader(final ClassLoader parentClassLoader, JavaDialectData parent) {
-            super( parentClassLoader );
-            this.parent = parent;
-        }
-
-        public Class fastFindClass(final String name) {
-            final Class clazz = findLoadedClass( name );
-
-            if ( clazz == null && parent != null) {
-                final byte[] clazzBytes = parent.read( convertClassToResourcePath( name ) );
-                if ( clazzBytes != null ) {
-                    return defineClass( name,
-                                        clazzBytes,
-                                        0,
-                                        clazzBytes.length,
-                                        PROTECTION_DOMAIN );
-                }
-            }
-
-            return clazz;
-        }
-
-        /**
-         * Javadocs recommend that this method not be overloaded. We overload this so that we can prioritise the fastFindClass
-         * over method calls to parent.loadClass(name, false); and c = findBootstrapClass0(name); which the default implementation
-         * would first - hence why we call it "fastFindClass" instead of standard findClass, this indicates that we give it a
-         * higher priority than normal.
-         *
-         */
-        protected synchronized Class loadClass(final String name,
-                                               final boolean resolve) throws ClassNotFoundException {
-            Class clazz = fastFindClass( name );
-
-            if ( clazz == null ) {
-                final ClassLoader parent = getParent();
-                if ( parent != null ) {
-                    clazz = Class.forName( name,
-                                           true,
-                                           parent );
-                }
-            }
-
-            if ( resolve && clazz != null) {
-                resolveClass( clazz );
-            }
-
-            return clazz;
-        }
-
-        protected Class findClass(final String name) throws ClassNotFoundException {
-            return fastFindClass( name );
-        }
-
-        public InputStream getResourceAsStream(final String name) {
-            final byte[] bytes = (byte[]) parent.store.get( name );
-            if ( bytes != null ) {
-                return new ByteArrayInputStream( bytes );
-            } else {
-                InputStream input = this.getParent().getResourceAsStream( name );
-                if ( input == null ) {
-                    input = super.getResourceAsStream( name );
-                }
-                return input;
-            }
-        }
-    }
-
-    /**
-     * Please do not use - internal
-     * org/my/Class.xxx -> org.my.Class
-     */
-    public static String convertResourceToClassName(final String pResourceName) {
-        return stripExtension( pResourceName ).replace( '/',
-                                                        '.' );
-    }
-
-    /**
-     * Please do not use - internal
-     * org.my.Class -> org/my/Class.class
-     */
-    public static String convertClassToResourcePath(final String pName) {
-        return pName.replace( '.',
-                              '/' ) + ".class";
-    }
-
-    /**
-     * Please do not use - internal
-     * org/my/Class.xxx -> org/my/Class
-     */
-    public static String stripExtension(final String pResourceName) {
-        final int i = pResourceName.lastIndexOf( '.' );
-        final String withoutExtension = pResourceName.substring( 0,
-                                                                 i );
-        return withoutExtension;
-    }
-
-}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectRuntimeData.java (from rev 20678, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectData.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectRuntimeData.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/JavaDialectRuntimeData.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -0,0 +1,491 @@
+package org.drools.rule;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.drools.RuntimeDroolsException;
+import org.drools.base.accumulators.JavaAccumulatorFunctionExecutor;
+import org.drools.common.DroolsObjectInput;
+import org.drools.spi.Accumulator;
+import org.drools.spi.Consequence;
+import org.drools.spi.EvalExpression;
+import org.drools.spi.PredicateExpression;
+import org.drools.spi.ReturnValueEvaluator;
+import org.drools.spi.ReturnValueExpression;
+import org.drools.util.StringUtils;
+import org.drools.workflow.core.node.ActionNode;
+import org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator;
+
+public class JavaDialectRuntimeData
+    implements
+    DialectRuntimeData,
+    Externalizable {
+
+    /**
+     *
+     */
+    private static final long             serialVersionUID = 400L;
+
+    private static final ProtectionDomain PROTECTION_DOMAIN;
+
+    private Map                           invokerLookups;
+
+    private Object                        AST;
+
+    private Map                           store;
+
+    private DialectRuntimeRegistry        datas;
+
+    private transient PackageClassLoader  classLoader;
+
+    private boolean                       dirty;
+
+    static {
+        PROTECTION_DOMAIN = (ProtectionDomain) AccessController.doPrivileged( new PrivilegedAction() {
+            public Object run() {
+                return JavaDialectRuntimeData.class.getProtectionDomain();
+            }
+        } );
+    }
+
+    /**
+     * Default constructor - for Externalizable. This should never be used by a user, as it
+     * will result in an invalid state for the instance.
+     */
+    public JavaDialectRuntimeData() {
+    }
+
+    public JavaDialectRuntimeData(final DialectRuntimeRegistry datas) {
+        this.datas = datas;
+        this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader(), this );
+        this.datas.addClassLoader( this.classLoader );
+        this.invokerLookups = new HashMap();
+        this.store = new HashMap();
+        this.dirty = false;
+    }
+
+    public DialectRuntimeData clone() {
+        DialectRuntimeData cloneOne = new JavaDialectRuntimeData();
+
+        cloneOne.merge(this);
+        return cloneOne;
+    }
+
+    public boolean isDirty() {
+        return this.dirty;
+    }
+
+    public void setDirty(boolean dirty) {
+        this.dirty = dirty;
+    }
+
+    /**
+     * Handles the write serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
+     * default methods. The PackageCompilationData holds a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
+     *
+     */
+    public void writeExternal(ObjectOutput stream) throws IOException {
+        stream.writeObject( this.store );
+        stream.writeObject( this.AST );
+        stream.writeObject( this.invokerLookups );
+        stream.writeBoolean( this.dirty );
+    }
+
+    /**
+     * Handles the read serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
+     * default methods. The PackageCompilationData holds a reference to the generated bytecode; which must be restored before any Rules.
+     * A custom ObjectInputStream, able to resolve classes against the bytecode, is used to restore the Rules.
+     *
+     */
+    public void readExternal(ObjectInput stream) throws IOException,
+                                                      ClassNotFoundException {
+        DroolsObjectInput droolsStream = (DroolsObjectInput)stream;
+
+        this.datas          = droolsStream.getDialectRuntimeRegistry();
+        this.classLoader    = new PackageClassLoader( this.datas.getParentClassLoader(), this );
+        this.datas.addClassLoader( this.classLoader );
+
+        this.store = (Map) stream.readObject();
+        this.AST = stream.readObject();
+        this.invokerLookups = (Map) droolsStream.readObject();
+        this.dirty  = droolsStream.readBoolean();
+    }
+
+    protected Map getStore() {
+        if (store == null) {
+            store = new HashMap();
+        }
+        return store;
+    }
+
+    public ClassLoader getClassLoader() {
+        return this.classLoader;
+    }
+
+    public void removeRule(Package pkg,
+                           Rule rule) {
+        final String consequenceName = rule.getConsequence().getClass().getName();
+
+        // check for compiled code and remove if present.
+        if ( remove( consequenceName ) ) {
+            removeClasses( rule.getLhs() );
+
+            // Now remove the rule class - the name is a subset of the consequence name
+            remove( consequenceName.substring( 0,
+                                               consequenceName.indexOf( "ConsequenceInvoker" ) ) );
+        }
+    }
+
+    public void removeFunction(Package pkg,
+                               Function function) {
+        remove( pkg.getName() + "." + StringUtils.ucFirst( function.getName() ) );
+    }
+
+    public void merge(DialectRuntimeData newData) {
+        JavaDialectRuntimeData newJavaData = (JavaDialectRuntimeData) newData;
+
+        this.datas = newJavaData.datas;
+        
+        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.
+        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
+        putAllInvokers( newJavaData.getInvokers() );
+    }
+
+    private void removeClasses(final ConditionalElement ce) {
+        if ( ce instanceof GroupElement ) {
+            final GroupElement group = (GroupElement) ce;
+            for ( final Iterator it = group.getChildren().iterator(); it.hasNext(); ) {
+                final Object object = it.next();
+                if ( object instanceof ConditionalElement ) {
+                    removeClasses( (ConditionalElement) object );
+                } else if ( object instanceof Pattern ) {
+                    removeClasses( (Pattern) object );
+                }
+            }
+        } else if ( ce instanceof EvalCondition ) {
+            remove( ((EvalCondition) ce).getEvalExpression().getClass().getName() );
+        }
+    }
+
+    private void removeClasses(final Pattern pattern) {
+        for ( final Iterator it = pattern.getConstraints().iterator(); it.hasNext(); ) {
+            final Object object = it.next();
+            if ( object instanceof PredicateConstraint ) {
+                remove( ((PredicateConstraint) object).getPredicateExpression().getClass().getName() );
+            } else if ( object instanceof ReturnValueConstraint ) {
+                remove( ((ReturnValueConstraint) object).getExpression().getClass().getName() );
+            }
+        }
+    }
+
+    public byte[] read(final String resourceName) {
+        byte[] bytes = null;
+
+        if ( !getStore().isEmpty()) {
+            bytes = (byte[])getStore().get( resourceName );
+        }
+        return bytes;
+    }
+
+    public void write(final String resourceName,
+                      final byte[] clazzData) throws RuntimeDroolsException {
+        if ( getStore().put( resourceName,
+                             clazzData ) != null ) {
+            // we are updating an existing class so reload();
+            //reload();
+            this.dirty = true;
+        } else {
+            try {
+                wire( convertResourceToClassName( resourceName ) );
+            } catch ( final Exception e ) {
+                e.printStackTrace();
+                throw new RuntimeDroolsException( e );
+            }
+        }
+
+    }
+
+    public boolean remove(final String resourceName) throws RuntimeDroolsException {
+        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;
+            return true;
+        }
+        return false;
+    }
+
+    public String[] list() {
+        String[] names = new String[getStore().size()];
+        int i = 0;
+
+        for ( Object object : getStore().keySet()) {
+            names[i++] = (String)object;
+        }
+        return names;
+    }
+
+    /**
+     * This class drops the classLoader and reloads it. During this process  it must re-wire all the invokeables.
+     * @throws RuntimeDroolsException
+     */
+    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 Object object : getInvokers().entrySet() ) {
+                Entry entry = (Entry) object;
+                wire( (String) entry.getKey(),
+                      entry.getValue() );
+            }
+        } catch ( final ClassNotFoundException e ) {
+            throw new RuntimeDroolsException( e );
+        } catch ( final InstantiationError e ) {
+            throw new RuntimeDroolsException( e );
+        } catch ( final IllegalAccessException e ) {
+            throw new RuntimeDroolsException( e );
+        } catch ( final InstantiationException e ) {
+            throw new RuntimeDroolsException( e );
+        } finally {
+            this.dirty = false;
+        }
+    }
+
+    public void clear() {
+        getStore().clear();
+        getInvokers().clear();
+        this.AST = null;
+        reload();
+    }
+
+    public void wire(final String className) throws ClassNotFoundException,
+                                            InstantiationException,
+                                            IllegalAccessException {
+        final Object invoker = getInvokers().get( className );
+        wire( className,
+              invoker );
+    }
+
+    public void wire(final String className,
+                     final Object invoker) throws ClassNotFoundException,
+                                          InstantiationException,
+                                          IllegalAccessException {
+        final Class clazz = ((CompositePackageClassLoader)this.datas.getClassLoader()).findClass( className );
+
+        if (clazz != null) {
+            if ( invoker instanceof ReturnValueRestriction ) {
+                ((ReturnValueRestriction) invoker).setReturnValueExpression( (ReturnValueExpression) clazz.newInstance() );
+            } else if ( invoker instanceof PredicateConstraint ) {
+                ((PredicateConstraint) invoker).setPredicateExpression( (PredicateExpression) clazz.newInstance() );
+            } else if ( invoker instanceof EvalCondition ) {
+                ((EvalCondition) invoker).setEvalExpression( (EvalExpression) clazz.newInstance() );
+            } else if ( invoker instanceof Accumulate ) {
+                ((Accumulate) invoker).setAccumulator( (Accumulator) clazz.newInstance() );
+            } else if ( invoker instanceof Rule ) {
+                ((Rule) invoker).setConsequence( (Consequence) clazz.newInstance() );
+            } else if ( invoker instanceof JavaAccumulatorFunctionExecutor ) {
+                ((JavaAccumulatorFunctionExecutor) invoker).setExpression( (ReturnValueExpression) clazz.newInstance() );
+            } else if ( invoker instanceof ActionNode ) {
+                ((ActionNode) invoker).setAction( clazz.newInstance() );
+            } else if ( invoker instanceof ReturnValueConstraintEvaluator ) {
+                ((ReturnValueConstraintEvaluator) invoker).setEvaluator( (ReturnValueEvaluator) clazz.newInstance() );
+            }
+        }
+        else {
+            throw new ClassNotFoundException(className);
+        }
+    }
+
+    public String toString() {
+        return this.getClass().getName() +getStore().toString();
+    }
+
+    public void putInvoker(final String className,
+                           final Object invoker) {
+        getInvokers().put( className,
+                                 invoker );
+    }
+
+    public void putAllInvokers(final Map invokers) {
+        getInvokers().putAll( invokers );
+
+    }
+
+    public Map getInvokers() {
+        if (this.invokerLookups == null) {
+            this.invokerLookups = new HashMap();
+        }
+        return this.invokerLookups;
+    }
+
+    public void removeInvoker(final String className) {
+        getInvokers().remove( className );
+    }
+
+    public Object getAST() {
+        return this.AST;
+    }
+
+    public void setAST(final Object ast) {
+        this.AST = ast;
+    }
+
+    /**
+     * Lifted and adapted from Jakarta commons-jci
+     *
+     * @author mproctor
+     *
+     */
+    public static class PackageClassLoader extends ClassLoader
+        implements
+        DroolsClassLoader {
+        private JavaDialectRuntimeData parent;
+
+        public PackageClassLoader() {
+        }
+
+        public PackageClassLoader(final ClassLoader parentClassLoader, JavaDialectRuntimeData parent) {
+            super( parentClassLoader );
+            this.parent = parent;
+        }
+
+        public Class fastFindClass(final String name) {
+            final Class clazz = findLoadedClass( name );
+
+            if ( clazz == null && parent != null) {
+                final byte[] clazzBytes = parent.read( convertClassToResourcePath( name ) );
+                if ( clazzBytes != null ) {
+                    return defineClass( name,
+                                        clazzBytes,
+                                        0,
+                                        clazzBytes.length,
+                                        PROTECTION_DOMAIN );
+                }
+            }
+
+            return clazz;
+        }
+
+        /**
+         * Javadocs recommend that this method not be overloaded. We overload this so that we can prioritise the fastFindClass
+         * over method calls to parent.loadClass(name, false); and c = findBootstrapClass0(name); which the default implementation
+         * would first - hence why we call it "fastFindClass" instead of standard findClass, this indicates that we give it a
+         * higher priority than normal.
+         *
+         */
+        protected synchronized Class loadClass(final String name,
+                                               final boolean resolve) throws ClassNotFoundException {
+            Class clazz = fastFindClass( name );
+
+            if ( clazz == null ) {
+                final ClassLoader parent = getParent();
+                if ( parent != null ) {
+                    clazz = Class.forName( name,
+                                           true,
+                                           parent );
+                }
+            }
+
+            if ( resolve && clazz != null) {
+                resolveClass( clazz );
+            }
+
+            return clazz;
+        }
+
+        protected Class findClass(final String name) throws ClassNotFoundException {
+            return fastFindClass( name );
+        }
+
+        public InputStream getResourceAsStream(final String name) {
+            final byte[] bytes = (byte[]) parent.store.get( name );
+            if ( bytes != null ) {
+                return new ByteArrayInputStream( bytes );
+            } else {
+                InputStream input = this.getParent().getResourceAsStream( name );
+                if ( input == null ) {
+                    input = super.getResourceAsStream( name );
+                }
+                return input;
+            }
+        }
+    }
+
+    /**
+     * Please do not use - internal
+     * org/my/Class.xxx -> org.my.Class
+     */
+    public static String convertResourceToClassName(final String pResourceName) {
+        return stripExtension( pResourceName ).replace( '/',
+                                                        '.' );
+    }
+
+    /**
+     * Please do not use - internal
+     * org.my.Class -> org/my/Class.class
+     */
+    public static String convertClassToResourcePath(final String pName) {
+        return pName.replace( '.',
+                              '/' ) + ".class";
+    }
+
+    /**
+     * Please do not use - internal
+     * org/my/Class.xxx -> org/my/Class
+     */
+    public static String stripExtension(final String pResourceName) {
+        final int i = pResourceName.lastIndexOf( '.' );
+        final String withoutExtension = pResourceName.substring( 0,
+                                                                 i );
+        return withoutExtension;
+    }
+
+}
\ No newline at end of file

Deleted: 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-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -1,109 +0,0 @@
-package org.drools.rule;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.mvel.ast.Function;
-import org.mvel.integration.VariableResolver;
-import org.mvel.integration.impl.MapVariableResolverFactory;
-
-public class MVELDialectData implements DialectData, Externalizable {
-	private MapFunctionResolverFactory functionFactory;
-
-	/**
-	 * Default constructor - for Externalizable. This should never be used by a
-	 * user, as it will result in an invalid state for the instance.
-	 */
-	public MVELDialectData() {
-        this(null);
-	}
-
-	public MVELDialectData(final DialectDatas datas) {
-		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;
-	}
-
-	public void removeRule(Package pkg, Rule rule) {
-	}
-
-	public void addFunction(Function function) {
-		this.functionFactory.addFunction(function);
-	}
-
-	public void removeFunction(Package pkg, org.drools.rule.Function function) {
-		this.functionFactory.removeFunction(function.getName());
-
-	}
-
-	public boolean isDirty() {
-		return false;
-	}
-
-    public void setDirty(boolean dirty) {
-    }
-
-    public void merge(DialectData newData) {
-	}
-
-	public void reload() {
-	}
-
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-    }
-
-    public void writeExternal(ObjectOutput out) throws IOException {
-    }
-
-    public static class MapFunctionResolverFactory extends
-                                                   MapVariableResolverFactory implements Externalizable {
-
-        public MapFunctionResolverFactory() {
-            super(new HashMap<String, Object>());
-        }
-
-        public void writeExternal(ObjectOutput out) throws IOException {
-            out.writeObject( this.variables );
-        }
-
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            this.variables = ( Map ) in.readObject();
-        }
-
-        public void addFunction(Function function) {
-            this.variables.put(function.getName(), function);
-        }
-
-        public void removeFunction(String functionName) {
-            this.variables.remove(functionName);
-            this.variableResolvers.remove(functionName);
-        }
-
-        public VariableResolver createVariable(String name, Object value) {
-            throw new RuntimeException(
-                    "variable is a read-only function pointer");
-        }
-
-        public VariableResolver createIndexedVariable(int index, String name,
-                                                      Object value, Class<?> type) {
-            throw new RuntimeException(
-                    "variable is a read-only function pointer");
-        }
-    }
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectRuntimeData.java (from rev 20678, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectRuntimeData.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectRuntimeData.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -0,0 +1,105 @@
+package org.drools.rule;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.mvel.ast.Function;
+import org.mvel.integration.VariableResolver;
+import org.mvel.integration.impl.MapVariableResolverFactory;
+
+public class MVELDialectRuntimeData implements DialectRuntimeData, Externalizable {
+	private MapFunctionResolverFactory functionFactory;
+
+	/**
+	 * Default constructor - for Externalizable. This should never be used by a
+	 * user, as it will result in an invalid state for the instance.
+	 */
+	public MVELDialectRuntimeData() {
+	}
+
+	public MVELDialectRuntimeData(final DialectRuntimeRegistry datas) {
+		this.functionFactory = new MapFunctionResolverFactory();
+	}
+
+    public DialectRuntimeData clone() {
+        DialectRuntimeData clone = new MVELDialectRuntimeData();
+        clone.merge(this);
+        return clone;
+    }
+
+	public MapFunctionResolverFactory getFunctionFactory() {
+		return this.functionFactory;
+	}
+
+	public void removeRule(Package pkg, Rule rule) {
+	}
+
+	public void addFunction(Function function) {
+		this.functionFactory.addFunction(function);
+	}
+
+	public void removeFunction(Package pkg, org.drools.rule.Function function) {
+		this.functionFactory.removeFunction(function.getName());
+
+	}
+
+	public boolean isDirty() {
+		return false;
+	}
+
+    public void setDirty(boolean dirty) {
+    }
+
+    public void merge(DialectRuntimeData newData) {
+	}
+
+	public void reload() {
+	}
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public static class MapFunctionResolverFactory extends
+                                                   MapVariableResolverFactory implements Externalizable {
+
+        public MapFunctionResolverFactory() {
+            super(new HashMap<String, Object>());
+        }
+
+        public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeObject( this.variables );
+        }
+
+        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            this.variables = ( Map ) in.readObject();
+        }
+
+        public void addFunction(Function function) {
+            this.variables.put(function.getName(), function);
+        }
+
+        public void removeFunction(String functionName) {
+            this.variables.remove(functionName);
+            this.variableResolvers.remove(functionName);
+        }
+
+        public VariableResolver createVariable(String name, Object value) {
+            throw new RuntimeException(
+                    "variable is a read-only function pointer");
+        }
+
+        public VariableResolver createIndexedVariable(int index, String name,
+                                                      Object value, Class<?> type) {
+            throw new RuntimeException(
+                    "variable is a read-only function pointer");
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Namespaceable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Namespaceable.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Namespaceable.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -0,0 +1,7 @@
+package org.drools.rule;
+
+public interface Namespaceable {
+    public String getNamespace();
+    
+    public void setNamespace(String namespace);
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -78,7 +78,7 @@
     private Map                            ruleFlows;
 
     // private JavaDialectData packageCompilationData;
-    private DialectDatas                   dialectDatas;
+    private DialectRuntimeRegistry         dialectRuntimeRegistry;
 
     private Map<String, TypeDeclaration>   typeDeclarations;
 
@@ -149,9 +149,9 @@
             }
         }
         this.packageScopeClassLoader = new MapBackedClassLoader( parentClassLoader );
-        this.dialectDatas = new DialectDatas( this.packageScopeClassLoader );
+        this.dialectRuntimeRegistry = new DialectRuntimeRegistry( this.packageScopeClassLoader );
     }
-    
+
     /**
      * Construct.
      * 
@@ -159,7 +159,7 @@
      *            The name of this <code>Package</code>.
      */
     public Package(final String name,
-                   final MapBackedClassLoader packageClassLoader ) {
+                   final MapBackedClassLoader packageClassLoader) {
         this.name = name;
         this.imports = new HashMap<String, ImportDeclaration>();
         this.typeDeclarations = new HashMap<String, TypeDeclaration>();
@@ -170,7 +170,7 @@
         this.factTemplates = Collections.EMPTY_MAP;
         this.functions = Collections.EMPTY_MAP;
 
-        if( packageClassLoader == null ) {
+        if ( packageClassLoader == null ) {
             ClassLoader parentClassLoader = null;
             // This classloader test should only be here for unit testing, too much
             // legacy api to want to change by hand at the moment
@@ -184,9 +184,8 @@
         } else {
             this.packageScopeClassLoader = packageClassLoader;
         }
-        this.dialectDatas = new DialectDatas( this.packageScopeClassLoader );
+        this.dialectRuntimeRegistry = new DialectRuntimeRegistry( this.packageScopeClassLoader );
     }
-    
 
     /**
      * Handles the write serialization of the Package. Patterns in Rules may
@@ -212,7 +211,7 @@
             out = new DroolsObjectOutputStream( bytes );
         }
         out.writeObject( this.packageScopeClassLoader.getStore() );
-        out.writeObject( this.dialectDatas );
+        out.writeObject( this.dialectRuntimeRegistry );
         out.writeObject( this.typeDeclarations );
         out.writeObject( this.name );
         out.writeObject( this.imports );
@@ -257,7 +256,7 @@
 
         // setting parent classloader for dialect datas
         in.setClassLoader( this.packageScopeClassLoader );
-        this.dialectDatas = (DialectDatas) in.readObject();
+        this.dialectRuntimeRegistry = (DialectRuntimeRegistry) in.readObject();
 
         this.typeDeclarations = (Map) in.readObject();
         this.name = (String) in.readObject();
@@ -291,8 +290,8 @@
         return this.name;
     }
 
-    public DialectDatas getDialectDatas() {
-        return this.dialectDatas;
+    public DialectRuntimeRegistry getDialectRuntimeRegistry() {
+        return this.dialectRuntimeRegistry;
     }
 
     public void addImport(final ImportDeclaration importDecl) {
@@ -339,7 +338,7 @@
 
         this.functions.put( function.getName(),
                             function );
-        dialectDatas.getDialectData( function.getDialect() ).setDirty( true );
+        dialectRuntimeRegistry.getDialectData( function.getDialect() ).setDirty( true );
     }
 
     public Map<String, Function> getFunctions() {
@@ -374,8 +373,8 @@
     public void removeFunction(final String functionName) {
         Function function = this.functions.remove( functionName );
         if ( function != null ) {
-            this.dialectDatas.removeFunction( this,
-                                              function );
+            this.dialectRuntimeRegistry.removeFunction( this,
+                                                        function );
         }
     }
 
@@ -442,8 +441,8 @@
 
     public void removeRule(final Rule rule) {
         this.rules.remove( rule.getName() );
-        this.dialectDatas.removeRule( this,
-                                      rule );
+        this.dialectRuntimeRegistry.removeRule( this,
+                                                rule );
         // final String consequenceName =
         // rule.getConsequence().getClass().getName();
         //
@@ -592,7 +591,7 @@
 
     public void clear() {
         this.rules.clear();
-        this.dialectDatas.clear();
+        this.dialectRuntimeRegistry.clear();
         this.ruleFlows.clear();
         this.imports.clear();
         this.functions.clear();

Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java	2008-06-23 15:35:51 UTC (rev 20702)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java	2008-06-23 17:36:39 UTC (rev 20703)
@@ -30,8 +30,10 @@
 
     public void testCodeSourceUrl() throws IOException {
         final String className = TestEvalExpression.class.getName();
-
-        final JavaDialectData pcData = new JavaDialectData( new DialectDatas(getClass().getClassLoader()) );
+        
+        final JavaDialectRuntimeData pcData = new JavaDialectRuntimeData( new DialectRuntimeRegistry( getClass().getClassLoader() ) );
+        
+        
         final EvalCondition invoker = new EvalCondition(null);
         pcData.putInvoker(className, invoker);
         final InputStream is = getClass().getClassLoader().getResourceAsStream(className.replace('.', '/') + ".class");




More information about the jboss-svn-commits mailing list