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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Feb 8 08:02:34 EST 2008


Author: mark.proctor at jboss.com
Date: 2008-02-08 08:02:34 -0500 (Fri, 08 Feb 2008)
New Revision: 18413

Modified:
   labs/jbossrules/trunk/drools-core/.classpath
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java
Log:
JBRULES-720 Clips Parser
-Factory added to hold MVEL functions is not serializable, so changed it to Externalizable.

Modified: labs/jbossrules/trunk/drools-core/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-core/.classpath	2008-02-08 12:15:24 UTC (rev 18412)
+++ labs/jbossrules/trunk/drools-core/.classpath	2008-02-08 13:02:34 UTC (rev 18413)
@@ -5,8 +5,8 @@
   <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/org/mvel/mvel/2.0-alpha2-dp3-java1.5/mvel-2.0-alpha2-dp3-java1.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.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-alpha2-dp3-java1.5/mvel-2.0-alpha2-dp3-java1.5.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/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java	2008-02-08 12:15:24 UTC (rev 18412)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java	2008-02-08 13:02:34 UTC (rev 18413)
@@ -250,8 +250,10 @@
                     }
                     proxy = (ShadowProxy) this.instantiator.newInstance();
                 }
+                
                 proxy.setShadowedObject( fact );
             } catch ( final Exception e ) {
+            	System.out.println( "shadow: " +proxy.getClass() + ":" + fact.getClass() );
                 throw new RuntimeDroolsException( "Error creating shadow fact for object: " + fact,
                                                   e );
             }

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-02-08 12:15:24 UTC (rev 18412)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MVELDialectData.java	2008-02-08 13:02:34 UTC (rev 18413)
@@ -1,81 +1,91 @@
 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, Serializable {
-    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() {
+	private MapFunctionResolverFactory functionFactory;
 
-    }
-    
-    public MVELDialectData(final DialectDatas datas) {
-        this.functionFactory = new MapFunctionResolverFactory( );
-    }
-    
-    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() );
-        
-    }    
+	/**
+	 * 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() {
 
-    public boolean isDirty() {
-        return false;
-    }
+	}
 
-    public void merge(DialectData newData) {        
-    }
+	public MVELDialectData(final DialectDatas datas) {
+		this.functionFactory = new MapFunctionResolverFactory();
+	}
 
-    public void reload() {
-    }
-    
-    public static class MapFunctionResolverFactory extends MapVariableResolverFactory implements Serializable {
-        
-        public MapFunctionResolverFactory() {
-            super(new HashMap<String, Object>() );
-        }
-        
-        
-        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" );
-        }
-    }
+	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 merge(DialectData newData) {
+	}
+
+	public void reload() {
+	}
+
+	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");
+		}
+	}
 }




More information about the jboss-svn-commits mailing list