[jboss-svn-commits] JBL Code SVN: r16763 - in labs/jbossrules/trunk/drools-compiler/src: main/java/org/drools/compiler and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 23 11:34:07 EST 2007


Author: mark.proctor at jboss.com
Date: 2007-11-23 11:34:06 -0500 (Fri, 23 Nov 2007)
New Revision: 16763

Added:
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/commons/jci/stores/RuleBuildError.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ActionError.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ProcessBuildError.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBuildError.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ActionDescr.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ProcessDescr.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ActionBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PackageBuildContext.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessBuildContext.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessClassBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaProcessClassBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java
Removed:
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELRuleClassBuilder.java
Modified:
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/Dialect.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/QueryBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleClassBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaEvalBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaPredicateBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaRuleClassBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELAccumulateBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java
   labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
   labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/AccumulateTemplateTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java
Log:
JBRULES-1197 Extends actions support to include other dialects and callback
-I'm updating PackageBuilder to be able to handle actions. It's still very messy, but all unit tests are currently passing. So I'm  committing now, before I start on more major refactorings.

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/commons/jci/stores/RuleBuildError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/commons/jci/stores/RuleBuildError.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/commons/jci/stores/RuleBuildError.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,20 @@
+package org.drools.commons.jci.stores;
+
+import org.drools.compiler.DescrBuildError;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Rule;
+
+public class RuleBuildError extends DescrBuildError {
+    private final Rule rule;
+    public RuleBuildError(final Rule rule,
+                           final BaseDescr descr,
+                           final Object object,
+                           final String message) {
+              super(descr, descr, object, message);
+              this.rule = rule;
+          }
+    
+    public Rule getRule() {
+        return this.rule;
+    }
+}

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ActionError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ActionError.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ActionError.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,117 @@
+package org.drools.compiler;
+
+/*
+ * 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 org.drools.commons.jci.problems.CompilationProblem;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Rule;
+
+public class ActionError extends DroolsError {
+    private BaseDescr descr;
+    private Object    object;
+    private String    message;
+    private int[]     errorLines = new int[0];
+
+    public ActionError(final BaseDescr descr,
+                     final Object object,
+                     final String message) {
+        super();
+        this.descr = descr;
+        this.object = object;
+        this.message = message;
+    }
+
+    public BaseDescr getDescr() {
+        return this.descr;
+    }
+
+    public Object getObject() {
+        return this.object;
+    }
+    
+    public int[] getErrorLines() {
+        return this.errorLines;
+    }
+
+    /** 
+     * This will return the line number of the error, if possible
+     * Otherwise it will be -1
+     */
+    public int getLine() {
+        return this.descr != null ? this.descr.getLine() : -1;
+    }
+
+    public String getMessage() {
+        String summary = this.message;
+        if ( this.object instanceof CompilationProblem[] ) {
+            final CompilationProblem[] problem = (CompilationProblem[]) this.object;
+            for ( int i = 0; i < problem.length; i++ ) {
+                if (i != 0) {
+                    summary = summary + "\n" + problem[i].getMessage();
+                } else {
+                    summary = summary + " " + problem[i].getMessage();
+                }
+            }
+
+        }
+        return summary;
+    }
+
+    public String toString() {
+        final StringBuffer buf = new StringBuffer();
+        buf.append( this.message );
+        buf.append( " : " );
+        buf.append( "\n" );
+        if ( this.object instanceof CompilationProblem[] ) {
+            final CompilationProblem[] problem = (CompilationProblem[]) this.object;
+            for ( int i = 0; i < problem.length; i++ ) {
+                buf.append( "\t" );
+                buf.append( problem[i] );
+                buf.append( "\n" );
+            }
+        } else if ( this.object != null ) {
+            buf.append( this.object );
+        }
+        return buf.toString();
+    }
+
+//    private String createMessage( String message ) {
+//        StringBuffer detail = new StringBuffer();
+//        detail.append( this.message );
+//        detail.append( " : " );
+//        detail.append( this.rule );
+//        detail.append( "\n" );
+//        if( object instanceof CompilationProblem[] ) {
+//            CompilationProblem[] cp = (CompilationProblem[]) object;
+//            this.errorLines = new int[cp.length];
+//            for( int i = 0; i < cp.length ; i ++ ) {
+//               this.errorLines[i] = cp[i].getStartLine() - this.descr.getOffset() + this.descr.getLine() - 1; 
+//               detail.append( this.rule.getName() );
+//               detail.append( " (line:" );
+//               detail.append( this.errorLines[i] );
+//               detail.append( "): " );
+//               detail.append( cp[i].getMessage() );
+//               detail.append( "\n" );
+//            }
+//        } else {
+//            this.errorLines = new int[0];
+//        }
+//        return "[ "+this.rule.getName()+" : "+message + "\n"+detail.toString()+" ]";
+//    }
+    
+    
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java (from rev 16518, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,125 @@
+package org.drools.compiler;
+
+/*
+ * 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 org.drools.commons.jci.problems.CompilationProblem;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Rule;
+
+public class DescrBuildError extends DroolsError {
+    private BaseDescr      parentDescr;
+    private BaseDescr descr;
+    private Object    object;
+    private String    message;
+    private int[]     errorLines = new int[0];
+
+    public DescrBuildError(final BaseDescr parentDescr,
+                     final BaseDescr descr,
+                     final Object object,
+                     final String message) {
+        super();
+        this.parentDescr = parentDescr;
+        this.descr = descr;
+        this.object = object;
+        this.message = message;
+    }
+
+    public BaseDescr getParentDescr() {
+        return this.parentDescr;
+    }
+
+    public BaseDescr getDescr() {
+        return this.descr;
+    }
+
+    public Object getObject() {
+        return this.object;
+    }
+    
+    public int[] getErrorLines() {
+        return this.errorLines;
+    }
+
+    /** 
+     * This will return the line number of the error, if possible
+     * Otherwise it will be -1
+     */
+    public int getLine() {
+        return this.descr != null ? this.descr.getLine() : -1;
+    }
+
+    public String getMessage() {
+        String summary = this.message;
+        if ( this.object instanceof CompilationProblem[] ) {
+            final CompilationProblem[] problem = (CompilationProblem[]) this.object;
+            for ( int i = 0; i < problem.length; i++ ) {
+                if (i != 0) {
+                    summary = summary + "\n" + problem[i].getMessage();
+                } else {
+                    summary = summary + " " + problem[i].getMessage();
+                }
+            }
+
+        }
+        return summary;
+    }
+
+    public String toString() {
+        final StringBuffer buf = new StringBuffer();
+        buf.append( this.message );
+        buf.append( " : " );
+        buf.append( this.parentDescr );
+        buf.append( "\n" );
+        if ( this.object instanceof CompilationProblem[] ) {
+            final CompilationProblem[] problem = (CompilationProblem[]) this.object;
+            for ( int i = 0; i < problem.length; i++ ) {
+                buf.append( "\t" );
+                buf.append( problem[i] );
+                buf.append( "\n" );
+            }
+        } else if ( this.object != null ) {
+            buf.append( this.object );
+        }
+        return buf.toString();
+    }
+
+//    private String createMessage( String message ) {
+//        StringBuffer detail = new StringBuffer();
+//        detail.append( this.message );
+//        detail.append( " : " );
+//        detail.append( this.rule );
+//        detail.append( "\n" );
+//        if( object instanceof CompilationProblem[] ) {
+//            CompilationProblem[] cp = (CompilationProblem[]) object;
+//            this.errorLines = new int[cp.length];
+//            for( int i = 0; i < cp.length ; i ++ ) {
+//               this.errorLines[i] = cp[i].getStartLine() - this.descr.getOffset() + this.descr.getLine() - 1; 
+//               detail.append( this.rule.getName() );
+//               detail.append( " (line:" );
+//               detail.append( this.errorLines[i] );
+//               detail.append( "): " );
+//               detail.append( cp[i].getMessage() );
+//               detail.append( "\n" );
+//            }
+//        } else {
+//            this.errorLines = new int[0];
+//        }
+//        return "[ "+this.rule.getName()+" : "+message + "\n"+detail.toString()+" ]";
+//    }
+    
+    
+}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/Dialect.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/Dialect.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/Dialect.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -2,6 +2,7 @@
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.base.ClassFieldExtractorCache;
 import org.drools.base.TypeResolver;
@@ -10,10 +11,13 @@
 import org.drools.lang.descr.RuleDescr;
 import org.drools.rule.Package;
 import org.drools.rule.builder.AccumulateBuilder;
+import org.drools.rule.builder.ActionBuilder;
 import org.drools.rule.builder.ConsequenceBuilder;
 import org.drools.rule.builder.FromBuilder;
+import org.drools.rule.builder.PackageBuildContext;
 import org.drools.rule.builder.PatternBuilder;
 import org.drools.rule.builder.PredicateBuilder;
+import org.drools.rule.builder.ProcessClassBuilder;
 import org.drools.rule.builder.QueryBuilder;
 import org.drools.rule.builder.ReturnValueBuilder;
 import org.drools.rule.builder.RuleBuildContext;
@@ -58,20 +62,26 @@
     ReturnValueBuilder getReturnValueBuilder();
 
     ConsequenceBuilder getConsequenceBuilder();
+    
+    ActionBuilder getActionBuilder();
 
     RuleClassBuilder getRuleClassBuilder();
+    
+    ProcessClassBuilder getProcessClassBuilder();
 
     FromBuilder getFromBuilder();
 
     RuleConditionBuilder getBuilder(Class clazz);
 
-    AnalysisResult analyzeExpression(final RuleBuildContext context,
+    AnalysisResult analyzeExpression(final PackageBuildContext context,
                                      final BaseDescr descr,
-                                     final Object content);
+                                     final Object content,
+                                     final Set[] availableIdentifiers);
 
-    AnalysisResult analyzeBlock(final RuleBuildContext context,
+    AnalysisResult analyzeBlock(final PackageBuildContext context,
                                 final BaseDescr descr,
-                                final String text);
+                                final String text,
+                                final Set[] availableIdentifiers);
 
     void compileAll();
 

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -32,6 +32,7 @@
 import org.drools.facttemplates.FactTemplateImpl;
 import org.drools.facttemplates.FieldTemplate;
 import org.drools.facttemplates.FieldTemplateImpl;
+import org.drools.lang.descr.ActionDescr;
 import org.drools.lang.descr.BaseDescr;
 import org.drools.lang.descr.FactTemplateDescr;
 import org.drools.lang.descr.FieldTemplateDescr;
@@ -40,13 +41,22 @@
 import org.drools.lang.descr.GlobalDescr;
 import org.drools.lang.descr.ImportDescr;
 import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.ProcessDescr;
 import org.drools.lang.descr.QueryDescr;
 import org.drools.lang.descr.RuleDescr;
 import org.drools.rule.Package;
 import org.drools.rule.Rule;
+import org.drools.rule.builder.ProcessBuildContext;
 import org.drools.rule.builder.RuleBuildContext;
 import org.drools.rule.builder.RuleBuilder;
+import org.drools.rule.builder.dialect.java.JavaDialect;
 import org.drools.ruleflow.common.core.Process;
+import org.drools.ruleflow.common.core.impl.ProcessImpl;
+import org.drools.ruleflow.core.ActionNode;
+import org.drools.ruleflow.core.Node;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+import org.drools.ruleflow.core.impl.DroolsConsequenceAction;
 import org.drools.xml.XmlPackageReader;
 import org.xml.sax.SAXException;
 
@@ -73,12 +83,12 @@
 
     private ClassFieldExtractorCache    classFieldExtractorCache;
 
-    private RuleBuilder                 builder;
+    private RuleBuilder                 ruleBuilder;
 
     private Dialect                     dialect;
 
     private DialectRegistry             dialectRegistry;
-    
+
     /**
      * Use this when package is starting from scratch.
      */
@@ -90,6 +100,7 @@
     /**
      * This will allow you to merge rules into this pre existing package.
      */
+
     public PackageBuilder(final Package pkg) {
         this( pkg,
               null );
@@ -98,9 +109,9 @@
     /**
      * Pass a specific configuration for the PackageBuilder
      * 
-	 * PackageBuilderConfiguration is not thread safe and it also contains state. Once it is created and used 
-	 * in one or more PackageBuilders it should be considered immutable. Do not modify its 
-	 * properties while it is being used by a PackageBuilder.
+     * PackageBuilderConfiguration is not thread safe and it also contains state. Once it is created and used 
+     * in one or more PackageBuilders it should be considered immutable. Do not modify its 
+     * properties while it is being used by a PackageBuilder.
      * 
      * @param configuration
      */
@@ -127,28 +138,26 @@
         this.configuration = configuration;
         this.results = new ArrayList();
         this.pkg = pkg;
-        this.classFieldExtractorCache = ClassFieldExtractorCache.getInstance();        
-        
+        this.classFieldExtractorCache = ClassFieldExtractorCache.getInstance();
+
         if ( this.pkg != null ) {
             this.typeResolver = new ClassTypeResolver( this.pkg.getImports(),
                                                        this.configuration.getClassLoader() );
             // make an automatic import for the current package
-            this.typeResolver.addImport( this.pkg.getName() + ".*" );            
+            this.typeResolver.addImport( this.pkg.getName() + ".*" );
         } else {
             this.typeResolver = new ClassTypeResolver( new HashSet(),
                                                        this.configuration.getClassLoader() );
         }
-        
+
         this.dialectRegistry = this.configuration.buildDialectRegistry();
-        
+
         this.dialect = this.dialectRegistry.getDialect( this.configuration.getDefaultDialect() );
-        
+
         this.dialectRegistry.initAll( this );
         if ( this.pkg != null ) {
-            initDialectPackage( pkg );            
-        }        
-        
-        
+            initDialectPackage( pkg );
+        }
 
     }
 
@@ -219,46 +228,74 @@
             for ( int i = 0; i < processes.length; i++ ) {
                 pkg.addRuleFlow( processes[i] );
             }
-            this.results.addAll(processBuilder.getErrors());
+            this.results.addAll( processBuilder.getErrors() );
         } catch ( Exception e ) {
             if ( e instanceof RuntimeException ) {
                 throw (RuntimeException) e;
             }
-            this.results.add( new RuleFlowLoadError("Unable to load the rule flow.", e) );
+            this.results.add( new RuleFlowLoadError( "Unable to load the rule flow.",
+                                                     e ) );
         }
     }
 
+    // @FIXME this is a hack to wire in Actions for now
+    public void buildActions(Process process) {
+        RuleFlowProcess rfp = (RuleFlowProcess) process;
+
+        ProcessDescr processDescr = new ProcessDescr();
+        processDescr.setClassName( rfp.getName() );
+        processDescr.setName( rfp.getPackageName() );
+
+        ProcessBuildContext context = new ProcessBuildContext( this.configuration,
+                                                               pkg,
+                                                               process,
+                                                               processDescr,
+                                                               this.dialectRegistry,
+                                                               this.dialect );        
+
+        for ( Node node : rfp.getNodes() ) {
+            if ( node instanceof ActionNode ) {
+                ActionNodeImpl actionNode = ( ActionNodeImpl ) node;
+                DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
+                ActionDescr actionDescr = new ActionDescr();
+                actionDescr.setText( action.getConsequence() );
+                
+                context.getDialect().getActionBuilder().build( context, actionNode, actionDescr );
+            }
+        }
+        ((JavaDialect)context.getDialect()).addAction( context );
+    }
+
     /**
      * This adds a package from a Descr/AST This will also trigger a compile, if
      * there are any generated classes to compile of course.
      */
-    public void addPackage(final PackageDescr packageDescr) {        
+    public void addPackage(final PackageDescr packageDescr) {
         validatePackageName( packageDescr );
         validateUniqueRuleNames( packageDescr );
-        
 
-        String dialectName = null;       
-//MN: not needed as overrides are done in the compiler before here
-//as we can have mixed dialect types - still not quite right here.       
-//        for ( Iterator it = packageDescr.getAttributes().iterator(); it.hasNext(); ) {
-//            AttributeDescr value = ( AttributeDescr ) it.next();
-//            if ( "dialect".equals( value.getName() )) {   
-//                dialectName = value.getValue();
-//                break;
-//            }
-//        }
-        
+        String dialectName = null;
+        //MN: not needed as overrides are done in the compiler before here
+        //as we can have mixed dialect types - still not quite right here.       
+        //        for ( Iterator it = packageDescr.getAttributes().iterator(); it.hasNext(); ) {
+        //            AttributeDescr value = ( AttributeDescr ) it.next();
+        //            if ( "dialect".equals( value.getName() )) {   
+        //                dialectName = value.getValue();
+        //                break;
+        //            }
+        //        }
+
         // The Package does not have a default dialect, so set it
-        if ( dialectName == null && this.dialect == null ) {        	
-                this.dialect = this.dialectRegistry.getDialect( this.configuration.getDefaultDialect() );
-        } 
-            
-        if ( dialectName != null ) {        	
+        if ( dialectName == null && this.dialect == null ) {
+            this.dialect = this.dialectRegistry.getDialect( this.configuration.getDefaultDialect() );
+        }
+
+        if ( dialectName != null ) {
             this.dialect = this.dialectRegistry.getDialect( dialectName );
         } else if ( this.dialect == null ) {
             this.dialect = this.dialectRegistry.getDialect( this.configuration.getDefaultDialect() );
         }
-                   
+
         if ( this.pkg != null ) {
             // mergePackage( packageDescr ) ;
             mergePackage( this.pkg,
@@ -267,36 +304,36 @@
             this.pkg = newPackage( packageDescr );
         }
 
-        this.builder = new RuleBuilder();
+        this.ruleBuilder = new RuleBuilder();
 
         // only try to compile if there are no parse errors
         if ( !hasErrors() ) {
             for ( final Iterator it = packageDescr.getFactTemplates().iterator(); it.hasNext(); ) {
                 addFactTemplate( (FactTemplateDescr) it.next() );
             }
-            
+
             if ( !packageDescr.getFunctions().isEmpty() ) {
-	            // add static imports for all functions
-	            for ( final Iterator it = packageDescr.getFunctions().iterator(); it.hasNext(); ) {
-	                FunctionDescr functionDescr = (FunctionDescr) it.next();
-	                final String functionClassName = this.pkg.getName() + "." + ucFirst( functionDescr.getName() );
-	                functionDescr.setClassName( functionClassName );
-	                this.pkg.addStaticImport( functionClassName + "." + functionDescr.getName() );
-	            }            	                        
-	
-	            // iterate and compile
-	            for ( final Iterator it = packageDescr.getFunctions().iterator(); it.hasNext(); ) {
-	                addFunction( (FunctionDescr) it.next() );
-	            }
-            
-	            // We need to compile all the functions, so scripting languages like mvel can find them
-	            this.dialectRegistry.compileAll();
-	            
-	            for ( final Iterator it = packageDescr.getFunctions().iterator(); it.hasNext(); ) {
-	                FunctionDescr functionDescr = (FunctionDescr) it.next();
-	                final String functionClassName = this.pkg.getName() + "." + ucFirst( functionDescr.getName() );
-	                this.dialectRegistry.addStaticImport(functionClassName + "." + functionDescr.getName());
-	            }	            
+                // add static imports for all functions
+                for ( final Iterator it = packageDescr.getFunctions().iterator(); it.hasNext(); ) {
+                    FunctionDescr functionDescr = (FunctionDescr) it.next();
+                    final String functionClassName = this.pkg.getName() + "." + ucFirst( functionDescr.getName() );
+                    functionDescr.setClassName( functionClassName );
+                    this.pkg.addStaticImport( functionClassName + "." + functionDescr.getName() );
+                }
+
+                // iterate and compile
+                for ( final Iterator it = packageDescr.getFunctions().iterator(); it.hasNext(); ) {
+                    addFunction( (FunctionDescr) it.next() );
+                }
+
+                // We need to compile all the functions, so scripting languages like mvel can find them
+                this.dialectRegistry.compileAll();
+
+                for ( final Iterator it = packageDescr.getFunctions().iterator(); it.hasNext(); ) {
+                    FunctionDescr functionDescr = (FunctionDescr) it.next();
+                    final String functionClassName = this.pkg.getName() + "." + ucFirst( functionDescr.getName() );
+                    this.dialectRegistry.addStaticImport( functionClassName + "." + functionDescr.getName() );
+                }
             }
 
             // iterate and compile
@@ -306,7 +343,7 @@
         }
 
         this.dialectRegistry.compileAll();
-        
+
         // some of the rules and functions may have been redefined
         if ( this.pkg.getPackageCompilationData().isDirty() ) {
             this.pkg.getPackageCompilationData().reload();
@@ -315,14 +352,11 @@
     }
 
     private void validatePackageName(final PackageDescr packageDescr) {
-        if ( ( this.pkg == null || this.pkg.getName() == null || this.pkg.getName().equals( "" ) )
-                && ( packageDescr.getName() == null || "".equals( packageDescr.getName() ) ) ) {
+        if ( (this.pkg == null || this.pkg.getName() == null || this.pkg.getName().equals( "" )) && (packageDescr.getName() == null || "".equals( packageDescr.getName() )) ) {
             throw new MissingPackageNameException( "Missing package name for rule package." );
         }
-        if ( this.pkg != null && packageDescr.getName() != null && 
-             ! "".equals( packageDescr.getName() ) && 
-             ! this.pkg.getName().equals( packageDescr.getName() ) ) {
-            throw new PackageMergeException( "Can't merge packages with different names. This package: "+this.pkg.getName()+" - New package: "+packageDescr.getName() ) ;
+        if ( this.pkg != null && packageDescr.getName() != null && !"".equals( packageDescr.getName() ) && !this.pkg.getName().equals( packageDescr.getName() ) ) {
+            throw new PackageMergeException( "Can't merge packages with different names. This package: " + this.pkg.getName() + " - New package: " + packageDescr.getName() );
         }
         return;
     }
@@ -343,22 +377,22 @@
 
     private Package newPackage(final PackageDescr packageDescr) {
         final Package pkg = new Package( packageDescr.getName(),
-                                         this.configuration.getClassLoader() );       
+                                         this.configuration.getClassLoader() );
 
-       initDialectPackage( pkg );
+        initDialectPackage( pkg );
 
         mergePackage( pkg,
                       packageDescr );
 
         return pkg;
     }
-    
+
     private void initDialectPackage(Package pkg) {
         for ( Iterator it = this.dialectRegistry.iterator(); it.hasNext(); ) {
-            Dialect dialect = ( Dialect) it.next();
+            Dialect dialect = (Dialect) it.next();
             dialect.init( pkg );
         }
-        
+
     }
 
     private void mergePackage(final Package pkg,
@@ -373,7 +407,7 @@
         for ( final Iterator it = imports.iterator(); it.hasNext(); ) {
             String importEntry = ((ImportDescr) it.next()).getTarget();
             pkg.addImport( importEntry );
-            this.typeResolver.addImport( importEntry );            
+            this.typeResolver.addImport( importEntry );
             this.dialectRegistry.addImport( importEntry );
         }
 
@@ -397,7 +431,8 @@
                 pkg.addGlobal( identifier,
                                clazz );
             } catch ( final ClassNotFoundException e ) {
-                this.results.add(new GlobalError( identifier, global.getLine() ));
+                this.results.add( new GlobalError( identifier,
+                                                   global.getLine() ) );
             }
         }
     }
@@ -433,7 +468,7 @@
 
     private void addRule(final RuleDescr ruleDescr) {
         //this.dialect.init( ruleDescr );
-        
+
         if ( ruleDescr instanceof QueryDescr ) {
             //ruleDescr.getLhs().insertDescr( 0, baseDescr );
         }
@@ -443,7 +478,7 @@
                                                          ruleDescr,
                                                          this.dialectRegistry,
                                                          this.dialect );
-        this.builder.build( context );
+        this.ruleBuilder.build( context );
 
         this.results.addAll( context.getErrors() );
 
@@ -477,7 +512,7 @@
         }
         return this.pkg;
     }
-    
+
     /**
      * Return the PackageBuilderConfiguration for this PackageBuilder session
      * @return
@@ -488,13 +523,13 @@
     }
 
     public DialectRegistry getDialectRegistry() {
-    	return this.dialectRegistry;
+        return this.dialectRegistry;
     }
-    
+
     public Dialect getDefaultDialect() {
-    	return this.dialect;
+        return this.dialect;
     }
-    
+
     /**
      * Return the ClassFieldExtractorCache, this should only be used internally, and is subject to change
      * @return
@@ -614,14 +649,37 @@
         }
 
         public DroolsError getError() {
-            return new RuleError( this.rule,
-                                  this.descr,
-                                  collectCompilerProblems(),
-                                  this.message );
+            return new RuleBuildError( this.rule,
+                                       this.descr,
+                                       collectCompilerProblems(),
+                                       this.message );
         }
 
     }
 
+    public static class ProcessErrorHandler extends ErrorHandler {
+
+        private BaseDescr descr;
+
+        private Process   process;
+
+        public ProcessErrorHandler(final BaseDescr ruleDescr,
+                                   final Process process,
+                                   final String message) {
+            this.descr = ruleDescr;
+            this.process = process;
+            this.message = message;
+        }
+
+        public DroolsError getError() {
+            return new ProcessBuildError( this.process,
+                                          this.descr,
+                                          collectCompilerProblems(),
+                                          this.message );
+        }
+
+    }
+
     /**
      * There isn't much point in reporting invoker errors, as they are no help.
      */
@@ -636,6 +694,17 @@
         }
     }
 
+    public static class ProcessInvokerErrorHandler extends ProcessErrorHandler {
+
+        public ProcessInvokerErrorHandler(final BaseDescr processDescr,
+                                          final Process process,
+                                          final String message) {
+            super( processDescr,
+                   process,
+                   message );
+        }
+    }
+
     public static class FunctionErrorHandler extends ErrorHandler {
 
         private FunctionDescr descr;

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ProcessBuildError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ProcessBuildError.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ProcessBuildError.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,19 @@
+package org.drools.compiler;
+
+import org.drools.lang.descr.BaseDescr;
+import org.drools.ruleflow.common.core.Process;
+
+public class ProcessBuildError extends DescrBuildError {
+    private final Process process;
+    public ProcessBuildError(final Process process,
+                           final BaseDescr descr,
+                           final Object object,
+                           final String message) {
+              super(descr, descr, object, message);
+              this.process = process;
+          }
+    
+    public Process getProcess() {
+        return this.process;
+    }
+}

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBuildError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBuildError.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBuildError.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,19 @@
+package org.drools.compiler;
+
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Rule;
+
+public class RuleBuildError extends DescrBuildError {
+    private final Rule rule;
+    public RuleBuildError(final Rule rule,
+                           final BaseDescr descr,
+                           final Object object,
+                           final String message) {
+              super(descr, descr, object, message);
+              this.rule = rule;
+          }
+    
+    public Rule getRule() {
+        return this.rule;
+    }
+}

Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -1,125 +0,0 @@
-package org.drools.compiler;
-
-/*
- * 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 org.drools.commons.jci.problems.CompilationProblem;
-import org.drools.lang.descr.BaseDescr;
-import org.drools.rule.Rule;
-
-public class RuleError extends DroolsError {
-    private Rule      rule;
-    private BaseDescr descr;
-    private Object    object;
-    private String    message;
-    private int[]     errorLines = new int[0];
-
-    public RuleError(final Rule rule,
-                     final BaseDescr descr,
-                     final Object object,
-                     final String message) {
-        super();
-        this.rule = rule;
-        this.descr = descr;
-        this.object = object;
-        this.message = message;
-    }
-
-    public Rule getRule() {
-        return this.rule;
-    }
-
-    public BaseDescr getDescr() {
-        return this.descr;
-    }
-
-    public Object getObject() {
-        return this.object;
-    }
-    
-    public int[] getErrorLines() {
-        return this.errorLines;
-    }
-
-    /** 
-     * This will return the line number of the error, if possible
-     * Otherwise it will be -1
-     */
-    public int getLine() {
-        return this.descr != null ? this.descr.getLine() : -1;
-    }
-
-    public String getMessage() {
-        String summary = this.message;
-        if ( this.object instanceof CompilationProblem[] ) {
-            final CompilationProblem[] problem = (CompilationProblem[]) this.object;
-            for ( int i = 0; i < problem.length; i++ ) {
-                if (i != 0) {
-                    summary = summary + "\n" + problem[i].getMessage();
-                } else {
-                    summary = summary + " " + problem[i].getMessage();
-                }
-            }
-
-        }
-        return summary;
-    }
-
-    public String toString() {
-        final StringBuffer buf = new StringBuffer();
-        buf.append( this.message );
-        buf.append( " : " );
-        buf.append( this.rule );
-        buf.append( "\n" );
-        if ( this.object instanceof CompilationProblem[] ) {
-            final CompilationProblem[] problem = (CompilationProblem[]) this.object;
-            for ( int i = 0; i < problem.length; i++ ) {
-                buf.append( "\t" );
-                buf.append( problem[i] );
-                buf.append( "\n" );
-            }
-        } else if ( this.object != null ) {
-            buf.append( this.object );
-        }
-        return buf.toString();
-    }
-
-//    private String createMessage( String message ) {
-//        StringBuffer detail = new StringBuffer();
-//        detail.append( this.message );
-//        detail.append( " : " );
-//        detail.append( this.rule );
-//        detail.append( "\n" );
-//        if( object instanceof CompilationProblem[] ) {
-//            CompilationProblem[] cp = (CompilationProblem[]) object;
-//            this.errorLines = new int[cp.length];
-//            for( int i = 0; i < cp.length ; i ++ ) {
-//               this.errorLines[i] = cp[i].getStartLine() - this.descr.getOffset() + this.descr.getLine() - 1; 
-//               detail.append( this.rule.getName() );
-//               detail.append( " (line:" );
-//               detail.append( this.errorLines[i] );
-//               detail.append( "): " );
-//               detail.append( cp[i].getMessage() );
-//               detail.append( "\n" );
-//            }
-//        } else {
-//            this.errorLines = new int[0];
-//        }
-//        return "[ "+this.rule.getName()+" : "+message + "\n"+detail.toString()+" ]";
-//    }
-    
-    
-}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ActionDescr.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ActionDescr.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ActionDescr.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,22 @@
+package org.drools.lang.descr;
+
+public class ActionDescr extends BaseDescr {
+    private String text;
+    
+    public ActionDescr() {
+        
+    }
+    
+    public ActionDescr(String text) {
+        super();
+        this.text = text;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+}

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ProcessDescr.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ProcessDescr.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/ProcessDescr.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,35 @@
+package org.drools.lang.descr;
+
+public class ProcessDescr extends BaseDescr {
+    private String name;
+    private String className;
+
+    
+    public ProcessDescr() {
+        
+    }
+    
+    public ProcessDescr(String name) {
+        super();
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }        
+    
+    
+
+}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -38,8 +38,6 @@
 
     private String            className;
 
-	//MVEL: Compiler change
-    private Dialect           dialect;
 
     public RuleDescr(final String name) {
         this( name,
@@ -130,11 +128,4 @@
         return this.consequencePattern;
     }
 
-    public void setDialect(Dialect dialect) {
-        this.dialect = dialect;
-    }
-
-    public Dialect getDialect() {
-        return this.dialect;
-    }
 }
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ActionBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ActionBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ActionBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,12 @@
+package org.drools.rule.builder;
+
+import org.drools.lang.descr.ActionDescr;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+
+public interface ActionBuilder {
+
+    public void build(final PackageBuildContext context,
+                      final ActionNodeImpl actionNode,
+                      final ActionDescr actionDescr);
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PackageBuildContext.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PackageBuildContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PackageBuildContext.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package org.drools.rule.builder;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.drools.base.evaluators.DateFactory;
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DialectConfiguration;
+import org.drools.compiler.DialectRegistry;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.rule.Dialectable;
+import org.drools.rule.Package;
+import org.drools.rule.Query;
+import org.drools.rule.Rule;
+import org.drools.spi.DeclarationScopeResolver;
+
+/**
+ * A context for the current build
+ * 
+ * @author etirelli
+ */
+public class PackageBuildContext {
+
+    // current package
+    private Package                     pkg;        
+
+    // configuration
+    private PackageBuilderConfiguration configuration;
+    
+    // the contianer descr
+    private BaseDescr                   parentDescr;    
+
+    // errors found when building the current context
+    private List                        errors;
+
+    // list of generated methods
+    private List                        methods;
+
+    // map<String invokerClassName, String invokerCode> of generated invokers
+    private Map                         invokers;
+
+    // map<String invokerClassName, ConditionalElement ce> of generated invoker lookups
+    private Map                         invokerLookups;
+
+    // map<String invokerClassName, BaseDescr descr> of descriptor lookups
+    private Map                         descrLookups;
+
+    // a simple counter for generated names
+    private int                         counter;
+
+    private DialectRegistry             dialectRegistry;
+
+    private Dialect                     dialect;    
+    
+    public PackageBuildContext() {
+        
+    }
+
+    /**
+     * Default constructor
+     */
+    public void init(final PackageBuilderConfiguration configuration,
+                               final Package pkg,
+                               final BaseDescr parentDescr,
+                               final DialectRegistry dialectRegistry,
+                               final Dialect defaultDialect,
+                               final Dialectable component) {
+        this.configuration = configuration;
+        this.pkg = pkg;
+        
+        this.parentDescr = parentDescr;
+
+        this.methods = new ArrayList();
+        this.invokers = new HashMap();
+        this.invokerLookups = new HashMap();
+        this.descrLookups = new HashMap();
+        this.errors = new ArrayList();
+
+        this.dialectRegistry = dialectRegistry;
+        this.dialect = (component != null && component.getDialect() != null) ? this.dialectRegistry.getDialect( component.getDialect() ) : defaultDialect;
+    }
+    
+    public BaseDescr getParentDescr() {
+        return this.parentDescr;
+    }
+
+    public Dialect getDialect() {
+        return dialect;
+    }
+
+    /**
+     * Allows the change of the current dialect in the context
+     */
+    public void setDialect(Dialect dialect) {
+        this.dialect = dialect;
+    }
+
+    public Dialect getDialect(String dialectName) {
+        return (Dialect) this.dialectRegistry.getDialect( dialectName );
+    }
+
+    /**
+     * Returns the list of errors found while building the current context
+     * @return
+     */
+    public List getErrors() {
+        return this.errors;
+    }
+
+    /**
+     * Returns the current package being built
+     * @return
+     */
+    public Package getPkg() {
+        return this.pkg;
+    }
+
+    /**
+     * Returns the Map<String invokerClassName, BaseDescr descr> of descriptor lookups
+     * @return
+     */
+    public Map getDescrLookups() {
+        return this.descrLookups;
+    }
+
+    public void setDescrLookups(final Map descrLookups) {
+        this.descrLookups = descrLookups;
+    }
+
+    /**
+     * Returns the Map<String invokerClassName, ConditionalElement ce> of generated invoker lookups
+     * @return
+     */
+    public Map getInvokerLookups() {
+        return this.invokerLookups;
+    }
+
+    public void setInvokerLookups(final Map invokerLookups) {
+        this.invokerLookups = invokerLookups;
+    }
+
+    /**
+     * Returns the Map<String invokerClassName, String invokerCode> of generated invokers
+     * @return
+     */
+    public Map getInvokers() {
+        return this.invokers;
+    }
+
+    public void setInvokers(final Map invokers) {
+        this.invokers = invokers;
+    }
+
+    /**
+     * Returns the list of generated methods
+     * @return
+     */
+    public List getMethods() {
+        return this.methods;
+    }
+
+    public void setMethods(final List methods) {
+        this.methods = methods;
+    }
+
+    /**
+     * Returns current counter value for generated method names
+     * @return
+     */
+    public int getCurrentId() {
+        return this.counter;
+    }
+
+    public int getNextId() {
+        return this.counter++;
+    }
+    
+    public PackageBuilderConfiguration getConfiguration() {
+        return configuration;
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -19,6 +19,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.drools.RuntimeDroolsException;
 import org.drools.base.ClassObjectType;
@@ -26,7 +27,7 @@
 import org.drools.base.ValueType;
 import org.drools.base.evaluators.Operator;
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.facttemplates.FactTemplate;
 import org.drools.facttemplates.FactTemplateFieldExtractor;
 import org.drools.facttemplates.FactTemplateObjectType;
@@ -105,7 +106,7 @@
         final PatternDescr patternDescr = (PatternDescr) descr;
 
         if ( patternDescr.getObjectType() == null || patternDescr.getObjectType().equals( "" ) ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     patternDescr,
                                                     null,
                                                     "ObjectType not correctly defined" ) );
@@ -123,7 +124,7 @@
                 final Class userProvidedClass = context.getDialect().getTypeResolver().resolveType( patternDescr.getObjectType() );
                 objectType = new ClassObjectType( userProvidedClass );
             } catch ( final ClassNotFoundException e ) {
-                context.getErrors().add( new RuleError( context.getRule(),
+                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                         patternDescr,
                                                         null,
                                                         "Unable to resolve ObjectType '" + patternDescr.getObjectType() + "'" ) );
@@ -136,7 +137,7 @@
 
             if ( context.getDeclarationResolver().isDuplicated( patternDescr.getIdentifier() ) ) {
                 // This declaration already  exists, so throw an Exception
-                context.getErrors().add( new RuleError( context.getRule(),
+                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                         patternDescr,
                                                         null,
                                                         "Duplicate declaration for variable '" + patternDescr.getIdentifier() + "' in the rule '" + context.getRule().getName() + "'" ) );
@@ -226,7 +227,7 @@
                 container.addConstraint( or );
             }
         } else {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     (BaseDescr) constraint,
                                                     null,
                                                     "This is a bug: unable to build constraint descriptor: '" + constraint + "' in rule '" + context.getRule().getName() + "'" ) );
@@ -283,7 +284,7 @@
                 // after building the predicate, we are done, so return
                 return;
             } else {
-                context.getErrors().add( new RuleError( context.getRule(),
+                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                         fieldConstraintDescr,
                                                         null,
                                                         "Unable to create Field Extractor for '" + fieldName + "' of '"+pattern.getObjectType().toString()+"' in rule '"+context.getRule().getName()+"'" ) );
@@ -316,7 +317,7 @@
             constraint = new ReturnValueConstraint( extractor,
                                                     (ReturnValueRestriction) restriction );
         } else {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     fieldConstraintDescr,
                                                     null,
                                                     "This is a bug: Unkown restriction type '" + restriction.getClass() + "' for pattern '"+pattern.getObjectType().toString()+"' in rule '"+context.getRule().getName()+"'" ) );
@@ -381,7 +382,7 @@
                                                           fieldConstraintDescr,
                                                           restrictionDescr );
                 if( restrictions[index] == null ) {
-                    context.getErrors().add( new RuleError( context.getRule(),
+                    context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                             fieldConstraintDescr,
                                                             null,
                                                             "Unable to create restriction '" + restrictionDescr.toString() + "' for field '"+ fieldConstraintDescr.getFieldName() +"' in the rule '" + context.getRule().getName() + "'" ) );
@@ -397,7 +398,7 @@
             } else if ( top.getConnective() == RestrictionConnectiveDescr.OR ) {
                 composite = new OrCompositeRestriction( restrictions );
             } else {
-                context.getErrors().add( new RuleError( context.getRule(),
+                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                         fieldConstraintDescr,
                                                         null,
                                                         "This is a bug: Impossible to create a composite restriction for connective: " + top.getConnective()+ "' for field '"+ fieldConstraintDescr.getFieldName() +"' in the rule '" + context.getRule().getName() + "'" ) );
@@ -407,7 +408,7 @@
         } else if ( restrictions.length == 1 ) {
             return restrictions[0];
         }
-        context.getErrors().add( new RuleError( context.getRule(),
+        context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                 fieldConstraintDescr,
                                                 null,
                                                 "This is a bug: trying to create a restriction for an empty restriction list for field '"+ fieldConstraintDescr.getFieldName() +"' in the rule '" + context.getRule().getName() + "'" ) );
@@ -420,7 +421,7 @@
 
         if ( context.getDeclarationResolver().isDuplicated( fieldBindingDescr.getIdentifier() ) ) {
             // This declaration already  exists, so throw an Exception
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     fieldBindingDescr,
                                                     null,
                                                     "Duplicate declaration for variable '" + fieldBindingDescr.getIdentifier() + "' in the rule '" + context.getRule().getName() + "'" ) );
@@ -447,7 +448,8 @@
 
         final Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                                         predicateDescr,
-                                                                                        predicateDescr.getContent() );
+                                                                                        predicateDescr.getContent(),
+                                                                                        new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
         if ( analysis == null ) {
             // something bad happened
@@ -594,7 +596,7 @@
                                                  final FieldConstraintDescr fieldConstraintDescr,
                                                  final VariableRestrictionDescr variableRestrictionDescr) {
         if ( variableRestrictionDescr.getIdentifier() == null || variableRestrictionDescr.getIdentifier().equals( "" ) ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     variableRestrictionDescr,
                                                     null,
                                                     "Identifier not defined for binding field '" + fieldConstraintDescr.getFieldName() + "'" ) );
@@ -612,7 +614,7 @@
             if ( implicit != null ) {
                 declaration = implicit;
             } else {
-                context.getErrors().add( new RuleError( context.getRule(),
+                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                         variableRestrictionDescr,
                                                         null,
                                                         "Unable to return Declaration for identifier '" + variableRestrictionDescr.getIdentifier() + "'" ) );
@@ -642,7 +644,7 @@
             field = FieldFactory.getFieldValue( literalRestrictionDescr.getValue(),
                                                 extractor.getValueType() );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     literalRestrictionDescr,
                                                     e,
                                                     "Unable to create a Field value of type  '" + extractor.getValueType() + "' and value '" + literalRestrictionDescr.getText() + "'" ) );
@@ -689,7 +691,7 @@
                                                                  decl.getPattern() );
 
                     } else {
-                        context.getErrors().add( new RuleError( context.getRule(),
+                        context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                                 qiRestrictionDescr,
                                                                 "",
                                                                 "Not possible to directly access the property '" + parts[1] + "' of declaration '" + parts[0] + "' since it is not a pattern" ) );
@@ -724,7 +726,7 @@
         } catch ( final ClassNotFoundException e ) {
             // nothing to do, as it is not a class name with static field
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     qiRestrictionDescr,
                                                     e,
                                                     "Unable to create a Field value of type  '" + extractor.getValueType() + "' and value '" + qiRestrictionDescr.getText() + "'" ) );
@@ -754,7 +756,8 @@
                                                     final ReturnValueRestrictionDescr returnValueRestrictionDescr) {
         Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                                   returnValueRestrictionDescr,
-                                                                                  returnValueRestrictionDescr.getContent() );
+                                                                                  returnValueRestrictionDescr.getContent(),
+                                                                                  new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
         final List[] usedIdentifiers = analysis.getBoundIdentifiers();
 
         final List tupleDeclarations = new ArrayList();
@@ -822,7 +825,7 @@
                                                                                              classloader );
             } catch ( final RuntimeDroolsException e ) {
                 if ( reportError ) {
-                    context.getErrors().add( new RuleError( context.getRule(),
+                    context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                             descr,
                                                             e,
                                                             "Unable to create Field Extractor for '" + fieldName + "'" ) );
@@ -841,7 +844,7 @@
         final Evaluator evaluator = valueType.getEvaluator( Operator.determineOperator( evaluatorString ) );
 
         if ( evaluator == null ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     descr,
                                                     null,
                                                     "Unable to determine the Evaluator for  '" + valueType + "' and '" + evaluatorString + "'" ) );

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessBuildContext.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessBuildContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessBuildContext.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,49 @@
+package org.drools.rule.builder;
+
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DialectRegistry;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.ProcessDescr;
+
+import org.drools.rule.Package;
+import org.drools.ruleflow.common.core.Process;
+
+public class ProcessBuildContext extends PackageBuildContext {
+    private Process      process;
+    private ProcessDescr processDescr;
+
+    public ProcessBuildContext(final PackageBuilderConfiguration cfg,
+                               final Package pkg,
+                               final Process process,
+                               final BaseDescr processDescr,
+                               final DialectRegistry dialectRegistry,
+                               final Dialect defaultDialect) {
+        this.process = process;
+        this.processDescr = (ProcessDescr) processDescr;
+        init( cfg,
+              pkg,
+              processDescr,
+              dialectRegistry,
+              defaultDialect,
+              null );
+
+    }
+
+    public ProcessDescr getProcessDescr() {
+        return processDescr;
+    }
+
+    public void setProcessDescr(ProcessDescr processDescr) {
+        this.processDescr = processDescr;
+    }
+
+    public Process getProcess() {
+        return process;
+    }
+
+    public void setProcess(Process process) {
+        this.process = process;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessClassBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessClassBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/ProcessClassBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,8 @@
+package org.drools.rule.builder;
+
+
+public interface ProcessClassBuilder {
+
+    public String  buildRule(final ProcessBuildContext context);
+
+}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/QueryBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/QueryBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/QueryBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -7,7 +7,7 @@
 import org.drools.base.ValueType;
 import org.drools.base.evaluators.Operator;
 import org.drools.base.extractors.ArrayExtractor;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.lang.descr.QueryDescr;
 import org.drools.rule.LiteralConstraint;
 import org.drools.rule.Pattern;
@@ -25,7 +25,9 @@
                                              objectType,
                                              null );
         ClassLoader classloader = context.getPkg().getPackageCompilationData().getClassLoader();
-        final FieldExtractor extractor = context.getDialect().getClassFieldExtractorCache().getExtractor(  DroolsQuery.class, "name",  classloader );        
+        final FieldExtractor extractor = context.getDialect().getClassFieldExtractorCache().getExtractor( DroolsQuery.class,
+                                                                                                          "name",
+                                                                                                          classloader );
 
         final FieldValue field = FieldFactory.getFieldValue( queryDescr.getName(),
                                                              ValueType.STRING_TYPE );
@@ -42,27 +44,27 @@
                                                                                               "arguments",
                                                                                               classloader );
         } catch ( final RuntimeDroolsException e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
-                                                    queryDescr,
-                                                    e,
-                                                    "Unable to create Field Extractor for 'getArguments'" ) );
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
+                                                          queryDescr,
+                                                          e,
+                                                          "Unable to create Field Extractor for 'getArguments'" ) );
         }
 
         String[] params = queryDescr.getParameters();
         String[] types = queryDescr.getParameterTypes();
         int i = 0;
         try {
-        for ( i = 0; i < params.length; i++ ) {
-            pattern.addDeclaration( params[i],
-                                    new ArrayExtractor( arrayExtractor,
-                                                        i,
-                                                        context.getDialect().getTypeResolver().resolveType( types[i] ) ) );
-        }
+            for ( i = 0; i < params.length; i++ ) {
+                pattern.addDeclaration( params[i],
+                                        new ArrayExtractor( arrayExtractor,
+                                                            i,
+                                                            context.getDialect().getTypeResolver().resolveType( types[i] ) ) );
+            }
         } catch ( ClassNotFoundException e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
-                                                    queryDescr,
-                                                    e,
-                                                    "Unable to resolve type '" + types[i] + " for parameter" + params[i] ) );            
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
+                                                          queryDescr,
+                                                          e,
+                                                          "Unable to resolve type '" + types[i] + " for parameter" + params[i] ) );
         }
         return pattern;
     }

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -42,14 +42,8 @@
  * 
  * @author etirelli
  */
-public class RuleBuildContext {
+public class RuleBuildContext extends PackageBuildContext {
 
-    // current package
-    private Package                     pkg;
-
-    // configuration
-    private PackageBuilderConfiguration configuration;
-
     // current rule
     private Rule                        rule;
 
@@ -66,28 +60,6 @@
     // a simple counter for patterns
     private int                         patternId = -1;
 
-    // errors found when building the current context
-    private List                        errors;
-
-    // list of generated methods
-    private List                        methods;
-
-    // map<String invokerClassName, String invokerCode> of generated invokers
-    private Map                         invokers;
-
-    // map<String invokerClassName, ConditionalElement ce> of generated invoker lookups
-    private Map                         invokerLookups;
-
-    // map<String invokerClassName, BaseDescr descr> of descriptor lookups
-    private Map                         descrLookups;
-
-    // a simple counter for generated names
-    private int                         counter;
-
-    private DialectRegistry             dialectRegistry;
-
-    private Dialect                     dialect;
-
     /**
      * Default constructor
      */
@@ -96,16 +68,8 @@
                             final RuleDescr ruleDescr,
                             final DialectRegistry dialectRegistry,
                             final Dialect defaultDialect) {
-        this.configuration = configuration;
-        this.pkg = pkg;
-
-        this.methods = new ArrayList();
-        this.invokers = new HashMap();
-        this.invokerLookups = new HashMap();
-        this.descrLookups = new HashMap();
-        this.errors = new ArrayList();
         this.buildStack = new Stack();
-        this.declarationResolver = new DeclarationScopeResolver( new Map[]{this.pkg.getGlobals()},
+        this.declarationResolver = new DeclarationScopeResolver( new Map[]{pkg.getGlobals()},
                                                                  this.buildStack );
         this.ruleDescr = ruleDescr;
 
@@ -113,51 +77,19 @@
             this.rule = new Query( ruleDescr.getName() );
         } else {
             this.rule = new Rule( ruleDescr.getName() );
-        }
+        }        
 
         // Assign attributes
         setAttributes( this.rule,
                        ruleDescr,
                        ruleDescr.getAttributes() );
+        
+        init(configuration, pkg, ruleDescr, dialectRegistry, defaultDialect, this.rule );
 
-        this.dialectRegistry = dialectRegistry;
-        this.dialect = (this.rule.getDialect() != null) ? this.dialectRegistry.getDialect( this.rule.getDialect() ) : defaultDialect;
-
         getDialect().init( ruleDescr );
     }
 
-    public Dialect getDialect() {
-        return dialect;
-    }
-
     /**
-     * Allows the change of the current dialect in the context
-     */
-    public void setDialect(Dialect dialect) {
-        this.dialect = dialect;
-    }
-
-    public Dialect getDialect(String dialectName) {
-        return (Dialect) this.dialectRegistry.getDialect( dialectName );
-    }
-
-    /**
-     * Returns the list of errors found while building the current context
-     * @return
-     */
-    public List getErrors() {
-        return this.errors;
-    }
-
-    /**
-     * Returns the current package being built
-     * @return
-     */
-    public Package getPkg() {
-        return this.pkg;
-    }
-
-    /**
      * Returns the current Rule being built
      * @return
      */
@@ -189,66 +121,6 @@
         this.declarationResolver = variables;
     }
 
-    /**
-     * Returns the Map<String invokerClassName, BaseDescr descr> of descriptor lookups
-     * @return
-     */
-    public Map getDescrLookups() {
-        return this.descrLookups;
-    }
-
-    public void setDescrLookups(final Map descrLookups) {
-        this.descrLookups = descrLookups;
-    }
-
-    /**
-     * Returns the Map<String invokerClassName, ConditionalElement ce> of generated invoker lookups
-     * @return
-     */
-    public Map getInvokerLookups() {
-        return this.invokerLookups;
-    }
-
-    public void setInvokerLookups(final Map invokerLookups) {
-        this.invokerLookups = invokerLookups;
-    }
-
-    /**
-     * Returns the Map<String invokerClassName, String invokerCode> of generated invokers
-     * @return
-     */
-    public Map getInvokers() {
-        return this.invokers;
-    }
-
-    public void setInvokers(final Map invokers) {
-        this.invokers = invokers;
-    }
-
-    /**
-     * Returns the list of generated methods
-     * @return
-     */
-    public List getMethods() {
-        return this.methods;
-    }
-
-    public void setMethods(final List methods) {
-        this.methods = methods;
-    }
-
-    /**
-     * Returns current counter value for generated method names
-     * @return
-     */
-    public int getCurrentId() {
-        return this.counter;
-    }
-
-    public int getNextId() {
-        return this.counter++;
-    }
-
     public int getPatternId() {
         return this.patternId;
     }
@@ -331,8 +203,4 @@
         }
     }
 
-    public PackageBuilderConfiguration getConfiguration() {
-        return configuration;
-    }
-
 }

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -79,10 +79,5 @@
             // It wasn't an integer, so build as an expression
             context.getDialect().getSalienceBuilder().build( context );    
         }              
-
-        RuleClassBuilder classBuilder = context.getDialect().getRuleClassBuilder();
-        if ( classBuilder != null ) {
-            classBuilder.buildRule( context );
-        }
     }
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleClassBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleClassBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleClassBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -3,6 +3,6 @@
 
 public interface RuleClassBuilder {
 
-    public void buildRule(final RuleBuildContext context);
+    public String  buildRule(final RuleBuildContext context);
 
 }
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -1,131 +0,0 @@
-package org.drools.rule.builder.dialect.java;
-
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.drools.lang.descr.BaseDescr;
-import org.drools.rule.Declaration;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
-import org.drools.util.StringUtils;
-import org.mvel.MVELTemplateRegistry;
-import org.mvel.TemplateInterpreter;
-import org.mvel.TemplateRegistry;
-
-public class AbstractJavaBuilder {
-
-    protected static final TemplateRegistry RULE_REGISTRY    = new MVELTemplateRegistry();
-    protected static final TemplateRegistry INVOKER_REGISTRY = new MVELTemplateRegistry();
-
-    static {
-        RULE_REGISTRY.registerTemplate( new InputStreamReader( AbstractJavaBuilder.class.getResourceAsStream( "javaRule.mvel" ) ) );
-        INVOKER_REGISTRY.registerTemplate( new InputStreamReader( AbstractJavaBuilder.class.getResourceAsStream( "javaInvokers.mvel" ) ) );
-        MVELDialect.setLanguageLevel( 4 );
-        
-    }
-
-    public TemplateRegistry getRuleTemplateRegistry() {
-        return RULE_REGISTRY;
-    }
-
-    public TemplateRegistry getInvokerTemplateRegistry() {
-        return INVOKER_REGISTRY;
-    }
-
-    public Map createVariableContext(final String className,
-                                     final String text,
-                                     final RuleBuildContext context,
-                                     final Declaration[] declarations,
-                                     final Declaration[] localDeclarations,
-                                     final String[] globals) {
-        final Map map = new HashMap();
-
-        map.put( "methodName",
-                 className );
-
-        map.put( "package",
-                 context.getPkg().getName() );
-
-        map.put( "ruleClassName",
-                 StringUtils.ucFirst( context.getRuleDescr().getClassName() ) );
-
-        map.put( "invokerClassName",
-                 context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker" );
-
-        if ( text != null ) {
-            map.put( "text",
-                     text );
-
-            map.put( "hashCode",
-                     new Integer( text.hashCode() ) );
-        }
-
-        final String[] declarationTypes = new String[declarations.length];
-        for ( int i = 0, size = declarations.length; i < size; i++ ) {
-            declarationTypes[i] = ((JavaDialect) context.getDialect()).getTypeFixer().fix( declarations[i] );
-        }
-
-        map.put( "declarations",
-                 declarations );
-
-        map.put( "declarationTypes",
-                 declarationTypes );
-
-        if ( localDeclarations != null ) {
-            final String[] localDeclarationTypes = new String[localDeclarations.length];
-            for ( int i = 0, size = localDeclarations.length; i < size; i++ ) {
-                localDeclarationTypes[i] = ((JavaDialect) context.getDialect()).getTypeFixer().fix( localDeclarations[i] );
-            }
-
-            map.put( "localDeclarations",
-                     localDeclarations );
-
-            map.put( "localDeclarationTypes",
-                     localDeclarationTypes );
-        }
-
-        final List globalTypes = new ArrayList( globals.length );
-        for ( int i = 0, length = globals.length; i < length; i++ ) {
-            globalTypes.add( ((Class) context.getPkg().getGlobals().get( globals[i] )).getName().replace( '$',
-                                                                                                          '.' ) );
-        }
-
-        map.put( "globals",
-                 globals );
-
-        map.put( "globalTypes",
-                 globalTypes );
-
-        return map;
-    }
-
-    public void generatTemplates(final String ruleTemplate,
-                                 final String invokerTemplate,
-                                 final RuleBuildContext context,
-                                 final String className,
-                                 final Map vars,
-                                 final Object invokerLookup,
-                                 final BaseDescr descrLookup) {
-        TemplateRegistry registry = getRuleTemplateRegistry();
-        context.getMethods().add( TemplateInterpreter.parse( registry.getTemplate( ruleTemplate ),
-                                                             null,
-                                                             vars,
-                                                             registry ) );
-
-        registry = getInvokerTemplateRegistry();
-        final String invokerClassName = context.getPkg().getName() + "." + context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker";
-        context.getInvokers().put( invokerClassName,
-                                   TemplateInterpreter.parse( registry.getTemplate( invokerTemplate ),
-                                                              null,
-                                                              vars,
-                                                              registry ) );
-
-        context.getInvokerLookups().put( invokerClassName,
-                                         invokerLookup );
-        context.getDescrLookups().put( invokerClassName,
-                                       descrLookup );
-    }
-}

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,106 @@
+package org.drools.rule.builder.dialect.java;
+
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Declaration;
+import org.drools.rule.builder.ProcessBuildContext;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+import org.drools.util.StringUtils;
+import org.mvel.MVELTemplateRegistry;
+import org.mvel.TemplateInterpreter;
+import org.mvel.TemplateRegistry;
+
+public class AbstractJavaProcessBuilder {
+
+    protected static final TemplateRegistry RULE_REGISTRY    = new MVELTemplateRegistry();
+    protected static final TemplateRegistry INVOKER_REGISTRY = new MVELTemplateRegistry();
+
+    static {
+        RULE_REGISTRY.registerTemplate( new InputStreamReader( AbstractJavaProcessBuilder.class.getResourceAsStream( "javaRule.mvel" ) ) );
+        INVOKER_REGISTRY.registerTemplate( new InputStreamReader( AbstractJavaProcessBuilder.class.getResourceAsStream( "javaInvokers.mvel" ) ) );
+        MVELDialect.setLanguageLevel( 4 );
+
+    }
+
+    public TemplateRegistry getRuleTemplateRegistry() {
+        return RULE_REGISTRY;
+    }
+
+    public TemplateRegistry getInvokerTemplateRegistry() {
+        return INVOKER_REGISTRY;
+    }
+
+    public Map createVariableContext(final String className,
+                                     final String text,
+                                     final ProcessBuildContext context,
+                                     final String[] globals) {
+        final Map map = new HashMap();
+
+        map.put( "methodName",
+                 className );
+
+        map.put( "package",
+                 context.getPkg().getName() );
+
+        map.put( "processClassName",
+                 StringUtils.ucFirst( context.getProcessDescr().getClassName() ) );
+
+        map.put( "invokerClassName",
+                 context.getProcessDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker" );
+
+        if ( text != null ) {
+            map.put( "text",
+                     text );
+
+            map.put( "hashCode",
+                     new Integer( text.hashCode() ) );
+        }
+
+        final List globalTypes = new ArrayList( globals.length );
+        for ( int i = 0, length = globals.length; i < length; i++ ) {
+            globalTypes.add( ((Class) context.getPkg().getGlobals().get( globals[i] )).getName().replace( '$',
+                                                                                                          '.' ) );
+        }
+
+        map.put( "globals",
+                 globals );
+
+        map.put( "globalTypes",
+                 globalTypes );
+
+        return map;
+    }
+
+    public void generatTemplates(final String ruleTemplate,
+                                 final String invokerTemplate,
+                                 final ProcessBuildContext context,
+                                 final String className,
+                                 final Map vars,
+                                 final Object invokerLookup,
+                                 final BaseDescr descrLookup) {
+        TemplateRegistry registry = getRuleTemplateRegistry();
+        context.getMethods().add( TemplateInterpreter.parse( registry.getTemplate( ruleTemplate ),
+                                                             null,
+                                                             vars,
+                                                             registry ) );
+
+        registry = getInvokerTemplateRegistry();
+        final String invokerClassName = context.getPkg().getName() + "." + context.getProcessDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker";
+        context.getInvokers().put( invokerClassName,
+                                   TemplateInterpreter.parse( registry.getTemplate( invokerTemplate ),
+                                                              null,
+                                                              vars,
+                                                              registry ) );
+
+        context.getInvokerLookups().put( invokerClassName,
+                                         invokerLookup );
+        context.getDescrLookups().put( invokerClassName,
+                                       descrLookup );
+    }
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java (from rev 16518, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaBuilder.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,131 @@
+package org.drools.rule.builder.dialect.java;
+
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Declaration;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+import org.drools.util.StringUtils;
+import org.mvel.MVELTemplateRegistry;
+import org.mvel.TemplateInterpreter;
+import org.mvel.TemplateRegistry;
+
+public class AbstractJavaRuleBuilder {
+
+    protected static final TemplateRegistry RULE_REGISTRY    = new MVELTemplateRegistry();
+    protected static final TemplateRegistry INVOKER_REGISTRY = new MVELTemplateRegistry();
+
+    static {
+        RULE_REGISTRY.registerTemplate( new InputStreamReader( AbstractJavaRuleBuilder.class.getResourceAsStream( "javaRule.mvel" ) ) );
+        INVOKER_REGISTRY.registerTemplate( new InputStreamReader( AbstractJavaRuleBuilder.class.getResourceAsStream( "javaInvokers.mvel" ) ) );
+        MVELDialect.setLanguageLevel( 4 );
+        
+    }
+
+    public TemplateRegistry getRuleTemplateRegistry() {
+        return RULE_REGISTRY;
+    }
+
+    public TemplateRegistry getInvokerTemplateRegistry() {
+        return INVOKER_REGISTRY;
+    }
+
+    public Map createVariableContext(final String className,
+                                     final String text,
+                                     final RuleBuildContext context,
+                                     final Declaration[] declarations,
+                                     final Declaration[] localDeclarations,
+                                     final String[] globals) {
+        final Map map = new HashMap();
+
+        map.put( "methodName",
+                 className );
+
+        map.put( "package",
+                 context.getPkg().getName() );
+
+        map.put( "ruleClassName",
+                 StringUtils.ucFirst( context.getRuleDescr().getClassName() ) );
+
+        map.put( "invokerClassName",
+                 context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker" );
+
+        if ( text != null ) {
+            map.put( "text",
+                     text );
+
+            map.put( "hashCode",
+                     new Integer( text.hashCode() ) );
+        }
+
+        final String[] declarationTypes = new String[declarations.length];
+        for ( int i = 0, size = declarations.length; i < size; i++ ) {
+            declarationTypes[i] = ((JavaDialect) context.getDialect()).getTypeFixer().fix( declarations[i] );
+        }
+
+        map.put( "declarations",
+                 declarations );
+
+        map.put( "declarationTypes",
+                 declarationTypes );
+
+        if ( localDeclarations != null ) {
+            final String[] localDeclarationTypes = new String[localDeclarations.length];
+            for ( int i = 0, size = localDeclarations.length; i < size; i++ ) {
+                localDeclarationTypes[i] = ((JavaDialect) context.getDialect()).getTypeFixer().fix( localDeclarations[i] );
+            }
+
+            map.put( "localDeclarations",
+                     localDeclarations );
+
+            map.put( "localDeclarationTypes",
+                     localDeclarationTypes );
+        }
+
+        final List globalTypes = new ArrayList( globals.length );
+        for ( int i = 0, length = globals.length; i < length; i++ ) {
+            globalTypes.add( ((Class) context.getPkg().getGlobals().get( globals[i] )).getName().replace( '$',
+                                                                                                          '.' ) );
+        }
+
+        map.put( "globals",
+                 globals );
+
+        map.put( "globalTypes",
+                 globalTypes );
+
+        return map;
+    }
+
+    public void generatTemplates(final String ruleTemplate,
+                                 final String invokerTemplate,
+                                 final RuleBuildContext context,
+                                 final String className,
+                                 final Map vars,
+                                 final Object invokerLookup,
+                                 final BaseDescr descrLookup) {
+        TemplateRegistry registry = getRuleTemplateRegistry();
+        context.getMethods().add( TemplateInterpreter.parse( registry.getTemplate( ruleTemplate ),
+                                                             null,
+                                                             vars,
+                                                             registry ) );
+
+        registry = getInvokerTemplateRegistry();
+        final String invokerClassName = context.getPkg().getName() + "." + context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker";
+        context.getInvokers().put( invokerClassName,
+                                   TemplateInterpreter.parse( registry.getTemplate( invokerTemplate ),
+                                                              null,
+                                                              vars,
+                                                              registry ) );
+
+        context.getInvokerLookups().put( invokerClassName,
+                                         invokerLookup );
+        context.getDescrLookups().put( invokerClassName,
+                                       descrLookup );
+    }
+}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -21,6 +21,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeSet;
 
 import org.drools.base.accumulators.AccumulateFunction;
@@ -42,7 +43,7 @@
  * 
  * @author etirelli
  */
-public class JavaAccumulateBuilder extends AbstractJavaBuilder
+public class JavaAccumulateBuilder extends AbstractJavaRuleBuilder
     implements
     AccumulateBuilder {
 
@@ -79,7 +80,8 @@
 
             final JavaAnalysisResult analysis = (JavaAnalysisResult) context.getDialect().analyzeBlock( context,
                                                                                                         accumDescr,
-                                                                                                        accumDescr.getExpression() );
+                                                                                                        accumDescr.getExpression(),
+                                                                                                        new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
             final List[] usedIdentifiers = analysis.getBoundIdentifiers();
 
@@ -125,13 +127,16 @@
 
             final JavaAnalysisResult initCodeAnalysis = (JavaAnalysisResult) context.getDialect().analyzeBlock( context,
                                                                                                                 accumDescr,
-                                                                                                                accumDescr.getInitCode() );
+                                                                                                                accumDescr.getInitCode(),
+                                                                                                                new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
             final Dialect.AnalysisResult actionCodeAnalysis = context.getDialect().analyzeBlock( context,
                                                                                                  accumDescr,
-                                                                                                 accumDescr.getActionCode() );
+                                                                                                 accumDescr.getActionCode(),
+                                                                                                 new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
             final Dialect.AnalysisResult resultCodeAnalysis = context.getDialect().analyzeExpression( context,
                                                                                                       accumDescr,
-                                                                                                      accumDescr.getResultCode() );
+                                                                                                      accumDescr.getResultCode(),
+                                                                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
             final List requiredDeclarations = new ArrayList( initCodeAnalysis.getBoundIdentifiers()[0] );
             requiredDeclarations.addAll( actionCodeAnalysis.getBoundIdentifiers()[0] );
@@ -144,7 +149,8 @@
             if ( accumDescr.getReverseCode() != null ) {
                 final Dialect.AnalysisResult reverseCodeAnalysis = context.getDialect().analyzeBlock( context,
                                                                                                       accumDescr,
-                                                                                                      accumDescr.getActionCode() );
+                                                                                                      accumDescr.getActionCode(),
+                                                                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
                 requiredDeclarations.addAll( reverseCodeAnalysis.getBoundIdentifiers()[0] );
                 requiredGlobals.addAll( reverseCodeAnalysis.getBoundIdentifiers()[1] );
             }

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package org.drools.rule.builder.dialect.java;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DescrBuildError;
+import org.drools.lang.descr.ActionDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.rule.Declaration;
+import org.drools.rule.builder.ActionBuilder;
+import org.drools.rule.builder.ConsequenceBuilder;
+import org.drools.rule.builder.PackageBuildContext;
+import org.drools.rule.builder.ProcessBuildContext;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+import org.drools.spi.PatternExtractor;
+
+/**
+ * @author etirelli
+ *
+ */
+public class JavaActionBuilder extends AbstractJavaProcessBuilder
+    implements
+    ActionBuilder {
+
+    /* (non-Javadoc)
+     * @see org.drools.semantics.java.builder.ConsequenceBuilder#buildConsequence(org.drools.semantics.java.builder.BuildContext, org.drools.semantics.java.builder.BuildUtils, org.drools.lang.descr.RuleDescr)
+     */
+    public void build(final PackageBuildContext context,
+                      final ActionNodeImpl actionNode,
+                      final ActionDescr actionDescr) {
+
+        final String className = "action";
+
+        JavaDialect dialect = (JavaDialect) context.getDialect();
+
+        Dialect.AnalysisResult analysis = dialect.analyzeBlock( context,
+                                                                actionDescr,
+                                                                actionDescr.getText(),
+                                                                new Set[]{Collections.EMPTY_SET, context.getPkg().getGlobals().keySet()} );
+
+        if ( analysis == null ) {
+            // not possible to get the analysis results
+            return;
+        }
+
+        final List[] usedIdentifiers = analysis.getBoundIdentifiers();
+
+
+        final Map map = createVariableContext( className,
+                                               actionDescr.getText(),
+                                               (ProcessBuildContext) context,
+                                               (String[]) usedIdentifiers[1].toArray( new String[usedIdentifiers[1].size()] ) );
+        map.put( "text",
+                 actionDescr.getText() );
+
+        generatTemplates( "actionMethod",
+                          "actionInvoker",
+                          (ProcessBuildContext)context,
+                          className,
+                          map,
+                          actionNode,
+                          actionDescr );
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -19,9 +19,10 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.lang.descr.RuleDescr;
 import org.drools.rule.Declaration;
 import org.drools.rule.builder.ConsequenceBuilder;
@@ -32,7 +33,7 @@
  * @author etirelli
  *
  */
-public class JavaConsequenceBuilder extends AbstractJavaBuilder
+public class JavaConsequenceBuilder extends AbstractJavaRuleBuilder
     implements
     ConsequenceBuilder {
 
@@ -50,13 +51,14 @@
 
         Dialect.AnalysisResult analysis = context.getDialect().analyzeBlock( context,
                                                                              ruleDescr,
-                                                                             (String) ruleDescr.getConsequence() );
-        
-        if( analysis == null ) {
+                                                                             (String) ruleDescr.getConsequence(),
+                                                                             new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
+
+        if ( analysis == null ) {
             // not possible to get the analysis results
             return;
         }
-        
+
         final List[] usedIdentifiers = analysis.getBoundIdentifiers();
 
         final Declaration[] declarations = new Declaration[usedIdentifiers[0].size()];
@@ -85,10 +87,10 @@
             indexes[i] = new Integer( list.indexOf( declarations[i] ) );
             notPatterns[i] = (declarations[i].getExtractor() instanceof PatternExtractor) ? new Boolean( false ) : new Boolean( true );
             if ( (indexes[i]).intValue() == -1 ) {
-                context.getErrors().add( new RuleError( context.getRule(),
-                                                        ruleDescr,
-                                                        null,
-                                                        "Internal Error : Unable to find declaration in list while generating the consequence invoker" ) );
+                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
+                                                              ruleDescr,
+                                                              null,
+                                                              "Internal Error : Unable to find declaration in list while generating the consequence invoker" ) );
             }
         }
 

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -8,6 +8,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.drools.ruleflow.common.core.Process;
 import org.drools.base.ClassFieldExtractorCache;
 import org.drools.base.TypeResolver;
 import org.drools.commons.jci.compilers.CompilationResult;
@@ -19,7 +20,7 @@
 import org.drools.commons.jci.readers.ResourceReader;
 import org.drools.compiler.Dialect;
 import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.compiler.PackageBuilder.ErrorHandler;
 import org.drools.compiler.PackageBuilder.FunctionErrorHandler;
 import org.drools.compiler.PackageBuilder.RuleErrorHandler;
@@ -36,20 +37,25 @@
 import org.drools.lang.descr.NotDescr;
 import org.drools.lang.descr.OrDescr;
 import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.ProcessDescr;
 import org.drools.lang.descr.QueryDescr;
 import org.drools.lang.descr.RuleDescr;
 import org.drools.rule.LineMappings;
 import org.drools.rule.Package;
 import org.drools.rule.Rule;
 import org.drools.rule.builder.AccumulateBuilder;
+import org.drools.rule.builder.ActionBuilder;
 import org.drools.rule.builder.CollectBuilder;
 import org.drools.rule.builder.ConsequenceBuilder;
 import org.drools.rule.builder.ForallBuilder;
 import org.drools.rule.builder.FromBuilder;
 import org.drools.rule.builder.FunctionBuilder;
 import org.drools.rule.builder.GroupElementBuilder;
+import org.drools.rule.builder.PackageBuildContext;
 import org.drools.rule.builder.PatternBuilder;
 import org.drools.rule.builder.PredicateBuilder;
+import org.drools.rule.builder.ProcessBuildContext;
+import org.drools.rule.builder.ProcessClassBuilder;
 import org.drools.rule.builder.QueryBuilder;
 import org.drools.rule.builder.ReturnValueBuilder;
 import org.drools.rule.builder.RuleBuildContext;
@@ -58,6 +64,8 @@
 import org.drools.rule.builder.SalienceBuilder;
 import org.drools.rule.builder.dialect.mvel.MVELFromBuilder;
 import org.drools.rule.builder.dialect.mvel.MVELSalienceBuilder;
+import org.drools.compiler.PackageBuilder.ProcessInvokerErrorHandler;
+import org.drools.compiler.PackageBuilder.ProcessErrorHandler;
 import org.drools.util.StringUtils;
 
 public class JavaDialect
@@ -76,7 +84,9 @@
     private final JavaPredicateBuilder     predicate               = new JavaPredicateBuilder();
     private final JavaReturnValueBuilder   returnValue             = new JavaReturnValueBuilder();
     private final JavaConsequenceBuilder   consequence             = new JavaConsequenceBuilder();
-    private final JavaRuleClassBuilder     rule                    = new JavaRuleClassBuilder();
+    private final JavaActionBuilder        actionBuilder           = new JavaActionBuilder();
+    private final JavaRuleClassBuilder     ruleClassBuilder        = new JavaRuleClassBuilder();
+    private final JavaProcessClassBuilder  processClassBuilder     = new JavaProcessClassBuilder();
     private final MVELFromBuilder          from                    = new MVELFromBuilder();
     private final JavaFunctionBuilder      function                = new JavaFunctionBuilder();
     private final CollectBuilder           collect                 = new CollectBuilder();
@@ -96,9 +106,8 @@
     private PackageStore                   packageStoreWrapper;
     private Map                            errorHandlers;
     private List                           results;
-    // the class name for the rule
-    private String                         ruleClass;
 
+
     private TypeResolver             typeResolver;
     private ClassFieldExtractorCache classFieldExtractorCache;
 
@@ -195,26 +204,24 @@
                                                          "java",
                                                          this.src );
         ruleDescr.setClassName( StringUtils.ucFirst( ruleClassName ) );
-        ruleDescr.setDialect( this );
     }
 
-    public void setRuleClass(final String ruleClass) {
-        this.ruleClass = ruleClass;
-    }
 
     public String getExpressionDialectName() {
         return EXPRESSION_DIALECT_NAME;
     }
 
-    public AnalysisResult analyzeExpression(final RuleBuildContext context,
+    public AnalysisResult analyzeExpression(final PackageBuildContext context,
                                             final BaseDescr descr,
-                                            final Object content) {
+                                            final Object content,
+                                            final Set[] availableIdentifiers ) {
         JavaAnalysisResult result = null;
         try {
+            //new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()}
             result = this.analyzer.analyzeExpression( (String) content,
-                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
+                                                      availableIdentifiers);
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     descr,
                                                     e,
                                                     "Unable to determine the used declarations.\n" + e) );
@@ -222,15 +229,17 @@
         return result;
     }
 
-    public AnalysisResult analyzeBlock(final RuleBuildContext context,
+    public AnalysisResult analyzeBlock(final PackageBuildContext context,
                                        final BaseDescr descr,
-                                       final String text) {
+                                       final String text,
+                                       final Set[] availableIdentifiers) {
         JavaAnalysisResult result = null;
         try {
+            // new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} 
             result = this.analyzer.analyzeBlock( text,
-                                                 new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
+                                                 availableIdentifiers);
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     descr,
                                                     e,
                                                     "Unable to determine the used declarations.\n" + e) );
@@ -304,11 +313,19 @@
     public ConsequenceBuilder getConsequenceBuilder() {
         return this.consequence;
     }
+    
+    public ActionBuilder getActionBuilder() {
+        return this.actionBuilder;
+    }
 
     public RuleClassBuilder getRuleClassBuilder() {
-        return this.rule;
+        return this.ruleClassBuilder;
     }
 
+    public ProcessClassBuilder getProcessClassBuilder() {
+        return this.processClassBuilder;
+    }
+    
     public FunctionBuilder getFunctionBuilder() {
         return this.function;
     }
@@ -375,18 +392,21 @@
      * It will not actually call the compiler
      */
     public void addRule(final RuleBuildContext context) {
+        RuleClassBuilder classBuilder = context.getDialect().getRuleClassBuilder();
+       
+        String ruleClass = classBuilder.buildRule( context );
         // return if there is no ruleclass name;
-        if ( this.ruleClass == null ) {
+        if ( ruleClass == null ) {
             return;
-        }
+        }        
 
         final Rule rule = context.getRule();
         final RuleDescr ruleDescr = context.getRuleDescr();
 
-        // The compilation result is for th entire rule, so difficult to associate with any descr
+        // The compilation result is for the entire rule, so difficult to associate with any descr
         addClassCompileTask( this.pkg.getName() + "." + ruleDescr.getClassName(),
                              ruleDescr,
-                             this.ruleClass,
+                             ruleClass,
                              this.src,
                              new RuleErrorHandler( ruleDescr,
                                                    rule,
@@ -425,7 +445,63 @@
                                                                            mapping );
 
     }
+    
+    /**
+     * This will add the rule for compiling later on.
+     * It will not actually call the compiler
+     */
+    public void addAction(final ProcessBuildContext context) {
+        ProcessClassBuilder classBuilder = context.getDialect().getProcessClassBuilder();
+       
+        String processClass = classBuilder.buildRule( context );
+      
+        final Process process = context.getProcess();
+        final ProcessDescr processDescr = context.getProcessDescr();
 
+        // The compilation result is for the entire rule, so difficult to associate with any descr
+        addClassCompileTask( this.pkg.getName() + "." + processDescr.getClassName(),
+                             processDescr,
+                             processClass,
+                             this.src,
+                             new ProcessErrorHandler( processDescr,
+                                                   process,
+                                                   "Rule Compilation error" ) );
+
+        for ( final Iterator it = context.getInvokers().keySet().iterator(); it.hasNext(); ) {
+            final String className = (String) it.next();
+
+            // Check if an invoker - Action has been associated
+            // If so we add it to the PackageCompilationData as it will get wired up on compilation
+            final Object invoker = context.getInvokerLookups().get( className );
+            if ( invoker != null ) {
+                this.pkg.getPackageCompilationData().putInvoker( className,
+                                                                 invoker );
+            }
+            final String text = (String) context.getInvokers().get( className );
+
+            final BaseDescr descr = (BaseDescr) context.getDescrLookups().get( className );
+            addClassCompileTask( className,
+                                 descr,
+                                 text,
+                                 this.src,
+                                 new ProcessInvokerErrorHandler( processDescr,
+                                                              process,
+                                                              "Unable to generate action invoker." ) );
+
+        }
+        
+        // setup the line mappins for this rule
+        // @TODO must setup mappings
+//        final String name = this.pkg.getName() + "." + StringUtils.ucFirst( ruleDescr.getClassName() );
+//        final LineMappings mapping = new LineMappings( name );
+//        mapping.setStartLine( ruleDescr.getConsequenceLine() );
+//        mapping.setOffset( ruleDescr.getConsequenceOffset() );
+//
+//        context.getPkg().getPackageCompilationData().getLineMappings().put( name,
+//                                                                           mapping );
+
+    }    
+
     public void addFunction(final FunctionDescr functionDescr,
                             final TypeResolver typeResolver) {
 

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaEvalBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaEvalBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaEvalBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -18,6 +18,7 @@
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.compiler.Dialect;
 import org.drools.lang.descr.BaseDescr;
@@ -33,7 +34,7 @@
  * @author etirelli
  *
  */
-public class JavaEvalBuilder extends AbstractJavaBuilder
+public class JavaEvalBuilder extends AbstractJavaRuleBuilder
     implements
     RuleConditionBuilder {
 
@@ -66,7 +67,8 @@
 
         Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                                   evalDescr,
-                                                                                  evalDescr.getContent() );
+                                                                                  evalDescr.getContent(),
+                                                                                  new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
         final List[] usedIdentifiers = analysis.getBoundIdentifiers();
 
         final Declaration[] declarations = new Declaration[usedIdentifiers[0].size()];

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaPredicateBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaPredicateBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaPredicateBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -9,7 +9,7 @@
 import org.drools.rule.builder.PredicateBuilder;
 import org.drools.rule.builder.RuleBuildContext;
 
-public class JavaPredicateBuilder extends AbstractJavaBuilder
+public class JavaPredicateBuilder extends AbstractJavaRuleBuilder
     implements
     PredicateBuilder {
 

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaProcessClassBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaProcessClassBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaProcessClassBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package org.drools.rule.builder.dialect.java;
+
+import java.util.Iterator;
+
+import org.drools.lang.descr.ProcessDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.rule.builder.ProcessBuildContext;
+import org.drools.rule.builder.ProcessClassBuilder;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.RuleClassBuilder;
+import org.drools.util.StringUtils;
+
+/**
+ * @author etirelli
+ *
+ */
+public class JavaProcessClassBuilder
+    implements
+    ProcessClassBuilder {
+
+    /* (non-Javadoc)
+     * @see org.drools.rule.builder.dialect.java.RuleClassBuilder#buildRule(org.drools.rule.builder.BuildContext, org.drools.rule.builder.dialect.java.BuildUtils, org.drools.lang.descr.RuleDescr)
+     */
+    public String  buildRule(final ProcessBuildContext context) {
+        // If there is no compiled code, return
+        if ( context.getMethods().isEmpty() ) {
+            return null;
+        }
+        
+        final String lineSeparator = System.getProperty( "line.separator" );
+
+        final StringBuffer buffer = new StringBuffer();
+        buffer.append( "package " + context.getPkg().getName() + ";" + lineSeparator );
+
+        for ( final Iterator it = context.getPkg().getImports().iterator(); it.hasNext(); ) {
+            buffer.append( "import " + it.next() + ";" + lineSeparator );
+        }
+
+        for ( final Iterator it = context.getPkg().getStaticImports().iterator(); it.hasNext(); ) {
+            buffer.append( "import static " + it.next() + ";" + lineSeparator );
+        }
+
+        final ProcessDescr processDescr = context.getProcessDescr();
+        
+        buffer.append( "public class " + StringUtils.ucFirst( processDescr.getClassName() ) + " {" + lineSeparator );
+        buffer.append( "    private static final long serialVersionUID = 400L;" + lineSeparator );
+
+        // @TODO record line numbers for each Action method
+        for ( int i = 0, size = context.getMethods().size(); i < size; i++ ) {
+            buffer.append( context.getMethods().get( i ) + lineSeparator );           
+        }
+
+        final String[] lines = buffer.toString().split( lineSeparator );
+
+        buffer.append( "}" );
+
+        return buffer.toString();
+    }
+}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -9,7 +9,7 @@
 import org.drools.rule.builder.ReturnValueBuilder;
 import org.drools.rule.builder.RuleBuildContext;
 
-public class JavaReturnValueBuilder extends AbstractJavaBuilder
+public class JavaReturnValueBuilder extends AbstractJavaRuleBuilder
     implements
     ReturnValueBuilder {
     public void build(final RuleBuildContext context,

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaRuleClassBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaRuleClassBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaRuleClassBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -34,14 +34,12 @@
     /* (non-Javadoc)
      * @see org.drools.rule.builder.dialect.java.RuleClassBuilder#buildRule(org.drools.rule.builder.BuildContext, org.drools.rule.builder.dialect.java.BuildUtils, org.drools.lang.descr.RuleDescr)
      */
-    public void buildRule(final RuleBuildContext context) {
-        final JavaDialect dialect = (JavaDialect) context.getDialect();
-
+    public String  buildRule(final RuleBuildContext context) {
         // If there is no compiled code, return
         if ( context.getMethods().isEmpty() ) {
-            dialect.setRuleClass( null );
-            return;
+            return null;
         }
+        
         final String lineSeparator = System.getProperty( "line.separator" );
 
         final StringBuffer buffer = new StringBuffer();
@@ -71,6 +69,6 @@
         buffer.append( context.getMethods().get( context.getMethods().size() - 1 ) + lineSeparator );
         buffer.append( "}" );
 
-        dialect.setRuleClass( buffer.toString() );
+        return buffer.toString();
     }
 }

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELAccumulateBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELAccumulateBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELAccumulateBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import org.drools.base.accumulators.AccumulateFunction;
 import org.drools.base.accumulators.MVELAccumulatorFunctionExecutor;
@@ -87,7 +88,8 @@
             // build an external function executor
             final Dialect.AnalysisResult analysis = dialect.analyzeExpression( context,
                                                                                accumDescr,
-                                                                               accumDescr.getExpression() );
+                                                                               accumDescr.getExpression(),
+                                                                               new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
             int size = analysis.getBoundIdentifiers()[0].size();
             declarations = new Declaration[size];
@@ -110,17 +112,20 @@
             // it is a custom accumulate
             final MVELAnalysisResult initCodeAnalysis = (MVELAnalysisResult) dialect.analyzeBlock( context,
                                                                                                    accumDescr,
-                                                                                                   accumDescr.getInitCode() );
+                                                                                                   accumDescr.getInitCode(),
+                                                                                                   new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
             final MVELAnalysisResult actionCodeAnalysis = (MVELAnalysisResult) dialect.analyzeBlock( context,
                                                                                                      accumDescr,
                                                                                                      null,
                                                                                                      accumDescr.getActionCode(),
+                                                                                                     new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()},
                                                                                                      initCodeAnalysis.getMvelVariables() );
             actionCodeAnalysis.setMvelVariables( initCodeAnalysis.getMvelVariables() );
             final MVELAnalysisResult resultCodeAnalysis = (MVELAnalysisResult) dialect.analyzeExpression( context,
                                                                                                           accumDescr,
                                                                                                           accumDescr.getResultCode(),
+                                                                                                          new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()},
                                                                                                           initCodeAnalysis.getMvelVariables() );
             resultCodeAnalysis.setMvelVariables( initCodeAnalysis.getMvelVariables() );
 
@@ -131,7 +136,8 @@
             if ( accumDescr.getReverseCode() != null ) {
                 final Dialect.AnalysisResult reverseCodeAnalysis = context.getDialect().analyzeBlock( context,
                                                                                                       accumDescr,
-                                                                                                      accumDescr.getActionCode() );
+                                                                                                      accumDescr.getActionCode(),
+                                                                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
                 requiredDeclarations.addAll( reverseCodeAnalysis.getBoundIdentifiers()[0] );
             }
 

Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,120 @@
+package org.drools.rule.builder.dialect.mvel;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.base.mvel.DroolsMVELFactory;
+import org.drools.base.mvel.MVELAction;
+import org.drools.base.mvel.MVELConsequence;
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DescrBuildError;
+import org.drools.lang.descr.ActionDescr;
+import org.drools.rule.builder.ActionBuilder;
+import org.drools.rule.builder.ConsequenceBuilder;
+import org.drools.rule.builder.PackageBuildContext;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+import org.mvel.Macro;
+import org.mvel.MacroProcessor;
+
+public class MVELActionBuilder
+    implements
+    ActionBuilder {
+
+    public MVELActionBuilder() {
+
+    }
+
+    public void build(final PackageBuildContext context,
+                      final ActionNodeImpl actionNode,
+                      final ActionDescr actionDescr) {
+
+        String text = actionDescr.getText();
+
+        try {
+            MVELDialect dialect = (MVELDialect) context.getDialect();
+
+            Dialect.AnalysisResult analysis = dialect.analyzeBlock( context,
+                                                                    actionDescr,
+                                                                    dialect.getInterceptors(),
+                                                                    text,
+                                                                    new Set[]{Collections.EMPTY_SET, context.getPkg().getGlobals().keySet()},
+                                                                    null );
+
+            final Serializable expr = dialect.compile( text,
+                                                       analysis,
+                                                       dialect.getInterceptors(),
+                                                       null,
+                                                       context );
+
+            final DroolsMVELFactory factory = new DroolsMVELFactory( null,
+                                                                     null,
+                                                                     context.getPkg().getGlobals(),
+                                                                     analysis.getBoundIdentifiers() );
+            
+            actionNode.setAction( new MVELAction( expr, factory )  );
+        } catch ( final Exception e ) {
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
+                                                          actionDescr,
+                                                          null,
+                                                          "Unable to build expression for 'action' '" + actionDescr.getText() + "'" ) );
+        }
+    }
+
+    /**
+     * Allows newlines to demarcate expressions, as per MVEL command line.
+     * If expression spans multiple lines (ie inside an unbalanced bracket) then
+     * it is left alone.
+     * Uses character based iteration which is at least an order of magnitude faster then a single
+     * simple regex.
+     */
+    public static String delimitExpressions(String s) {
+
+        StringBuffer result = new StringBuffer();
+        char[] cs = s.toCharArray();
+        int brace = 0;
+        int sqre = 0;
+        int crly = 0;
+        char lastNonWhite = ';';
+        for ( int i = 0; i < cs.length; i++ ) {
+            char c = cs[i];
+            switch ( c ) {
+                case '(' :
+                    brace++;
+                    break;
+                case '{' :
+                    crly++;
+                    break;
+                case '[' :
+                    sqre++;
+                    break;
+                case ')' :
+                    brace--;
+                    break;
+                case '}' :
+                    crly--;
+                    break;
+                case ']' :
+                    sqre--;
+                    break;
+                default :
+                    break;
+            }
+            if ( (brace == 0 && sqre == 0 && crly == 0) && (c == '\n' || c == '\r') ) {
+                if ( lastNonWhite != ';' ) {
+                    result.append( ';' );
+                    lastNonWhite = ';';
+                }
+            } else if ( !Character.isWhitespace( c ) ) {
+                lastNonWhite = c;
+            }
+            result.append( c );
+
+        }
+        return result.toString();
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -3,11 +3,12 @@
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.base.mvel.DroolsMVELFactory;
 import org.drools.base.mvel.MVELConsequence;
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.rule.builder.ConsequenceBuilder;
 import org.drools.rule.builder.RuleBuildContext;
 import org.mvel.Macro;
@@ -75,6 +76,7 @@
                                                                     context.getRuleDescr(),
                                                                     dialect.getInterceptors(),
                                                                     text,
+                                                                    new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()},
                                                                     null );
 
             final Serializable expr = dialect.compile( text,
@@ -91,7 +93,7 @@
             context.getRule().setConsequence( new MVELConsequence( expr,
                                                                    factory ) );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     context.getRuleDescr(),
                                                     null,
                                                     "Unable to build expression for 'consequence' '" + context.getRuleDescr().getConsequence() + "'" ) );

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -15,10 +15,11 @@
 import org.drools.base.TypeResolver;
 import org.drools.base.mvel.MVELDebugHandler;
 import org.drools.commons.jci.readers.MemoryResourceReader;
+import org.drools.compiler.ActionError;
 import org.drools.compiler.Dialect;
 import org.drools.compiler.ImportError;
 import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.lang.descr.AccumulateDescr;
 import org.drools.lang.descr.AndDescr;
 import org.drools.lang.descr.BaseDescr;
@@ -37,13 +38,16 @@
 import org.drools.rule.LineMappings;
 import org.drools.rule.Package;
 import org.drools.rule.builder.AccumulateBuilder;
+import org.drools.rule.builder.ActionBuilder;
 import org.drools.rule.builder.CollectBuilder;
 import org.drools.rule.builder.ConsequenceBuilder;
 import org.drools.rule.builder.ForallBuilder;
 import org.drools.rule.builder.FromBuilder;
 import org.drools.rule.builder.GroupElementBuilder;
+import org.drools.rule.builder.PackageBuildContext;
 import org.drools.rule.builder.PatternBuilder;
 import org.drools.rule.builder.PredicateBuilder;
+import org.drools.rule.builder.ProcessClassBuilder;
 import org.drools.rule.builder.QueryBuilder;
 import org.drools.rule.builder.ReturnValueBuilder;
 import org.drools.rule.builder.RuleBuildContext;
@@ -70,8 +74,6 @@
 
     private final static String               EXPRESSION_DIALECT_NAME = "MVEL";
 
-    private final MVELRuleClassBuilder        rule                    = new MVELRuleClassBuilder();
-
     private final PatternBuilder              pattern                 = new PatternBuilder();
     private final QueryBuilder                query                   = new QueryBuilder();
     private final MVELAccumulateBuilder       accumulate              = new MVELAccumulateBuilder();
@@ -80,6 +82,7 @@
     private final MVELPredicateBuilder        predicate               = new MVELPredicateBuilder();
     private final MVELReturnValueBuilder      returnValue             = new MVELReturnValueBuilder();
     private final MVELConsequenceBuilder      consequence             = new MVELConsequenceBuilder();
+    private final MVELActionBuilder           actionBuilder           = new MVELActionBuilder();
     //private final JavaRuleClassBuilder            rule        = new JavaRuleClassBuilder();
     private final MVELFromBuilder             from                    = new MVELFromBuilder();
     private final JavaFunctionBuilder         function                = new JavaFunctionBuilder();
@@ -224,7 +227,6 @@
         															 "mvel",
         															 this.src );
         ruleDescr.setClassName( StringUtils.ucFirst( ruleClassName ) );
-        ruleDescr.setDialect( this );
     }
 
     public String getExpressionDialectName() {
@@ -302,27 +304,32 @@
     public void compileAll() {
     }
 
-    public Dialect.AnalysisResult analyzeExpression(RuleBuildContext context,
+    public Dialect.AnalysisResult analyzeExpression(PackageBuildContext context,
                                                     BaseDescr descr,
-                                                    Object content) {
+                                                    Object content,
+                                                    final Set[] availableIdentifiers) {
         return analyzeExpression( context,
                                   descr,
                                   content,
+                                  availableIdentifiers,
                                   null );
     }
 
-    public Dialect.AnalysisResult analyzeExpression(RuleBuildContext context,
+    public Dialect.AnalysisResult analyzeExpression(PackageBuildContext context,
                                                     BaseDescr descr,
                                                     Object content,
+                                                    final Set[] availableIdentifiers,
                                                     Map localTypes) {
+        //new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()},
+        
         Dialect.AnalysisResult result = null;
         try {
             result = this.analyzer.analyzeExpression( context,
                                                       (String) content,
-                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()},
+                                                      availableIdentifiers,
                                                       localTypes );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     descr,
                                                     null,
                                                     "Unable to determine the used declarations.\n" + e.getMessage()) );
@@ -330,41 +337,46 @@
         return result;
     }
 
-    public Dialect.AnalysisResult analyzeBlock(RuleBuildContext context,
+    public Dialect.AnalysisResult analyzeBlock(PackageBuildContext context,
                                                BaseDescr descr,
-                                               String text) {
+                                               String text,
+                                               final Set[] availableIdentifiers) {
         return analyzeBlock( context,
                              descr,
                              null,
                              text,
+                             availableIdentifiers,
                              null );
     }
 
-    public Dialect.AnalysisResult analyzeBlock(RuleBuildContext context,
+    public Dialect.AnalysisResult analyzeBlock(PackageBuildContext context,
                                                BaseDescr descr,
                                                Map interceptors,
                                                String text,
+                                               final Set[] availableIdentifiers,
                                                Map localTypes) {
+        //new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()}
+        
         Dialect.AnalysisResult result = null;
         try {
             result = this.analyzer.analyzeExpression( context,
                                                       text,
-                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()},
+                                                      availableIdentifiers,
                                                       localTypes );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     descr,
                                                     e,
                                                     "Unable to determine the used declarations.\n" + e.getMessage()) );
         }
         return result;
-    }
-
+    }  
+    
     public Serializable compile(final String text,
                                 final Dialect.AnalysisResult analysis,
                                 final Map interceptors,
                                 final Map outerDeclarations,
-                                final RuleBuildContext context) {
+                                final PackageBuildContext context) {
         final ParserContext parserContext = getParserContext(analysis, outerDeclarations, context );
 
         ExpressionCompiler compiler = new ExpressionCompiler( text.trim() );
@@ -378,10 +390,12 @@
         return expr;
     }
 
-    public ParserContext getParserContext(final Dialect.AnalysisResult analysis, final Map outerDeclarations, final RuleBuildContext context) {
+    public ParserContext getParserContext(final Dialect.AnalysisResult analysis, final Map outerDeclarations, final PackageBuildContext context) {
+        // @todo proper source file name
         final ParserContext parserContext = new ParserContext( this.imports,
                                                                null,
-                                                               context.getPkg().getName()+"."+context.getRuleDescr().getClassName() );
+                                                               "xxx" );//context.getPkg().getName()+"."+context.getRuleDescr().getClassName() );
+        
 
         for ( Iterator it = this.packageImports.values().iterator(); it.hasNext(); ) {
             String packageImport = ( String ) it.next();
@@ -393,14 +407,19 @@
         if ( interceptors != null ) {
             parserContext.setInterceptors( interceptors );
         }
-        //FIXME: analysis can be null, throws an NPE
+        
         List list[] = analysis.getBoundIdentifiers();
-        DeclarationScopeResolver resolver = context.getDeclarationResolver();
-        for ( Iterator it = list[0].iterator(); it.hasNext(); ) {
-            String identifier = (String) it.next();
-            Class cls = resolver.getDeclaration( identifier ).getExtractor().getExtractToClass();
-            parserContext.addInput( identifier,
-                                    cls );
+        
+        // @TODO yuck, we don't want conditions for configuration :(
+        if ( context instanceof RuleBuildContext ) {
+            //FIXME: analysis can be null, throws an NPE
+            DeclarationScopeResolver resolver = ((RuleBuildContext)context).getDeclarationResolver();
+            for ( Iterator it = list[0].iterator(); it.hasNext(); ) {
+                String identifier = (String) it.next();
+                Class cls = resolver.getDeclaration( identifier ).getExtractor().getExtractToClass();
+                parserContext.addInput( identifier,
+                                        cls );
+            }
         }
 
         Map globalTypes = context.getPkg().getGlobals();
@@ -460,6 +479,10 @@
     public ConsequenceBuilder getConsequenceBuilder() {
         return this.consequence;
     }
+    
+    public ActionBuilder getActionBuilder() {
+        return this.actionBuilder;
+    }
 
     public RuleConditionBuilder getEvalBuilder() {
         return this.eval;
@@ -490,8 +513,12 @@
     }
 
     public RuleClassBuilder getRuleClassBuilder() {
-        return rule;
+        throw new UnsupportedOperationException("MVELDialect.getRuleClassBuilder is not supported" );
     }
+    
+    public ProcessClassBuilder getProcessClassBuilder() {
+        throw new UnsupportedOperationException("MVELDialect.getProcessClassBuilder is not supported" );
+    }    
 
     public TypeResolver getTypeResolver() {
         return this.typeResolver;

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -20,11 +20,12 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.base.mvel.DroolsMVELFactory;
 import org.drools.base.mvel.MVELEvalExpression;
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.lang.descr.BaseDescr;
 import org.drools.lang.descr.EvalDescr;
 import org.drools.rule.Declaration;
@@ -77,7 +78,8 @@
 
             Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                                       evalDescr,
-                                                                                      evalDescr.getContent() );
+                                                                                      evalDescr.getContent(),
+                                                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
             final List[] usedIdentifiers = analysis.getBoundIdentifiers();
 
             final Declaration[] declarations = new Declaration[usedIdentifiers[0].size()];
@@ -98,7 +100,7 @@
 
             return eval;
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     evalDescr,
                                                     e,
                                                     "Unable to build expression for 'eval' node '" + evalDescr.getContent() + "'" ) );

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -26,6 +26,7 @@
 import java.util.Set;
 
 import org.antlr.runtime.RecognitionException;
+import org.drools.rule.builder.PackageBuildContext;
 import org.drools.rule.builder.RuleBuildContext;
 import org.mvel.ExpressionCompiler;
 import org.mvel.ParserContext;
@@ -57,7 +58,7 @@
      * @throws RecognitionException 
      *             If an error occurs in the parser.
      */
-    public MVELAnalysisResult analyzeExpression(final RuleBuildContext context,
+    public MVELAnalysisResult analyzeExpression(final PackageBuildContext context,
                                                 final String expr,
                                                 final Set[] availableIdentifiers,
                                                 final Map localTypes) throws RecognitionException {
@@ -67,9 +68,10 @@
 
             MVELDialect dialect = (MVELDialect) context.getDialect( "mvel" );
 
+            // @todo proper source file name
             final ParserContext parserContext = new ParserContext( dialect.getImports(),
                                                                    null,
-                                                                   context.getPkg().getName() + "." + context.getRuleDescr().getClassName() );
+                                                                   "xxx" ); //context.getPkg().getName() + "." + context.getRuleDescr().getClassName() );
 
             if ( dialect.getPackgeImports() != null && !dialect.getPackgeImports().isEmpty() ) {
 	            for ( Iterator it = dialect.getPackgeImports().values().iterator(); it.hasNext(); ) {

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -17,11 +17,12 @@
 package org.drools.rule.builder.dialect.mvel;
 
 import java.io.Serializable;
+import java.util.Set;
 
 import org.drools.base.dataproviders.MVELDataProvider;
 import org.drools.base.mvel.DroolsMVELFactory;
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.lang.descr.AccessorDescr;
 import org.drools.lang.descr.BaseDescr;
 import org.drools.lang.descr.FromDescr;
@@ -70,7 +71,8 @@
             String text = (String) accessor.toString();
             Dialect.AnalysisResult analysis = dialect.analyzeExpression( context,
                                                                          descr,
-                                                                         text );
+                                                                         text,
+                                                                         new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
             final Serializable expr = dialect.compile( text,
                                                        analysis,
@@ -81,10 +83,10 @@
             dataProvider = new MVELDataProvider( expr,
                                                  factory );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
-                                                    fromDescr,
-                                                    null,
-                                                    "Unable to build expression for 'from' node '" + accessor + "'" ) );
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
+                                                          fromDescr,
+                                                          null,
+                                                          "Unable to build expression for 'from' node '" + accessor + "'" ) );
             return null;
         }
 

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -20,11 +20,12 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.base.mvel.DroolsMVELFactory;
 import org.drools.base.mvel.MVELPredicateExpression;
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.lang.descr.PredicateDescr;
 import org.drools.rule.Declaration;
 import org.drools.rule.PredicateConstraint;
@@ -67,14 +68,15 @@
             
             Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                                       predicateDescr,
-                                                                                      predicateDescr.getContent() );
+                                                                                      predicateDescr.getContent(),
+                                                                                      new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
             
             final Serializable expr = ((MVELDialect) context.getDialect()).compile( (String) predicateDescr.getContent(), analysis, null, null, context );            
             
             predicate.setPredicateExpression( new MVELPredicateExpression( expr,
                                                                            factory ) );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                     predicateDescr,
                                                     e,
                                                     "Unable to build expression for 'inline-eval' node '" + predicateDescr.getContent() + "'\n" + e.getMessage() ) );

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -20,6 +20,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.drools.base.mvel.DroolsMVELFactory;
 import org.drools.base.mvel.MVELReturnValueExpression;
@@ -64,7 +65,8 @@
         
         Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                                   returnValueRestrictionDescr,
-                                                                                  returnValueRestrictionDescr.getContent() );
+                                                                                  returnValueRestrictionDescr.getContent(),
+                                                                                  new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
         
         final Serializable expr = ((MVELDialect) context.getDialect()).compile( (String) returnValueRestrictionDescr.getContent(), analysis, null, null, context );        
         

Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELRuleClassBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELRuleClassBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELRuleClassBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -1,26 +0,0 @@
-package org.drools.rule.builder.dialect.mvel;
-
-import org.drools.lang.descr.RuleDescr;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.RuleClassBuilder;
-
-public class MVELRuleClassBuilder
-    implements
-    RuleClassBuilder {
-
-    /**
-     * No real building for now.
-     * Simply to update ruleDescr.setConsequenceOffset
-     */
-    public void buildRule(RuleBuildContext context) {
-        final MVELDialect dialect = (MVELDialect) context.getDialect();
-
-        final String lineSeparator = System.getProperty( "line.separator" );
-
-        final StringBuffer buffer = new StringBuffer();
-
-        final RuleDescr ruleDescr = context.getRuleDescr();
-
-        ruleDescr.setConsequenceOffset( 0);
-    }
-}

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -1,11 +1,12 @@
 package org.drools.rule.builder.dialect.mvel;
 
 import java.io.Serializable;
+import java.util.Set;
 
 import org.drools.base.mvel.DroolsMVELFactory;
 import org.drools.base.mvel.MVELSalienceExpression;
 import org.drools.compiler.Dialect;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.rule.builder.RuleBuildContext;
 import org.drools.rule.builder.SalienceBuilder;
 import org.mvel.ExpressionCompiler;
@@ -25,30 +26,30 @@
             final DroolsMVELFactory factory = new DroolsMVELFactory( context.getDeclarationResolver().getDeclarations(),
                                                                      null,
                                                                      context.getPkg().getGlobals() );
-            
+
             // This builder is re-usable in other dialects, so specify by name            
             MVELDialect dialect = (MVELDialect) context.getDialect( "mvel" );
 
-
             Dialect.AnalysisResult analysis = dialect.analyzeExpression( context,
                                                                          context.getRuleDescr(),
-                                                                         (String) context.getRuleDescr().getSalience() );
+                                                                         (String) context.getRuleDescr().getSalience(),
+                                                                         new Set[]{context.getDeclarationResolver().getDeclarations().keySet(), context.getPkg().getGlobals().keySet()} );
 
             final Serializable expr = dialect.compile( (String) context.getRuleDescr().getSalience(),
-                                                                                    analysis,
-                                                                                    null,
-                                                                                    null,
-                                                                                    context );
+                                                       analysis,
+                                                       null,
+                                                       null,
+                                                       context );
 
             MVELSalienceExpression salience = new MVELSalienceExpression( expr,
                                                                           factory );
 
             context.getRule().setSalience( salience );
         } catch ( final Exception e ) {
-            context.getErrors().add( new RuleError( context.getRule(),
-                                                    context.getRuleDescr(),
-                                                    null,
-                                                    "Unable to build expression for 'salience' node '" + context.getRuleDescr().getSalience() + "'" ) );
+            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
+                                                          context.getRuleDescr(),
+                                                          null,
+                                                          "Unable to build expression for 'salience' node '" + context.getRuleDescr().getSalience() + "'" ) );
         }
     }
 

Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel	2007-11-23 16:34:06 UTC (rev 16763)
@@ -326,4 +326,23 @@
 	        @end{","} );
     }
 }     
+>>=::
+
+actionInvoker() ::=<<
+package @{package};
+
+public class @{invokerClassName} implements org.drools.spi.Action
+{
+    private static final long serialVersionUID  = 400L;
+
+    public void execute(org.drools.WorkingMemory workingMemory) throws Exception {    
+                               
+        @foreach{globalTypes, globals as type, identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" ); 
+        @end{}    
+        
+        @{processClassName}.@{methodName} ( 
+	        @foreach{globals as identifier} @{identifier}
+	        @end{","} );
+    }
+}     
 >>=::
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel	2007-11-23 16:34:06 UTC (rev 16763)
@@ -72,4 +72,10 @@
 public static void @{methodName}(org.drools.spi.KnowledgeHelper drools at if{declarations != empty}, at end{} @foreach{declarationTypes, declarations as type, declr} @{type} @{declr.identifier}, org.drools.FactHandle @{declr.identifier}__Handle__ @end{","}@if{globals != empty}, at end{} @foreach{globalTypes, globals as type, identifier}  @{type} @{identifier} @end{","} ) throws Exception {
     @{text}
 }
+>>=::
+
+actionMethod() ::=<<
+public static void @{methodName}(@foreach{globalTypes, globals as type, identifier}  @{type} @{identifier} @end{","} ) throws Exception {
+    @{text}
+}
 >>=::
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -4,6 +4,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
@@ -23,11 +24,14 @@
 import org.drools.rule.Rule;
 import org.drools.rule.RuleConditionElement;
 import org.drools.rule.builder.AccumulateBuilder;
+import org.drools.rule.builder.ActionBuilder;
 import org.drools.rule.builder.ConsequenceBuilder;
 import org.drools.rule.builder.FromBuilder;
 import org.drools.rule.builder.GroupElementBuilder;
+import org.drools.rule.builder.PackageBuildContext;
 import org.drools.rule.builder.PatternBuilder;
 import org.drools.rule.builder.PredicateBuilder;
+import org.drools.rule.builder.ProcessClassBuilder;
 import org.drools.rule.builder.QueryBuilder;
 import org.drools.rule.builder.ReturnValueBuilder;
 import org.drools.rule.builder.RuleBuildContext;
@@ -301,16 +305,18 @@
             return this.rule;
         }
 
-        public AnalysisResult analyzeBlock(RuleBuildContext context,
+        public AnalysisResult analyzeBlock(PackageBuildContext context,
                                            BaseDescr descr,
-                                           String text) {
+                                           String text,
+                                           Set[] availableIdentifiers) {
             // TODO Auto-generated method stub
             return null;
         }
 
-        public AnalysisResult analyzeExpression(RuleBuildContext context,
+        public AnalysisResult analyzeExpression(PackageBuildContext context,
                                                 BaseDescr descr,
-                                                Object content) {
+                                                Object content,
+                                                Set[] availableIdentifiers) {
             // TODO Auto-generated method stub
             return null;
         }
@@ -339,12 +345,10 @@
         }
 
         public Map getBuilders() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public ClassFieldExtractorCache getClassFieldExtractorCache() {
-            // TODO Auto-generated method stub
             return null;
         }
 
@@ -357,54 +361,52 @@
         }
 
         public String getExpressionDialectName() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public FromBuilder getFromBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public PatternBuilder getPatternBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public PredicateBuilder getPredicateBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public QueryBuilder getQueryBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public List getResults() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public ReturnValueBuilder getReturnValueBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public RuleClassBuilder getRuleClassBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
+        
+        public ProcessClassBuilder getProcessClassBuilder() {
+            return null;
+        }        
 
         public SalienceBuilder getSalienceBuilder() {
-            // TODO Auto-generated method stub
             return null;
         }
 
         public TypeResolver getTypeResolver() {
-            // TODO Auto-generated method stub
             return null;
         }
+        
+        public ActionBuilder getActionBuilder() {
+            return null;
+        }        
 
         public String getId() {
             return "mock";

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -2,6 +2,7 @@
 
 import org.drools.commons.jci.problems.CompilationProblem;
 import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.RuleDescr;
 import org.drools.rule.Rule;
 
 import junit.framework.TestCase;
@@ -14,24 +15,24 @@
         probs[1] = new MockCompilationProblem();
         probs[2] = new MockCompilationProblem();
 
-        
-        RuleError err = new RuleError(new Rule("ruleName"), 
-                                      new AndDescr(), 
-                                      probs, 
-                                      "IM IN YR EROR");
-        assertNotNull(err.toString());
+        DescrBuildError err = new DescrBuildError( new RuleDescr( "ruleName" ),
+                                                   new AndDescr(),
+                                                   probs,
+                                                   "IM IN YR EROR" );
+        assertNotNull( err.toString() );
         String msg = err.getMessage();
-        
-        assertTrue(msg.indexOf( "IM IN YR EROR") != -1);
-        System.err.println(msg);        
-        assertEquals("IM IN YR EROR problem\nproblem\nproblem", msg);
 
-        
+        assertTrue( msg.indexOf( "IM IN YR EROR" ) != -1 );
+        System.err.println( msg );
+        assertEquals( "IM IN YR EROR problem\nproblem\nproblem",
+                      msg );
+
     }
-    
-    
-    class MockCompilationProblem implements CompilationProblem {
 
+    class MockCompilationProblem
+        implements
+        CompilationProblem {
+
         public int getEndColumn() {
             return 0;
         }
@@ -59,7 +60,7 @@
         public boolean isError() {
             return true;
         }
-        
+
     }
-    
+
 }

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -86,7 +86,7 @@
 import org.drools.compiler.PackageBuilder;
 import org.drools.compiler.PackageBuilderConfiguration;
 import org.drools.compiler.ParserError;
-import org.drools.compiler.RuleError;
+import org.drools.compiler.DescrBuildError;
 import org.drools.compiler.PackageBuilder.PackageMergeException;
 import org.drools.event.ActivationCancelledEvent;
 import org.drools.event.ActivationCreatedEvent;
@@ -1201,7 +1201,7 @@
         final Package pkg = builder.getPackage();
 
         final DroolsError err = builder.getErrors().getErrors()[0];
-        final RuleError ruleErr = (RuleError) err;
+        final DescrBuildError ruleErr = (DescrBuildError) err;
         assertNotNull( ruleErr.getDescr() );
         assertTrue( ruleErr.getLine() != -1 );
 
@@ -1219,7 +1219,7 @@
 
         // now check the RHS, not being too specific yet, as long as it has the
         // rules line number, not zero
-        final RuleError rhs = (RuleError) builder.getErrors().getErrors()[2];
+        final DescrBuildError rhs = (DescrBuildError) builder.getErrors().getErrors()[2];
         assertTrue( rhs.getLine() > 7 ); // not being too specific - may need to
         // change this when we rework the error
         // reporting

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/AccumulateTemplateTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/AccumulateTemplateTest.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/AccumulateTemplateTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -287,14 +287,14 @@
 
     private TemplateRegistry getRuleTemplateRegistry() {
         TemplateRegistry ruleRegistry = new MVELTemplateRegistry();
-        ruleRegistry.registerTemplate( new InputStreamReader( AbstractJavaBuilder.class.getResourceAsStream( "javaRule.mvel" ) ) );
+        ruleRegistry.registerTemplate( new InputStreamReader( AbstractJavaRuleBuilder.class.getResourceAsStream( "javaRule.mvel" ) ) );
 
         return ruleRegistry;
     }
 
     private TemplateRegistry getInvokerTemplateRegistry() {
         TemplateRegistry invokerRegistry = new MVELTemplateRegistry();
-        invokerRegistry.registerTemplate( new InputStreamReader( AbstractJavaBuilder.class.getResourceAsStream( "javaInvokers.mvel" ) ) );
+        invokerRegistry.registerTemplate( new InputStreamReader( AbstractJavaRuleBuilder.class.getResourceAsStream( "javaInvokers.mvel" ) ) );
 
         return invokerRegistry;
     }

Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,102 @@
+package org.drools.rule.builder.dialect.java;
+
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.drools.Cheese;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.base.ClassObjectType;
+import org.drools.base.DefaultKnowledgeHelper;
+import org.drools.base.mvel.MVELConsequence;
+import org.drools.base.mvel.MVELDebugHandler;
+import org.drools.common.AgendaItem;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.PropagationContextImpl;
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DialectConfiguration;
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.ActionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.ProcessDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.rule.Package;
+import org.drools.rule.Pattern;
+import org.drools.rule.Rule;
+import org.drools.rule.builder.PackageBuildContext;
+import org.drools.rule.builder.ProcessBuildContext;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.RuleBuilder;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+import org.drools.ruleflow.core.impl.RuleFlowProcessImpl;
+import org.drools.spi.Action;
+import org.drools.spi.ObjectType;
+import org.drools.spi.PatternExtractor;
+import org.mvel.ExpressionCompiler;
+import org.mvel.ParserContext;
+
+public class JavaActionBuilderTest extends TestCase {
+
+    public void setUp() {
+    }
+    
+    public void testSimpleAction() throws Exception {
+        final Package pkg = new Package( "pkg1" );
+
+        ActionDescr actionDescr = new ActionDescr();
+        actionDescr.setText( "list.add( \"hello world\" );" );       
+
+        PackageBuilder pkgBuilder = new PackageBuilder( pkg );
+        final PackageBuilderConfiguration conf = pkgBuilder.getPackageBuilderConfiguration();
+        JavaDialect javaDialect = ( JavaDialect ) pkgBuilder.getDialectRegistry().getDialect( "java" );
+
+        ProcessDescr processDescr = new ProcessDescr();
+        processDescr.setClassName( "Process1" );
+        processDescr.setName( "Process1" );
+        
+        RuleFlowProcessImpl process = new RuleFlowProcessImpl();
+        process.setName( "Process1" );
+        process.setPackageName( "pkg1" );
+
+        ProcessBuildContext context = new ProcessBuildContext(conf, pkgBuilder.getPackage(), null, processDescr, pkgBuilder.getDialectRegistry(), javaDialect);
+        
+        context.init( conf, pkg, null, pkgBuilder.getDialectRegistry(), javaDialect, null);
+        
+        pkgBuilder.addPackageFromDrl( new StringReader("package pkg1;\nglobal java.util.List list;\n") );        
+        
+        ActionNodeImpl actionNode = new ActionNodeImpl();
+        
+        javaDialect.getActionBuilder().build( context, actionNode, actionDescr );
+        javaDialect.addAction( context );
+        javaDialect.compileAll();                
+
+        final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+        ruleBase.addPackage( pkgBuilder.getPackage() );
+        final WorkingMemory wm = ruleBase.newStatefulSession();
+
+        List list = new  ArrayList();
+        wm.setGlobal( "list", list );        
+        
+        ((Action)actionNode.getAction()).execute( wm );
+       
+        assertEquals("hello world", list.get(0) );
+    }    
+    
+
+}
+

Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -0,0 +1,90 @@
+package org.drools.rule.builder.dialect.mvel;
+
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.drools.Cheese;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.base.ClassObjectType;
+import org.drools.base.DefaultKnowledgeHelper;
+import org.drools.base.mvel.MVELConsequence;
+import org.drools.base.mvel.MVELDebugHandler;
+import org.drools.common.AgendaItem;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.PropagationContextImpl;
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DialectConfiguration;
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.ActionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.rule.Package;
+import org.drools.rule.Pattern;
+import org.drools.rule.Rule;
+import org.drools.rule.builder.PackageBuildContext;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.RuleBuilder;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+import org.drools.spi.Action;
+import org.drools.spi.ObjectType;
+import org.drools.spi.PatternExtractor;
+import org.mvel.ExpressionCompiler;
+import org.mvel.ParserContext;
+
+public class MVELActionBuilderTest extends TestCase {
+
+    public void setUp() {
+    }
+    
+    public void testSimpleAction() throws Exception {
+        final Package pkg = new Package( "pkg1" );
+
+        ActionDescr actionDescr = new ActionDescr();
+        actionDescr.setText( "list.add( 'hello world' )" );       
+
+        PackageBuilder pkgBuilder = new PackageBuilder( pkg );
+        final PackageBuilderConfiguration conf = pkgBuilder.getPackageBuilderConfiguration();
+        MVELDialect mvelDialect = ( MVELDialect ) pkgBuilder.getDialectRegistry().getDialect( "mvel" );
+
+        PackageBuildContext context = new PackageBuildContext();
+        context.init( conf, pkg, null, pkgBuilder.getDialectRegistry(), mvelDialect, null);
+        
+        pkgBuilder.addPackageFromDrl( new StringReader("package pkg1;\nglobal java.util.List list;\n") );        
+        
+        ActionNodeImpl actionNode = new ActionNodeImpl();
+        
+        final MVELActionBuilder builder = new MVELActionBuilder();
+        builder.build( context,
+                       actionNode,
+                       actionDescr );
+
+        final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+        ruleBase.addPackage( pkgBuilder.getPackage() );
+        final WorkingMemory wm = ruleBase.newStatefulSession();
+
+        List list = new  ArrayList();
+        wm.setGlobal( "list", list );        
+        
+        ((Action)actionNode.getAction()).execute( wm );
+        
+        assertEquals("hello world", list.get(0) );
+    }    
+
+}
+

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java	2007-11-23 16:33:01 UTC (rev 16762)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java	2007-11-23 16:34:06 UTC (rev 16763)
@@ -26,6 +26,7 @@
 import org.drools.compiler.DroolsParserException;
 import org.drools.compiler.PackageBuilder;
 import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.ActionDescr;
 import org.drools.lang.descr.PackageDescr;
 import org.drools.lang.descr.RuleDescr;
 import org.drools.reteoo.ReteTuple;
@@ -43,7 +44,7 @@
 public class MVELConsequenceBuilderTest extends TestCase {
 
     public void setUp() {
-    }
+    }    
 
     public void testSimpleExpression() throws Exception {
         final Package pkg = new Package( "pkg1" );




More information about the jboss-svn-commits mailing list