[jboss-svn-commits] JBL Code SVN: r31153 - in labs/jbossrules/branches/camel_jaxb_marshaller-lucaz: drools-core/src/main/java/org/drools and 15 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 19 18:18:02 EST 2010


Author: lucazamador
Date: 2010-01-19 18:18:01 -0500 (Tue, 19 Jan 2010)
New Revision: 31153

Added:
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ExecutionResultsType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactHandleListType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactObjectListType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/GlobalType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/InsertResultsType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ObjectFactory.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryFieldType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryResultsType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryRowType.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/package-info.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/AbstractResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResults.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResultsImpl.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GenericResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetGlobalResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetObjectsResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertElementsResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertObjectResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/QueryResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/SetGlobalResult.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/java/org/drools/camel/component/DroolsJaxbDataFormat.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/resources/META-INF/services/org/apache/camel/dataformat/drools-jaxb
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xml
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xsd
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/CommandTranslator.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlVsmTransformer.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/ResultTranslator.java
Modified:
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/JaxbTransformerProvider.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineFactory.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/QueryCommand.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlTransformer.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbToXmlTransformer.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformerProviderImpl.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbFactTest.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbGlobalTest.java
   labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbTest.java
Log:
added jaxb xml vsm transformer, jaxb data format & merge with laune branch

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/JaxbTransformerProvider.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/JaxbTransformerProvider.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/JaxbTransformerProvider.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -1,7 +1,6 @@
 package org.drools.runtime.pipeline;
 
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.JAXBContext;
 
 /**
  * 
@@ -9,7 +8,13 @@
  *
  */
 public interface JaxbTransformerProvider {
-    Transformer newJaxbFromXmlTransformer(Unmarshaller unmarshaller);
-
-    Transformer newJaxbToXmlTransformer(Marshaller marshaller);
+	
+    Transformer newJaxbFromXmlTransformer( JAXBContext jaxbCtx );
+    
+    Transformer newJaxbFromXmlCommandTransformer( JAXBContext jaxbCtx );
+    
+    Transformer newJaxbToXmlTransformer( JAXBContext jaxbCtx );
+    
+    Transformer newJaxbToXmlResultTransformer( JAXBContext jaxbCtx );
+    
 }

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineFactory.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineFactory.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-api/src/main/java/org/drools/runtime/pipeline/PipelineFactory.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -482,8 +482,8 @@
      * @param unmarshaller
      * @return
      */
-    public static Transformer newJaxbFromXmlTransformer(Unmarshaller unmarshaller) {
-        return getJaxbPipelineProvider().newJaxbFromXmlTransformer( unmarshaller );
+    public static Transformer newJaxbFromXmlTransformer(JAXBContext context) {
+        return getJaxbPipelineProvider().newJaxbFromXmlTransformer( context );
     }
 
     /**
@@ -499,8 +499,8 @@
      * @param marshaller
      * @return
      */
-    public static Transformer newJaxbToXmlTransformer(Marshaller marshaller) {
-        return getJaxbPipelineProvider().newJaxbToXmlTransformer( marshaller );
+    public static Transformer newJaxbToXmlTransformer(JAXBContext context) {
+        return getJaxbPipelineProvider().newJaxbToXmlTransformer( context );
     }
 
     /**

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,138 @@
+package org.drools.command.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.command.runtime.SetGlobalCommand;
+import org.drools.command.runtime.process.CompleteWorkItemCommand;
+import org.drools.command.runtime.process.AbortWorkItemCommand;
+import org.drools.command.runtime.process.SignalEventCommand;
+import org.drools.command.runtime.rule.FireAllRulesCommand;
+import org.drools.command.runtime.process.StartProcessCommand;
+import org.drools.command.runtime.GetGlobalCommand;
+import org.drools.command.runtime.rule.InsertElementsCommand;
+import org.drools.command.runtime.rule.QueryCommand;
+import org.drools.command.runtime.rule.InsertObjectCommand;
+
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.result.GenericResult;
+
+import org.drools.runtime.pipeline.impl.BasePipelineContext;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.result.ExecutionResults;
+
+import org.drools.reteoo.ReteooWorkingMemory;
+
+
+/**
+ * <p>Java class for BatchExecutionCommand complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="BatchExecutionCommand">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;choice maxOccurs="unbounded">
+ *         &lt;element name="abort-work-item" type="{http://drools.org/drools-5.0/knowledge-session}AbortWorkItemCommand"/>
+ *         &lt;element name="complete-work-item" type="{http://drools.org/drools-5.0/knowledge-session}CompleteWorkItemCommand"/>
+ *         &lt;element name="fire-all-rules" type="{http://drools.org/drools-5.0/knowledge-session}FireAllRulesCommand"/>
+ *         &lt;element name="get-global" type="{http://drools.org/drools-5.0/knowledge-session}GetGlobalCommand"/>
+ *         &lt;element name="insert" type="{http://drools.org/drools-5.0/knowledge-session}InsertObjectCommand"/>
+ *         &lt;element name="insert-elements" type="{http://drools.org/drools-5.0/knowledge-session}InsertElementsCommand"/>
+ *         &lt;element name="query" type="{http://drools.org/drools-5.0/knowledge-session}QueryCommand"/>
+ *         &lt;element name="set-global" type="{http://drools.org/drools-5.0/knowledge-session}SetGlobalCommand"/>
+ *         &lt;element name="signal-event" type="{http://drools.org/drools-5.0/knowledge-session}SignalEventCommand"/>
+ *         &lt;element name="start-process" type="{http://drools.org/drools-5.0/knowledge-session}StartProcessCommand"/>
+ *       &lt;/choice>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "BatchExecutionCommand", propOrder = {
+    "commands"
+})
+public class BatchExecutionCommand implements GenericCommand<Void> {
+
+	public BatchExecutionCommand(){
+	}
+	
+	public BatchExecutionCommand( List<GenericCommand<?>> commands ){
+		this.commands = commands;
+	}
+	
+	
+    @XmlElements({
+        @XmlElement(name = "set-global", type = SetGlobalCommand.class),
+        @XmlElement(name = "complete-work-item", type = CompleteWorkItemCommand.class),
+        @XmlElement(name = "abort-work-item", type = AbortWorkItemCommand.class),
+        @XmlElement(name = "signal-event", type = SignalEventCommand.class),
+        @XmlElement(name = "fire-all-rules", type = FireAllRulesCommand.class),
+        @XmlElement(name = "start-process", type = StartProcessCommand.class),
+        @XmlElement(name = "get-global", type = GetGlobalCommand.class),
+        @XmlElement(name = "insert-elements", type = InsertElementsCommand.class),
+        @XmlElement(name = "query", type = QueryCommand.class),
+        @XmlElement(name = "insert", type = InsertObjectCommand.class)
+    })
+    protected List<GenericCommand<?>> commands;
+
+    /**
+     * Gets the value of the abortWorkItemOrCompleteWorkItemOrFireAllRules property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the abortWorkItemOrCompleteWorkItemOrFireAllRules property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getCommand().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link SetGlobalCommand }
+     * {@link CompleteWorkItemCommand }
+     * {@link AbortWorkItemCommand }
+     * {@link SignalEventCommand }
+     * {@link FireAllRulesCommand }
+     * {@link StartProcessCommand }
+     * {@link GetGlobalCommand }
+     * {@link InsertElementsCommand }
+     * {@link QueryCommand }
+     * {@link InsertObjectCommand }
+     * 
+     * 
+     */
+    public List<GenericCommand<?>> getCommands() {
+        if (commands == null) {
+            commands = new ArrayList<GenericCommand<?>>();
+        }
+        return this.commands;
+    }
+
+
+    public Void execute(Context context) {
+        for ( GenericCommand<?> command : commands ) {
+            ((GenericCommand)command).execute( context );
+        }
+        return null;
+    }	
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -1,70 +1,96 @@
 package org.drools.command.runtime;
 
-import org.drools.KnowledgeBase;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
 import org.drools.command.Context;
 import org.drools.command.impl.GenericCommand;
 import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.impl.StatefulKnowledgeSessionImpl;
-import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.result.ExecutionResults;
+import org.drools.result.SetGlobalResult;
 import org.drools.runtime.StatefulKnowledgeSession;
 
+ at XmlAccessorType( XmlAccessType.NONE )
 public class SetGlobalCommand
     implements
     GenericCommand<Void> {
 
-    private String  identifier;
-    private Object  object;
+    @XmlAttribute(required = true)
+    private String identifier;
 
-    private String  outIdentifier;
+    @XmlElement
+    private Object object;
+    
+    @XmlAttribute(name = "out-identifier")
+    private String outIdentifier;
+    
+    @XmlAttribute
+    private Boolean out;
 
-    private boolean out;
+    public SetGlobalCommand(){
+    }
 
     public SetGlobalCommand(String identifier,
                             Object object) {
-        this.identifier = identifier;
-        this.object = object;
+    	this.identifier = identifier;
+    	this.object = object;
     }
 
     public Void execute(Context context) {
-        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+    	StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
 
-        if ( this.out ) {
-            ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult().getResults().put( (this.outIdentifier != null) ? this.outIdentifier : this.identifier,
-                                                                                                     object );
-        }
+    	ksession.setGlobal( this.identifier, this.object );
 
-        ksession.setGlobal( this.identifier,
-                            this.object );
-        return null;
+    	if ( this.isOut() ) {
+    		ExecutionResults execRes = (ExecutionResults)((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
+    		String id =  (this.outIdentifier != null) ? this.outIdentifier : this.identifier;
+    		execRes.getResults().add( new SetGlobalResult( id, object ) );
+    	}
+    	return null;
     }
 
-    public String getIdentifier() {
-        return this.identifier;
+    public Object getObject() {
+    	return this.object;
     }
 
-    public Object getObject() {
-        return this.object;
+    public void setObject( Object object ) {
+    	this.object = object;
     }
 
     public String getOutIdentifier() {
-        return this.outIdentifier;
+    	return this.outIdentifier;
     }
 
     public void setOutIdentifier(String outIdentifier) {
-        this.outIdentifier = outIdentifier;
-        this.out = true;
+    	this.outIdentifier = outIdentifier;
+    	this.out = true;
     }
 
+    public String getIdentifier() {
+    	return this.identifier;
+    }
+
+    public void setIdentifier(String identifier) {
+    	this.identifier = identifier;
+    }
+
     public boolean isOut() {
-        return this.out;
+    	if (out == null) {
+    		return false;
+    	} else {
+    		return out;
+    	}
     }
 
-    public void setOut(boolean out) {
-        this.out = out;
+    public void setOut(Boolean out) {
+    	this.out = out;
     }
 
     public String toString() {
-        return "session.setGlobal(" + this.identifier + ", " + this.object + ");";
+    	return "session.setGlobal(" + this.identifier + ", " + this.object + ");";
     }
 
 }

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -44,6 +44,10 @@
     public Object getObject() {
         return this.object;
     }
+    
+    public void setObject( Object object ) {
+        this.object = object;
+    }
 
     public String getOutIdentifier() {
         return this.outIdentifier;

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/QueryCommand.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/QueryCommand.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/command/runtime/rule/QueryCommand.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -1,27 +1,42 @@
 package org.drools.command.runtime.rule;
 
-import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
 import org.drools.command.Context;
 import org.drools.command.impl.GenericCommand;
 import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.impl.StatefulKnowledgeSessionImpl;
-import org.drools.reteoo.ReteooWorkingMemory;
-import org.drools.runtime.ExecutionResults;
+import org.drools.result.ExecutionResults;
+import org.drools.result.QueryResult;
 import org.drools.runtime.StatefulKnowledgeSession;
-import org.drools.runtime.rule.FactHandle;
 import org.drools.runtime.rule.QueryResults;
-import org.drools.runtime.rule.impl.NativeQueryResults;
 
+ at XmlAccessorType( XmlAccessType.NONE )
 public class QueryCommand  implements GenericCommand<QueryResults> {
+
+	private static final long serialVersionUID = 1L;
+	
+	@XmlAttribute(name = "out-identifier")
     private String outIdentifier;
+    @XmlAttribute(required = true)
     private String name;
-    private Object[] arguments;
+    @XmlElement(name="argument")
+    private List<Object> arguments;
+
+    public QueryCommand() {
+    }
     
     public QueryCommand(String outIdentifier, String name, Object[] arguments) {
         this.outIdentifier = outIdentifier;
         this.name = name;
-        this.arguments = arguments;
+        this.arguments = arguments != null ? Arrays.asList( arguments ) : Arrays.asList();
     }
     
     public String getOutIdentifier() {
@@ -38,10 +53,13 @@
     public void setName(String name) {
         this.name = name;
     }
-    public Object[] getArguments() {
-        return arguments;
+    public List<Object> getArguments() {
+        if (this.arguments == null) {
+            this.arguments = new ArrayList<Object>();
+        }
+        return this.arguments;
     }
-    public void setArguments(Object[] arguments) {
+    public void setArguments(List<Object> arguments) {
         this.arguments = arguments;
     }
 
@@ -50,14 +68,17 @@
         
         QueryResults results = null;
         
-        if ( arguments == null || arguments.length == 0 ) {
+        if ( this.arguments == null || this.arguments.size() == 0 ) {
             results = ksession.getQueryResults( name );
         } else {
-            results = ksession.getQueryResults( name, this.arguments );
+            results = ksession.getQueryResults( name, this.arguments.toArray() );
         }
         
         if ( this.outIdentifier != null ) {
-            ((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put( this.outIdentifier, results );
+            ExecutionResults execRes =
+                (ExecutionResults)((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
+            QueryResult queryRes = new QueryResult( outIdentifier, results );
+            execRes.getResults().add( queryRes );
         }
 
         return results;

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ExecutionResultsType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ExecutionResultsType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ExecutionResultsType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,87 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ExecutionResultsType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="ExecutionResultsType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;choice maxOccurs="unbounded" minOccurs="0">
+ *         &lt;element name="query-results" type="{http://drools.org/process/result}QueryResultsType"/>
+ *         &lt;element name="insert-results" type="{http://drools.org/process/result}InsertResultsType"/>
+ *         &lt;element name="global-value" type="{http://drools.org/process/result}GlobalType"/>
+ *       &lt;/choice>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlRootElement( namespace = "http://drools.org/process/result", name = "execution-results" )
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "ExecutionResultsType", propOrder = {
+    "queryResultsOrInsertResultsOrGlobalValue"
+})
+public class ExecutionResultsType {
+
+    @XmlElements({
+        @XmlElement(name = "global-value", type = GlobalType.class),
+        @XmlElement(name = "insert-results", type = InsertResultsType.class),
+        @XmlElement(name = "query-results", type = QueryResultsType.class)
+    })
+    protected List<Object> queryResultsOrInsertResultsOrGlobalValue;
+
+    /**
+     * Gets the value of the queryResultsOrInsertResultsOrGlobalValue property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the queryResultsOrInsertResultsOrGlobalValue property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getQueryResultsOrInsertResultsOrGlobalValue().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link GlobalType }
+     * {@link InsertResultsType }
+     * {@link QueryResultsType }
+     * 
+     * 
+     */
+    public List<Object> getQueryResultsOrInsertResultsOrGlobalValue() {
+        if (queryResultsOrInsertResultsOrGlobalValue == null) {
+            queryResultsOrInsertResultsOrGlobalValue = new ArrayList<Object>();
+        }
+        return this.queryResultsOrInsertResultsOrGlobalValue;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ExecutionResultsType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactHandleListType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactHandleListType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactHandleListType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for FactHandleListType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="FactHandleListType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="fact-handle" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "FactHandleListType", propOrder = {
+    "factHandle"
+})
+public class FactHandleListType {
+
+    @XmlElement(name = "fact-handle", required = true)
+    protected List<String> factHandle;
+
+    /**
+     * Gets the value of the factHandle property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the factHandle property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getFactHandle().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link String }
+     * 
+     * 
+     */
+    public List<String> getFactHandle() {
+        if (factHandle == null) {
+            factHandle = new ArrayList<String>();
+        }
+        return this.factHandle;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactHandleListType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactObjectListType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactObjectListType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactObjectListType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,77 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for FactObjectListType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="FactObjectListType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;any/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "FactObjectListType", propOrder = {
+    "any"
+})
+public class FactObjectListType {
+
+    @XmlAnyElement
+    protected List<Element> any;
+
+    /**
+     * Gets the value of the any property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the any property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getAny().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link Element }
+     * 
+     * 
+     */
+    public List<Element> getAny() {
+        if (any == null) {
+            any = new ArrayList<Element>();
+        }
+        return this.any;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/FactObjectListType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/GlobalType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/GlobalType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/GlobalType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,98 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for GlobalType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="GlobalType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;any/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="identifier" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "GlobalType", propOrder = {
+    "any"
+})
+public class GlobalType {
+
+    @XmlAnyElement
+    protected Element any;
+    @XmlAttribute
+    protected String identifier;
+
+    /**
+     * Gets the value of the any property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link Element }
+     *     
+     */
+    public Element getAny() {
+        return any;
+    }
+
+    /**
+     * Sets the value of the any property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link Element }
+     *     
+     */
+    public void setAny(Element value) {
+        this.any = value;
+    }
+
+    /**
+     * Gets the value of the identifier property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    /**
+     * Sets the value of the identifier property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setIdentifier(String value) {
+        this.identifier = value;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/GlobalType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/InsertResultsType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/InsertResultsType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/InsertResultsType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,124 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for InsertResultsType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="InsertResultsType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="fact-handles" type="{http://drools.org/process/result}FactHandleListType"/>
+ *         &lt;element name="fact-objects" type="{http://drools.org/process/result}FactObjectListType" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="identifier" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "InsertResultsType", propOrder = {
+    "factHandles",
+    "factObjects"
+})
+public class InsertResultsType {
+
+    @XmlElement(name = "fact-handles", required = true)
+    protected FactHandleListType factHandles;
+    @XmlElement(name = "fact-objects")
+    protected FactObjectListType factObjects;
+    @XmlAttribute
+    protected String identifier;
+
+    /**
+     * Gets the value of the factHandles property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link FactHandleListType }
+     *     
+     */
+    public FactHandleListType getFactHandles() {
+        return factHandles;
+    }
+
+    /**
+     * Sets the value of the factHandles property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link FactHandleListType }
+     *     
+     */
+    public void setFactHandles(FactHandleListType value) {
+        this.factHandles = value;
+    }
+
+    /**
+     * Gets the value of the factObjects property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link FactObjectListType }
+     *     
+     */
+    public FactObjectListType getFactObjects() {
+        return factObjects;
+    }
+
+    /**
+     * Sets the value of the factObjects property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link FactObjectListType }
+     *     
+     */
+    public void setFactObjects(FactObjectListType value) {
+        this.factObjects = value;
+    }
+
+    /**
+     * Gets the value of the identifier property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    /**
+     * Sets the value of the identifier property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setIdentifier(String value) {
+        this.identifier = value;
+    }
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/InsertResultsType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ObjectFactory.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ObjectFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ObjectFactory.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,116 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each 
+ * Java content interface and Java element interface 
+ * generated in the org.drools.process.result package. 
+ * <p>An ObjectFactory allows you to programatically 
+ * construct new instances of the Java representation 
+ * for XML content. The Java representation of XML 
+ * content can consist of schema derived interfaces 
+ * and classes representing the binding of schema 
+ * type definitions, element declarations and model 
+ * groups.  Factory methods for each of these are 
+ * provided in this class.
+ * 
+ */
+ at XmlRegistry
+public class ObjectFactory {
+
+    private final static QName _ExecutionResults_QNAME = new QName("http://drools.org/process/result", "execution-results");
+
+    /**
+     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.drools.process.result
+     * 
+     */
+    public ObjectFactory() {
+    }
+
+    /**
+     * Create an instance of {@link FactObjectListType }
+     * 
+     */
+    public FactObjectListType createFactObjectListType() {
+        return new FactObjectListType();
+    }
+
+    /**
+     * Create an instance of {@link QueryRowType }
+     * 
+     */
+    public QueryRowType createQueryRowType() {
+        return new QueryRowType();
+    }
+
+    /**
+     * Create an instance of {@link ExecutionResultsType }
+     * 
+     */
+    public ExecutionResultsType createExecutionResultsType() {
+        return new ExecutionResultsType();
+    }
+
+    /**
+     * Create an instance of {@link FactHandleListType }
+     * 
+     */
+    public FactHandleListType createFactHandleListType() {
+        return new FactHandleListType();
+    }
+
+    /**
+     * Create an instance of {@link QueryFieldType }
+     * 
+     */
+    public QueryFieldType createQueryFieldType() {
+        return new QueryFieldType();
+    }
+
+    /**
+     * Create an instance of {@link InsertResultsType }
+     * 
+     */
+    public InsertResultsType createInsertResultsType() {
+        return new InsertResultsType();
+    }
+
+    /**
+     * Create an instance of {@link QueryResultsType }
+     * 
+     */
+    public QueryResultsType createQueryResultsType() {
+        return new QueryResultsType();
+    }
+
+    /**
+     * Create an instance of {@link GlobalType }
+     * 
+     */
+    public GlobalType createGlobalType() {
+        return new GlobalType();
+    }
+
+    /**
+     * Create an instance of {@link JAXBElement }{@code <}{@link ExecutionResultsType }{@code >}}
+     * 
+     */
+    @XmlElementDecl(namespace = "http://drools.org/process/result", name = "execution-results")
+    public JAXBElement<ExecutionResultsType> createExecutionResults(ExecutionResultsType value) {
+        return new JAXBElement<ExecutionResultsType>(_ExecutionResults_QNAME, ExecutionResultsType.class, null, value);
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/ObjectFactory.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryFieldType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryFieldType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryFieldType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,128 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for QueryFieldType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="QueryFieldType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;choice>
+ *           &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *           &lt;any/>
+ *         &lt;/choice>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "QueryFieldType", propOrder = {
+    "name",
+    "value",
+    "any"
+})
+public class QueryFieldType {
+
+    @XmlElement(required = true)
+    protected String name;
+    protected String value;
+    @XmlAnyElement
+    protected Element any;
+
+    /**
+     * Gets the value of the name property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the value of the name property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setName(String value) {
+        this.name = value;
+    }
+
+    /**
+     * Gets the value of the value property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * Sets the value of the value property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets the value of the any property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link Element }
+     *     
+     */
+    public Element getAny() {
+        return any;
+    }
+
+    /**
+     * Sets the value of the any property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link Element }
+     *     
+     */
+    public void setAny(Element value) {
+        this.any = value;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryFieldType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryResultsType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryResultsType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryResultsType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,122 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for QueryResultsType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="QueryResultsType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="row" type="{http://drools.org/process/result}QueryRowType" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="identifier" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="size" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "QueryResultsType", propOrder = {
+    "row"
+})
+public class QueryResultsType {
+
+    protected List<QueryRowType> row;
+    @XmlAttribute(required = true)
+    protected String identifier;
+    @XmlAttribute(required = true)
+    protected int size;
+
+    /**
+     * Gets the value of the row property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the row property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getRow().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link QueryRowType }
+     * 
+     * 
+     */
+    public List<QueryRowType> getRow() {
+        if (row == null) {
+            row = new ArrayList<QueryRowType>();
+        }
+        return this.row;
+    }
+
+    /**
+     * Gets the value of the identifier property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    /**
+     * Sets the value of the identifier property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setIdentifier(String value) {
+        this.identifier = value;
+    }
+
+    /**
+     * Gets the value of the size property.
+     * 
+     */
+    public int getSize() {
+        return size;
+    }
+
+    /**
+     * Sets the value of the size property.
+     * 
+     */
+    public void setSize(int value) {
+        this.size = value;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryResultsType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryRowType.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryRowType.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryRowType.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,74 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+
+package org.drools.process.result;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for QueryRowType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="QueryRowType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="field" type="{http://drools.org/process/result}QueryFieldType" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "QueryRowType", propOrder = {
+    "field"
+})
+public class QueryRowType {
+
+    protected List<QueryFieldType> field;
+
+    /**
+     * Gets the value of the field property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the field property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getField().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link QueryFieldType }
+     * 
+     * 
+     */
+    public List<QueryFieldType> getField() {
+        if (field == null) {
+            field = new ArrayList<QueryFieldType>();
+        }
+        return this.field;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/QueryRowType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/package-info.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/package-info.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/package-info.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,9 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.16 at 08:23:06 AM CEST 
+//
+
+ at javax.xml.bind.annotation.XmlSchema(namespace = "http://drools.org/process/result")
+package org.drools.process.result;


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/process/result/package-info.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/AbstractResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/AbstractResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/AbstractResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,19 @@
+package org.drools.result;
+
+public abstract class AbstractResult {
+
+    private String identifier;
+
+    public AbstractResult( String identifier ){
+        this.identifier = identifier;
+    }
+
+    public String getIdentifier(){
+        return identifier;
+    }
+
+    public Object getFactHandle(){
+	return null;
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/AbstractResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResults.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResults.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResults.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,15 @@
+package org.drools.result;
+
+import java.util.List;
+
+public interface ExecutionResults {
+
+    List<GenericResult> getResults();
+
+    Object getValue( String identifier );
+
+    Object getFactHandle( String identifier );
+
+    List<String> getIdentifiers();
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResults.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResultsImpl.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResultsImpl.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResultsImpl.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,76 @@
+package org.drools.result;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExecutionResultsImpl implements ExecutionResults {
+
+    private List<GenericResult> results;
+
+    public ExecutionResultsImpl(){
+    }
+
+    public List<GenericResult> getResults(){
+	if( results == null ){
+	    results = new ArrayList<GenericResult>();
+	}
+        return results;
+    }
+
+    public Object getValue( String identifier ){
+        for( GenericResult genRes: getResults() ){
+	    if( identifier.equals( genRes.getIdentifier() ) ){
+                return genRes.getValue();
+	    }
+	}
+        return null;
+    }
+
+    public Object getFactHandle( String identifier ){
+        for( GenericResult genRes: getResults() ){
+	    if( identifier.equals( genRes.getIdentifier() ) ){
+                return genRes.getFactHandle();
+	    }
+	}
+        return null;
+    }
+
+    public List<String> getIdentifiers(){
+	List<String> idList = new ArrayList<String>();
+        for( GenericResult genRes: getResults() ){
+	    String id = genRes.getIdentifier();
+            if( id != null ){
+                idList.add( id );
+	    }
+	}
+        return idList;
+    }
+    
+    public Map<String,Object> getResultsAsMap(){
+    	Map<String,Object> resmap = new HashMap<String,Object>();
+    	for( GenericResult genres: results ){
+    		String key = genres.getIdentifier();
+    		Object val = genres.getValue();
+    		if( key != null && val != null ){
+    			resmap.put( key, val );
+    		}
+    	}
+    	return resmap;
+    }
+
+    public Map<String,Object> getFactHandlesAsMap(){
+    	Map<String,Object> hanmap = new HashMap<String,Object>();
+    	for( GenericResult genres: results ){
+    		String key = genres.getIdentifier();
+    		Object val = genres.getFactHandle();
+    		if( key != null && val != null ){
+    			hanmap.put( key, val );
+    		}
+    	}
+    	return hanmap;
+    }
+
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/ExecutionResultsImpl.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GenericResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GenericResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GenericResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,10 @@
+package org.drools.result;
+
+public interface GenericResult {
+
+    String getIdentifier();
+
+    Object getValue();
+
+    Object getFactHandle();
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GenericResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetGlobalResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetGlobalResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetGlobalResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,15 @@
+package org.drools.result;
+
+public class GetGlobalResult extends AbstractResult implements GenericResult {
+
+    private Object object;
+
+    public GetGlobalResult( String identifier, Object object ){
+        super( identifier );
+        this.object = object;
+    }
+
+    public Object getValue(){
+	return object;
+    }
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetGlobalResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetObjectsResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetObjectsResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetObjectsResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,29 @@
+package org.drools.result;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GetObjectsResult extends AbstractResult implements GenericResult {
+
+    private List<Object> objects;
+
+    public GetObjectsResult( String identifier, Object object ){
+        super( identifier );
+        this.objects = new ArrayList<Object>();
+        this.objects.add( object );
+    }
+
+    public GetObjectsResult( String identifier, List<Object> objects ){
+        super( identifier );
+        this.objects = objects;
+    }
+
+    public List<Object> getObjects(){
+        return objects;
+    }
+
+    public Object getValue(){
+	return objects;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/GetObjectsResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertElementsResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertElementsResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertElementsResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,39 @@
+package org.drools.result;
+
+import java.util.List;
+
+import org.drools.runtime.rule.FactHandle;
+
+public class InsertElementsResult extends AbstractResult implements GenericResult {
+
+    private List<FactHandle> handles;
+    private List<Object>     objects;
+
+    public InsertElementsResult( String identifier ){
+        super( identifier );
+    }
+
+    public List<FactHandle> getHandles(){
+        return handles;
+    }
+
+    public void setHandles( List<FactHandle> handles ){
+	this.handles = handles;
+    }
+
+    public List<Object> getObjects(){
+        return objects;
+    }
+
+    public void setObjects( List<Object> objects ){
+	this.objects = objects;
+    }
+
+    public Object getValue(){
+        return this.objects;
+    }
+
+    public Object getFactHandle(){
+        return this.handles;
+    }
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertElementsResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertObjectResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertObjectResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertObjectResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,26 @@
+package org.drools.result;
+
+import org.drools.runtime.rule.FactHandle;
+
+public class InsertObjectResult extends AbstractResult implements GenericResult {
+
+    private FactHandle handle;
+    private Object     object;
+
+    public InsertObjectResult( String identifier, FactHandle handle ){
+        super( identifier );
+        this.handle = handle;
+    }
+
+    public void setObject( Object object ){
+	this.object = object;
+    }
+
+    public Object getValue(){
+        return this.object;
+    }
+
+    public Object getFactHandle(){
+        return this.handle;
+    }
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/InsertObjectResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/QueryResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/QueryResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/QueryResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,21 @@
+package org.drools.result;
+
+import org.drools.runtime.rule.QueryResults;
+
+public class QueryResult extends AbstractResult implements GenericResult {
+
+    private QueryResults results;
+
+    public QueryResult( String identifier, QueryResults results ){
+        super( identifier );
+        this.results = results;
+    }
+
+    public QueryResults getResults(){
+        return this.results;
+    }
+
+    public Object getValue(){
+	return this.results;
+    }
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/QueryResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/SetGlobalResult.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/SetGlobalResult.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/SetGlobalResult.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,10 @@
+package org.drools.result;
+
+
+public class SetGlobalResult extends GetGlobalResult {
+
+    public SetGlobalResult( String outIdentifier, Object object ){
+        super( outIdentifier, object );
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-core/src/main/java/org/drools/result/SetGlobalResult.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/java/org/drools/camel/component/DroolsJaxbDataFormat.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/java/org/drools/camel/component/DroolsJaxbDataFormat.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/java/org/drools/camel/component/DroolsJaxbDataFormat.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,121 @@
+package org.drools.camel.component;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.DataFormat;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.impl.StatelessKnowledgeSessionImpl;
+import org.drools.io.Resource;
+import org.drools.reteoo.ReteooRuleBase;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.impl.ServiceManagerPipelineContextImpl;
+import org.drools.vsm.ServiceManager;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * 
+ * @author Lucas Amador
+ * 
+ */
+public class DroolsJaxbDataFormat implements DataFormat {
+
+//	private JaxbFromXmlVsmTransformer transformer;
+	private Unmarshaller unmarshaller;
+    private String charset;
+
+    public DroolsJaxbDataFormat() {
+//    	this.transformer = new JaxbFromXmlVsmTransformer(null);
+    }
+
+    public void marshal(Exchange exchange, Object graph, OutputStream stream)
+            throws Exception {
+
+        PipelineContext context = (PipelineContext) exchange.getProperty("drools-context");
+        JAXBContext jaxbContext = (JAXBContext) context.getProperties().get("jaxb-context");
+        this.unmarshaller = getUnmarshaller(jaxbContext);
+
+        String result = null;
+        Object body = exchange.getIn().getBody();
+
+        if ( body instanceof File ) {
+        	result = (String) this.unmarshaller.unmarshal( (File) body );
+        } else if ( body instanceof InputStream ) {
+        	result = (String) this.unmarshaller.unmarshal( (InputStream) body );
+        } else if ( body instanceof Reader ) {
+        	result = (String) this.unmarshaller.unmarshal( (Reader) body );
+        } else if ( body instanceof Source ) {
+        	result = (String) this.unmarshaller.unmarshal( (Source) body );
+        } else if ( body instanceof InputSource ) {
+        	result = (String) this.unmarshaller.unmarshal( (InputSource) body );
+        }  else if ( body instanceof Resource ) {
+        	result = (String) this.unmarshaller.unmarshal( (( Resource ) body).getReader() );
+        }  else if ( body instanceof String ) {
+        	result = (String) this.unmarshaller.unmarshal( new StringReader( ( String ) body ) );
+        } else {
+            throw new IllegalArgumentException( "exchange input body object must be instance of File, InputStream, Reader, Source, InputSource, Resource, String" );
+        }
+
+        byte[] bytes;
+        if (charset != null) {
+            bytes = result.getBytes(charset);
+        } else {
+            bytes = result.getBytes();
+        }
+
+        stream.write(bytes);
+
+    }
+
+    private Unmarshaller getUnmarshaller(JAXBContext jaxbCtx) throws JAXBException {
+    	if (this.unmarshaller==null) {
+    		this.unmarshaller = jaxbCtx.createUnmarshaller();
+    	}
+		return this.unmarshaller;
+	}
+
+	public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+
+        PipelineContext context = (PipelineContext) exchange.getProperty("drools-context");
+        Document d = exchange.getIn().getBody(Document.class);
+        String name = d.getDocumentElement().getAttribute("lookup");
+        JAXBContext jaxbContext = (JAXBContext) context.getProperties().get("jaxb-context");
+        this.unmarshaller = getUnmarshaller(jaxbContext);
+        ServiceManagerPipelineContextImpl vsmContext = 
+            (ServiceManagerPipelineContextImpl) exchange.getProperty("drools-context");
+        ServiceManager sm = vsmContext.getServiceManager();
+        CommandExecutor executor = sm.lookup(name);
+        if (executor == null) {
+            throw new IllegalArgumentException("Unable to lookup CommandExecutor using name '" + name + "'");
+        }
+        vsmContext.setCommandExecutor(executor);
+        ClassLoader cl = null;
+        if (executor instanceof StatefulKnowledgeSessionImpl) {
+            cl = ((ReteooRuleBase) ((StatefulKnowledgeSessionImpl) executor).getRuleBase()).getRootClassLoader();
+//            xstream.setClassLoader(cl);
+        } else if (executor instanceof StatelessKnowledgeSessionImpl) {
+            cl = ((ReteooRuleBase) ((StatelessKnowledgeSessionImpl) executor).getRuleBase()).getRootClassLoader();
+        } else {
+            throw new IllegalArgumentException("Unable to set ClassLoader on " + executor);
+        }
+//        xstream.setClassLoader(cl);
+        vsmContext.setClassLoader(cl);
+        Object payload = null;
+//      this.unmarshaller.unmarshal(new DomReader(d));
+//      context.getProperties().put("xstream-instance", xstream);
+        exchange.setProperty("drools-context", context);
+		return payload;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/java/org/drools/camel/component/DroolsJaxbDataFormat.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/resources/META-INF/services/org/apache/camel/dataformat/drools-jaxb
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/resources/META-INF/services/org/apache/camel/dataformat/drools-jaxb	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/resources/META-INF/services/org/apache/camel/dataformat/drools-jaxb	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+class=org.drools.camel.component.DroolsJaxbDataFormat
+


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/main/resources/META-INF/services/org/apache/camel/dataformat/drools-jaxb
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,136 @@
+package org.drools.camel.component;
+
+import java.io.IOException;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.drools.KnowledgeBase;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.ResourceType;
+import org.drools.builder.help.KnowledgeBuilderHelper;
+import org.drools.command.runtime.rule.InsertObjectCommand;
+import org.drools.common.InternalFactHandle;
+import org.drools.io.ResourceFactory;
+import org.drools.pipeline.camel.Person;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.help.BatchExecutionHelper;
+import org.drools.runtime.pipeline.PipelineFactory;
+import org.drools.runtime.pipeline.Transformer;
+import org.drools.runtime.rule.FactHandle;
+
+import com.sun.tools.xjc.Language;
+import com.sun.tools.xjc.Options;
+/**
+ * 
+ * @author Lucas Amador
+ *
+ */
+public class CamelEndpointWithJaxbTest extends DroolsCamelTestSupport {
+	
+    private String handle;
+
+    public void testSessionInsert() throws Exception {
+
+        String cmd = "" +
+            "<batch-execution lookup=\"ksession1\">\n" +
+                "<insert out-identifier=\"salaboy\">\n" +
+                    "<org.drools.pipeline.camel.Person>\n" +
+                        "<name>salaboy</name>\n" +
+                    "</org.drools.pipeline.camel.Person>\n" +
+                "</insert>\n" +
+                "<fire-all-rules/>\n" +
+            "</batch-execution>\n";
+
+        String outXml = new String((byte[])template.requestBody("direct:test-with-session", cmd));
+
+        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML(outXml);
+        Person person = (Person) result.getValue("salaboy");
+        assertEquals("salaboy", person.getName());
+
+        String expectedXml = "<execution-results>\n";
+        expectedXml += "  <result identifier=\"salaboy\">\n";
+        expectedXml += "    <org.drools.pipeline.camel.Person>\n";
+        expectedXml += "      <name>salaboy</name>\n";
+        expectedXml += "    </org.drools.pipeline.camel.Person>\n";
+        expectedXml += "  </result>\n";
+        expectedXml += "  <fact-handle identifier=\"salaboy\" externalForm=\"" + ((InternalFactHandle) result.getFactHandle("salaboy")).toExternalForm() + "\"/>\n";
+        expectedXml += "</execution-results>";
+
+        assertEquals(expectedXml, outXml);
+
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:test-with-session").to("drools:sm/ksession1?dataFormat=drools-jaxb");
+                from("direct:test-no-session").to("drools:sm?dataFormat=drools-jaxb");
+            }
+        };
+    }
+
+    @Override
+    protected void configureDroolsContext() {
+        Person me = new Person();
+        me.setName("Hadrian");
+
+        StatefulKnowledgeSession ksession = registerKnowledgeRuntime("ksession1", null);
+        InsertObjectCommand cmd = new InsertObjectCommand(me);
+        cmd.setOutIdentifier("camel-rider");
+        cmd.setReturnObject(false);
+        ExecutionResults results = ksession.execute(cmd);
+        handle = ((FactHandle)results.getFactHandle("camel-rider")).toExternalForm();
+    }
+    
+    @Override
+    protected StatefulKnowledgeSession registerKnowledgeRuntime(String identifier, String rule) {
+    	KnowledgeBuilder kbuilder = serviceManager.getKnowledgeBuilderFactory().newKnowledgeBuilder();
+    	
+    	Options xjcOpts = new Options();
+        xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
+
+        String[] classNames = null;
+        try {
+			classNames = KnowledgeBuilderHelper.addXsdModel( ResourceFactory.newClassPathResource("person.xsd", getClass()),
+			                                                          kbuilder,
+			                                                          xjcOpts,
+			                                                          "xsd" );
+		} catch (IOException e) {
+			LOG.error("Errors while adding xsd model. ", kbuilder.getErrors());
+		}
+
+        assertFalse( kbuilder.hasErrors() );
+        
+        if (rule != null && rule.length() > 0) {
+            kbuilder.add(ResourceFactory.newByteArrayResource(rule.getBytes()), ResourceType.DRL);
+    
+            if (kbuilder.hasErrors()) {
+                LOG.info("Errors while adding rule. ", kbuilder.getErrors());
+            }
+        }
+
+    	assertFalse(kbuilder.hasErrors());
+    	
+    	
+    	KnowledgeBase kbase = serviceManager.getKnowledgeBaseFactory().newKnowledgeBase();
+		kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
+		
+		JAXBContext jaxbContext = null;
+		try {
+			jaxbContext = KnowledgeBuilderHelper.newJAXBContext( classNames, kbase );
+		} catch (JAXBException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		// put this jaxbContext into the camel-context
+    	
+    	StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
+    	serviceManager.register(identifier, session);
+    	return session;
+    }
+    
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xml
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xml	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xml	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<person xmlns="http://drools.org/model/person" >
+    <name>lucaz</name>
+    <age>25</age>
+</person>
\ No newline at end of file


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xsd
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xsd	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xsd	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,15 @@
+<xsd:schema xmlns:person="http://drools.org/model/person" 
+            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	        targetNamespace="http://drools.org/model/person"
+	        elementFormDefault="qualified" >
+	        
+	<xsd:element name="person">
+		<xsd:complexType>
+			<xsd:sequence>
+				<xsd:element name="name" type="xsd:string" />
+				<xsd:element name="age" type="xsd:integer" />
+			</xsd:sequence>	
+		</xsd:complexType>
+	</xsd:element>
+
+</xsd:schema>
\ No newline at end of file


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-camel/src/test/resources/org/drools/camel/component/person.xsd
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/CommandTranslator.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/CommandTranslator.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/CommandTranslator.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,206 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.runtime.BatchExecutionCommand;
+import org.drools.command.runtime.SetGlobalCommand;
+import org.drools.command.runtime.process.SignalEventCommand;
+import org.drools.command.runtime.process.StartProcessCommand;
+import org.drools.command.runtime.rule.InsertElementsCommand;
+import org.drools.command.runtime.rule.InsertObjectCommand;
+import org.drools.command.runtime.rule.QueryCommand;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * @author Wolfgang Laun
+ */
+public class CommandTranslator {
+    private JaxbTransformer jaxbTransformer;
+    private Map<Class<?>,CommandTransformer> class2trans;
+    
+    /**
+     * Constructor
+     *  
+     */
+    public CommandTranslator( JaxbTransformer jaxbTransformer ){
+        class2trans = new HashMap<Class<?>,CommandTransformer>();
+        class2trans.put( BatchExecutionCommand.class,   new BatchExecutionTransformer() );
+        class2trans.put( InsertElementsCommand.class,   new InsertElementsTransformer() );
+        class2trans.put( InsertObjectCommand.class,     new InsertObjectTransformer() );
+        class2trans.put( QueryCommand.class,            new QueryTransformer() );
+        class2trans.put( SetGlobalCommand.class,        new SetGlobalTransformer() );
+        class2trans.put( SignalEventCommand.class,      new SignalEventTransformer() );
+        class2trans.put( StartProcessCommand.class,     new StartProcessTransformer() );
+        this.jaxbTransformer = jaxbTransformer;
+    }
+    
+    /**
+     * Transforms a list of XML elements representing Drools command objects
+     * to a list of <tt>Command&lt;?&gt;</tt> objects. Application objects
+     * are unmarshalled, using an <tt>Unmarshaller</tt> object derived from
+     * the object's class.
+     * 
+     * @param xmlCmds the list of XML elements representing Drools command objects
+     * @return a list of <tt>Command&lt;?&gt;</tt> objects
+     */
+    public void transform( BatchExecutionCommand batchExecution ){
+        CommandTransformer ct = class2trans.get( batchExecution.getClass() );
+        ct.transform( this, batchExecution );
+    }
+
+    CommandTransformer getCommandTransformer( Class<?> clazz ){
+        return class2trans.get( clazz );
+    }
+        
+    protected Object makeObject( Element element ){        
+        Object obj = null;
+        try {
+            JAXBContext ctxt = jaxbTransformer.getContext();
+            Unmarshaller um = ctxt.createUnmarshaller();
+            obj = um.unmarshal( element );
+        } catch (JAXBException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return obj;
+    }
+}
+
+
+/**
+ * Abstract base class for all command transformers.
+ */
+abstract class CommandTransformer {
+    abstract GenericCommand<?> transform( CommandTranslator ct, Object o );
+}
+
+/**
+ * Class for transforming a BatchExecution command.
+ */
+class BatchExecutionTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator cmdTrans, Object o ){
+        BatchExecutionCommand be = (BatchExecutionCommand)o;
+        List<GenericCommand<?>> xmlCmds = be.getCommands();
+        for( int i = 0; i < xmlCmds.size(); i++ ){
+            GenericCommand<?> cmd = xmlCmds.get( i );
+            CommandTransformer ct = cmdTrans.getCommandTransformer( cmd.getClass() );
+            if( ct != null ){
+                xmlCmds.set( i, ct.transform( cmdTrans, cmd ) );
+            }
+        }
+        return be;
+    }
+}
+
+
+
+
+/**
+ * Class for transforming an InsertElements command.
+ */
+class InsertElementsTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator ct, Object o ){
+        InsertElementsCommand ie = (InsertElementsCommand)o;
+        Iterable<?> ioList = ie.getObjects();        
+        List<Object> coList = new ArrayList<Object>();
+        for( Object io: ioList ){
+            System.out.println( io.getClass() );
+            Element el = (Element)io;
+            Object co = ct.makeObject( el );
+            coList.add( co );
+        }
+        System.out.println( "insert " + coList.size() + " elements" );
+        ie.setObjects( coList );
+        return ie;
+    }
+}
+
+/**
+ * Class for transforming a InsertObject command.
+ */
+class InsertObjectTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator ct, Object o ){
+        InsertObjectCommand io = (InsertObjectCommand)o;
+        Element el = (Element)io.getObject();
+        Object obj = ct.makeObject( el );
+        io.setObject( obj );
+        return io;
+    }
+}
+
+/**
+ * Class for transforming a Query command.
+ */
+class QueryTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator ct, Object o ){
+        QueryCommand q = (QueryCommand)o;
+        List<Object> argList = q.getArguments();
+        for( int i = 0; i < argList.size(); i++ ){
+            Element el = (Element)argList.get( i );
+            Object ao = ct.makeObject( el );
+            argList.add( i, ao );
+        }
+        return q;
+    }
+}
+
+/**
+ * Class for transforming a SetGlobal command.
+ */
+class SetGlobalTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator ct, Object o ){
+        SetGlobalCommand sg = (SetGlobalCommand)o;
+        Element el = (Element)sg.getObject();
+        Object obj = ct.makeObject( el );
+        sg.setObject( obj );
+        return sg;
+    }
+}
+
+/**
+ * Class for transforming a SignalEvent command.
+ */
+class SignalEventTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator ct, Object o ){
+        SignalEventCommand se = (SignalEventCommand)o;
+        Object ev = se.getEvent();
+        if( ev != null ){
+            Object obj = ct.makeObject( (Element)ev );
+            se.setEvent( obj );
+        }
+        return se;
+    }
+}
+
+/**
+ * Class for transforming a StartProcess command.
+ */
+class StartProcessTransformer extends CommandTransformer {
+    public GenericCommand<?> transform( CommandTranslator ct, Object o ){
+        StartProcessCommand sp = (StartProcessCommand)o;
+        // data items
+        List<Object> diList = sp.getData();
+        for( int i = 0; i < diList.size(); i++ ){
+            Element el = (Element)diList.get( i );
+            Object obj = ct.makeObject( el );
+            diList.add( i, obj );
+        }
+        // parameters
+        Map<String,Object> parMap = sp.getParameters();;
+        for( Map.Entry<String, Object> entry: parMap.entrySet() ){
+            Element el = (Element)entry.getValue();
+            Object obj = ct.makeObject( el );
+            entry.setValue( obj );
+        }
+        return sp;
+    }
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/CommandTranslator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlTransformer.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlTransformer.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlTransformer.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -1,63 +1,82 @@
-package org.drools.runtime.pipeline.impl;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.Source;
-
-import org.drools.io.Resource;
-import org.drools.runtime.pipeline.PipelineContext;
-import org.drools.runtime.pipeline.Transformer;
-import org.drools.runtime.pipeline.impl.BaseEmitter;
-import org.drools.runtime.pipeline.impl.BaseStage;
-import org.xml.sax.InputSource;
-
-public class JaxbFromXmlTransformer extends BaseEmitter
-    implements
-    Transformer {
-    private Unmarshaller            unmarshaller;
-
-    public JaxbFromXmlTransformer(Unmarshaller unmarshaller) {
-        this.unmarshaller = unmarshaller;
-    }
-
-    public void receive(Object object,
-                       PipelineContext context) {
-        Object result = null;
-        try {
-            if ( object instanceof File ) {
-                result = this.unmarshaller.unmarshal( (File) object );
-            } else if ( object instanceof InputStream ) {
-                result = this.unmarshaller.unmarshal( (InputStream) object );
-            } else if ( object instanceof Reader ) {
-                result = this.unmarshaller.unmarshal( (Reader) object );
-            } else if ( object instanceof Source ) {
-                result = this.unmarshaller.unmarshal( (Source) object );
-            } else if ( object instanceof InputSource ) {
-                result = this.unmarshaller.unmarshal( (InputSource) object );
-            }  else if ( object instanceof Resource ) {
-                result = this.unmarshaller.unmarshal( (( Resource ) object).getReader() );
-            }  else if ( object instanceof String ) {
-                result = this.unmarshaller.unmarshal( new StringReader( ( String ) object ) );
-            } else {
-                throw new IllegalArgumentException( "signal object must be instance of File, InputStream, Reader, Source, InputSource, Resource, String" );
-            }
-        } catch ( Exception e ) {
-            handleException( this,
-                             object,
-                             e );
-        }
-        
-        if ( result instanceof JAXBElement ) {
-            result = ((JAXBElement) object).getValue();
-        }
-        
-        emit( result,
-              context );
-    }
-
-}
+package org.drools.runtime.pipeline.impl;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+
+import org.drools.io.Resource;
+import org.drools.command.runtime.BatchExecutionCommand;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.Transformer;
+
+import org.xml.sax.InputSource;
+
+public class JaxbFromXmlTransformer extends JaxbTransformer
+    implements
+    Transformer {
+
+    private CommandTranslator cmdTrans;
+
+    public JaxbFromXmlTransformer(JAXBContext jaxbCtx) {
+        super( jaxbCtx );
+    }
+
+    public void receive(Object object, PipelineContext context) {
+    	Unmarshaller unmarshaller;
+    	try {
+    		JAXBContext jaxbContext = getPrimaryContext();
+    		unmarshaller = jaxbContext.createUnmarshaller();
+   !
  	} catch ( Exception e ) {
+    		handleException( this,
+    				object,
+    				e );
+    		return;
+    	}
+
+    	Object result = null;
+    	try {
+    		if ( object instanceof File ) {
+    			result = unmarshaller.unmarshal( (File) object );
+    		} else if ( object instanceof InputStream ) {
+    			result = unmarshaller.unmarshal( (InputStream) object );
+    		} else if ( object instanceof Reader ) {
+    			result = unmarshaller.unmarshal( (Reader) object );
+    		} else if ( object instanceof Source ) {
+    			result = unmarshaller.unmarshal( (Source) object );
+    		} else if ( object instanceof InputSource ) {
+    			result = unmarshaller.unmarshal( (InputSource) object );
+    		}  else if ( object instanceof Resource ) {
+    			result = unmarshaller.unmarshal( (( Resource ) object).getReader() );
+    		}  else if ( object instanceof String ) {
+    			result = unmarshaller.unmarshal( new StringReader( ( String ) object ) );
+    		} else {
+    			t!
 hrow new IllegalArgumentException( "signal object must be inst!
 ance of 
File, InputStream, Reader, Source, InputSource, Resource, String" );
+    		}
+    	} catch ( Exception e ) {
+    		handleException( this,
+    				object,
+    				e );
+    	}
+
+    	if ( result instanceof JAXBElement ) {
+    		result = ((JAXBElement<?>) result).getValue();
+    	}
+
+    	if( result instanceof BatchExecutionCommand ){
+    		if( cmdTrans == null ){
+    			cmdTrans = new CommandTranslator( this );
+    		}
+    		cmdTrans.transform( (BatchExecutionCommand)result );
+    	}
+
+    	emit( result,
+    			context );
+    }
+
+}
Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlVsmTransformer.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlVsmTransformer.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlVsmTransformer.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,110 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.Source;
+
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.impl.StatelessKnowledgeSessionImpl;
+import org.drools.io.Resource;
+import org.drools.reteoo.ReteooRuleBase;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.pipeline.PipelineContext;
+import org.drools.runtime.pipeline.Transformer;
+import org.drools.vsm.ServiceManager;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * 
+ * @author Lucas Amador
+ *
+ */
+public class JaxbFromXmlVsmTransformer extends BaseEmitter implements Transformer {
+	
+    private Unmarshaller unmarshaller;
+    private PipelineContext context;
+    private Object payload;
+
+    public JaxbFromXmlVsmTransformer(JAXBContext jaxbCtx) {
+        try {
+			this.unmarshaller = jaxbCtx.createUnmarshaller();
+		} catch (JAXBException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+    }
+
+    public void receive(Object object, PipelineContext context) {
+    	this.payload = processPayload(object, context);
+        emit( this.payload, context );
+    }
+    
+    public Object processPayload(Object object, PipelineContext context) {
+        
+        try {
+            Document d = (Document) object;
+            String name = d.getDocumentElement().getAttribute("lookup");
+            ServiceManagerPipelineContextImpl vsmContext = (ServiceManagerPipelineContextImpl) context;
+            ServiceManager sm = vsmContext.getServiceManager();
+            CommandExecutor executor = sm.lookup(name);
+            if (executor == null) {
+                throw new IllegalArgumentException("Unable to lookup CommandExecutor using name '" + name + "'");
+            }
+            vsmContext.setCommandExecutor(executor);
+            ClassLoader cl = null;
+            if (executor instanceof StatefulKnowledgeSessionImpl) {
+                cl = ((ReteooRuleBase) (( StatefulKnowledgeSessionImpl ) executor).getRuleBase()).getRootClassLoader();
+            } else if (executor instanceof StatelessKnowledgeSessionImpl) {
+                cl = ((ReteooRuleBase) (( StatelessKnowledgeSessionImpl ) executor).getRuleBase()).getRootClassLoader();
+            } else {
+                throw new IllegalArgumentException("Unable to set ClassLoader on " + executor);
+            }
+            vsmContext.setClassLoader(cl);
+            if ( object instanceof File ) {
+            	payload = this.unmarshaller.unmarshal( (File) object );
+            } else if ( object instanceof InputStream ) {
+            	payload = this.unmarshaller.unmarshal( (InputStream) object );
+            } else if ( object instanceof Reader ) {
+            	payload = this.unmarshaller.unmarshal( (Reader) object );
+            } else if ( object instanceof Source ) {
+            	payload = this.unmarshaller.unmarshal( (Source) object );
+            } else if ( object instanceof InputSource ) {
+            	payload = this.unmarshaller.unmarshal( (InputSource) object );
+            }  else if ( object instanceof Resource ) {
+            	payload = this.unmarshaller.unmarshal( (( Resource ) object).getReader() );
+            }  else if ( object instanceof String ) {
+            	payload = this.unmarshaller.unmarshal( new StringReader( ( String ) object ) );
+            } else {
+                throw new IllegalArgumentException( "signal object must be instance of File, InputStream, Reader, Source, InputSource, Resource, String" );
+            }
+            this.context = context;
+        } catch (Exception e) {
+            handleException(this, object, e);
+        }
+        return payload;
+    }
+
+    public Object getPayload() {
+        return payload;
+    }
+
+    public void setPayload(Object payload) {
+        this.payload = payload;
+    }
+
+    public PipelineContext getContext() {
+        return context;
+    }
+
+    public void setContext(PipelineContext context) {
+        this.context = context;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbFromXmlVsmTransformer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbToXmlTransformer.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbToXmlTransformer.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbToXmlTransformer.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -1,49 +1,52 @@
 package org.drools.runtime.pipeline.impl;
 
-import java.io.File;
-import java.io.InputStream;
-import java.io.Reader;
 import java.io.StringWriter;
 
-import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.Source;
 
-import org.drools.io.Resource;
-import org.drools.runtime.pipeline.JaxbTransformerProvider;
+import org.drools.result.ExecutionResults;
+import org.drools.process.result.ExecutionResultsType;
 import org.drools.runtime.pipeline.PipelineContext;
 import org.drools.runtime.pipeline.Transformer;
-import org.drools.runtime.pipeline.impl.BaseEmitter;
-import org.drools.runtime.pipeline.impl.BaseStage;
-import org.xml.sax.InputSource;
+import org.drools.runtime.pipeline.impl.ResultTranslator;
 
-public class JaxbToXmlTransformer extends BaseEmitter
-    implements
-    Transformer {
-    private Marshaller            marshaller;
 
-    public JaxbToXmlTransformer(Marshaller marshaller) {
-        this.marshaller = marshaller;
-    }
+public class JaxbToXmlTransformer extends JaxbTransformer implements Transformer {
 
-    public void receive(Object object,
-                       PipelineContext context) {
-        Object result = null;
-        try {
-            StringWriter stringWriter = new StringWriter();
-            
-            this.marshaller.marshal( object, stringWriter );
+	ResultTranslator resTrans;
 
-            result = stringWriter.getBuffer().toString();
-        } catch ( Exception e ) {
-            handleException( this,
-                             object,
-                             e );
-        }
-        
-        emit( result,
-              context );
-    }
+	public JaxbToXmlTransformer( JAXBContext jaxbCtx ) {
+		super( jaxbCtx );
+	}
 
+	public void receive(Object object, PipelineContext context) {
+
+		Object result = null;
+		JAXBContext jaxbCtxt = getPrimaryContext();
+		StringWriter stringWriter = new StringWriter();
+		try {
+			Marshaller marshaller = jaxbCtxt.createMarshaller();
+			marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true );
+
+			if( object instanceof ExecutionResults ){
+				if( resTrans == null ){
+					resTrans = new ResultTranslator( this );
+				}
+				ExecutionResultsType execRes = resTrans.transform( (ExecutionResults)object );
+				marshaller.marshal( execRes, stringWriter );
+			} else {
+				marshaller.marshal( object, stringWriter );
+			}
+		} catch ( Exception e ) {
+			handleException( this,
+					object,
+					e );
+		}
+    	result = stringWriter.getBuffer().toString();
+
+		emit( result,
+				context );
+	}
+
 }

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,78 @@
+package org.drools.runtime.pipeline.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.drools.process.result.ExecutionResultsType;
+import org.drools.runtime.pipeline.impl.BaseEmitter;
+
+/**
+ * @author: Wolfgang Laun
+ */
+public class JaxbTransformer extends BaseEmitter {
+
+    public final static String COMMAND_PACKAGES = "org.drools.command.runtime:" +
+											      "org.drools.command.runtime.process:" +
+											      "org.drools.command.runtime.rule";
+
+    public final static String RESULT_PACKAGE = "org.drools.process.result";
+
+    private Map<Object,JAXBContext> class2ctxt;
+
+    protected JAXBContext jaxbContext;
+    protected JAXBContext jaxbPrimaryContext;
+    
+    protected JaxbTransformer( JAXBContext jaxbCtx ){
+    	this.jaxbContext = jaxbCtx;
+    	this.jaxbPrimaryContext = jaxbCtx;
+        class2ctxt = new HashMap<Object,JAXBContext>();
+    }
+
+    public void addContextForCommands() {
+    	try {
+    		jaxbPrimaryContext = getContext( JaxbTransformer.COMMAND_PACKAGES );
+    	} catch ( Exception e ) {
+    		handleException( this, null, e );
+    		return;
+    	}
+    }
+
+    public void addContextForResults() {
+    	try {
+    		jaxbPrimaryContext = getContext( ExecutionResultsType.class );
+    	} catch ( Exception e ) {
+    		handleException( this, null, e );
+    		return;
+    	}
+    }
+
+    protected JAXBContext getContext(){
+    	return this.jaxbContext;
+    }
+    
+    protected JAXBContext getPrimaryContext(){
+    	return this.jaxbPrimaryContext;
+    }
+    
+    protected JAXBContext getContext( Class<?> clazz ) throws JAXBException{
+    	JAXBContext ctxt = class2ctxt.get( clazz );
+    	if ( ctxt == null ) {
+            ctxt = JAXBContext.newInstance( clazz );
+            class2ctxt.put( clazz, ctxt );
+        }
+        return ctxt;
+    }
+
+    protected JAXBContext getContext( String packagePath ) throws JAXBException{
+    	JAXBContext ctxt = class2ctxt.get( packagePath );
+    	if ( ctxt == null ) {
+            ctxt = JAXBContext.newInstance( packagePath );
+            class2ctxt.put( packagePath, ctxt );
+        }
+        return ctxt;
+    }
+
+}


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformerProviderImpl.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformerProviderImpl.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/JaxbTransformerProviderImpl.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -1,8 +1,6 @@
-/**
- * 
- */
 package org.drools.runtime.pipeline.impl;
 
+import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 
@@ -10,11 +8,24 @@
 import org.drools.runtime.pipeline.Transformer;
 
 public class JaxbTransformerProviderImpl implements JaxbTransformerProvider {
-    public Transformer newJaxbFromXmlTransformer(Unmarshaller unmarshaller) {
-        return new JaxbFromXmlTransformer( unmarshaller );
+    public Transformer newJaxbFromXmlTransformer( JAXBContext jaxbCtx ) {
+        return new JaxbFromXmlTransformer( jaxbCtx );
     }
     
-    public Transformer newJaxbToXmlTransformer(Marshaller marshaller) {
-        return new JaxbToXmlTransformer( marshaller );
+    public Transformer newJaxbFromXmlCommandTransformer( JAXBContext jaxbCtx ) {
+    	JaxbFromXmlTransformer trans = new JaxbFromXmlTransformer( jaxbCtx );
+    	trans.addContextForCommands();
+    	return trans;
+    }
+
+    public Transformer newJaxbToXmlTransformer( JAXBContext jaxbCtx ) {
+        return new JaxbToXmlTransformer( jaxbCtx );
     }    
+
+    public Transformer newJaxbToXmlResultTransformer( JAXBContext jaxbCtx ) {
+    	JaxbToXmlTransformer trans = new JaxbToXmlTransformer( jaxbCtx );
+    	trans.addContextForResults();
+    	return trans;
+    }
+
 }
\ No newline at end of file

Added: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/ResultTranslator.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/ResultTranslator.java	                        (rev 0)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/ResultTranslator.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -0,0 +1,254 @@
+package org.drools.runtime.pipeline.impl;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.drools.process.result.ExecutionResultsType;
+import org.drools.process.result.FactHandleListType;
+import org.drools.process.result.FactObjectListType;
+import org.drools.process.result.GlobalType;
+import org.drools.process.result.InsertResultsType;
+import org.drools.process.result.ObjectFactory;
+import org.drools.process.result.QueryFieldType;
+import org.drools.process.result.QueryResultsType;
+import org.drools.process.result.QueryRowType;
+import org.drools.result.ExecutionResults;
+import org.drools.result.GenericResult;
+import org.drools.result.GetGlobalResult;
+import org.drools.result.InsertElementsResult;
+import org.drools.result.InsertObjectResult;
+import org.drools.result.QueryResult;
+import org.drools.runtime.rule.FactHandle;
+import org.drools.runtime.rule.QueryResults;
+import org.drools.runtime.rule.QueryResultsRow;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class ResultTranslator {
+    private JaxbTransformer jaxbTransformer;
+    private Map<Class<?>,ResultTransformer> class2trans;
+    private ObjectFactory objFact;
+    private ExecutionResultsType execRes;
+
+    /**
+     * Constructor.
+     *  
+     * @param jaxbTransformer the <tt>JaxbTransformer</tt>
+     */
+    public ResultTranslator( JaxbTransformer jaxbTransformer ){
+        this.jaxbTransformer = jaxbTransformer;
+        class2trans = new HashMap<Class<?>,ResultTransformer>();
+        class2trans.put( InsertElementsResult.class, new InsertElementsResultTransformer() );
+        class2trans.put( InsertObjectResult.class,   new InsertObjectResultTransformer() );
+        class2trans.put( GetGlobalResult.class,      new GetGlobalResultTransformer() );
+	/** @TODO: LATER
+        class2trans.put( GetObjectsResult.class, new GetObjectsResultTransformer() );
+        class2trans.put( SetGlobalResult.class,  new SetGlobalResultTransformer() );
+        */
+        class2trans.put( QueryResult.class,      new QueryResultTransformer() );
+
+        objFact = new ObjectFactory();
+    }
+
+    ObjectFactory getObjFact(){
+    	return objFact;
+    }
+
+    void addResult( Object result ){
+    	execRes.getQueryResultsOrInsertResultsOrGlobalValue().add( result );
+    }
+
+    ResultTransformer getResultTransformer( Class<?> clazz ){
+    	return class2trans.get( clazz );
+    }
+
+
+    Element makeElement( Object obj ) throws JAXBException, ParserConfigurationException {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware( true );
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        Document doc = db.newDocument();
+        JAXBContext ctxt = jaxbTransformer.getContext();
+        Marshaller m = ctxt.createMarshaller();
+        m.marshal( obj, doc );
+        Element el = doc.getDocumentElement();
+        
+        Node xsi = doc.createAttributeNS( "http://www.w3.org/2000/xmlns/", "xmlns:xsi" );
+        xsi.setTextContent( "http://www.w3.org/2001/XMLSchema-instance" );
+        el.getAttributes().setNamedItem( xsi );
+        
+        Node type = doc.createAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "xsi:type" );
+        type.setTextContent( obj.getClass().getName() );
+        el.getAttributes().setNamedItem( type );
+        
+        return el;
+    }
+    
+    public ExecutionResultsType transform( ExecutionResults results ){
+        execRes = new ExecutionResultsType();
+        for( GenericResult aResult: results.getResults() ){
+            ResultTransformer resultTransformer = this.getResultTransformer( aResult.getClass() );
+            if( resultTransformer != null ){
+                resultTransformer.transform( this, aResult );
+	    }
+	}
+        return execRes;
+    }
+
+}
+
+/**
+ * Abstract base class for all result transformers.
+ */
+abstract class ResultTransformer {
+    abstract void transform( ResultTranslator rt,
+                             GenericResult result );
+}
+
+
+class InsertElementsResultTransformer extends ResultTransformer {
+    void transform( ResultTranslator rt, GenericResult result ){
+        InsertElementsResult insertResult = (InsertElementsResult)result;
+        String ident = insertResult.getIdentifier();
+
+        ObjectFactory objFact = rt.getObjFact();
+        InsertResultsType insResultXml = objFact.createInsertResultsType();
+        FactHandleListType fhList = objFact.createFactHandleListType();
+        insResultXml.setFactHandles( fhList );
+        FactObjectListType foList = null;
+        insResultXml.setIdentifier( ident );
+
+        List<FactHandle> fhResList = insertResult.getHandles();
+        List<Object>     obResList = insertResult.getObjects();
+
+        if( obResList != null ){
+            foList = objFact.createFactObjectListType();
+            insResultXml.setFactObjects( foList );
+        }
+            
+        try {
+            for( int i = 0; i < fhResList.size(); i++ ){
+                fhList.getFactHandle().add( fhResList.get( i ).toExternalForm() );
+                if( obResList != null ){
+                    Object factObj = obResList.get( i );
+                    foList.getAny().add( rt.makeElement( factObj ) );
+                }
+            }
+            rt.addResult( insResultXml );
+        } catch (JAXBException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+}
+
+class InsertObjectResultTransformer extends ResultTransformer {
+    void transform( ResultTranslator rt, GenericResult result ){
+        InsertObjectResult insertResult = (InsertObjectResult)result;
+        String ident = insertResult.getIdentifier();
+
+        ObjectFactory objFact = rt.getObjFact();
+        InsertResultsType insResultXml = objFact.createInsertResultsType();
+        FactHandleListType fhList = objFact.createFactHandleListType();
+        insResultXml.setFactHandles( fhList );
+        FactObjectListType foList = null;
+        insResultXml.setIdentifier( ident );
+
+        FactHandle handle = (FactHandle)insertResult.getFactHandle();
+        Object object = insertResult.getValue();
+
+        if( object != null ){
+            foList = objFact.createFactObjectListType();
+            insResultXml.setFactObjects( foList );
+        }
+            
+        try {
+            fhList.getFactHandle().add( handle.toExternalForm() );
+
+            if( object != null ){
+                foList.getAny().add( rt.makeElement( object ) );
+            }
+
+            rt.addResult( insResultXml );
+        } catch (JAXBException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+}
+
+
+class GetGlobalResultTransformer extends ResultTransformer {
+    void transform( ResultTranslator rt, GenericResult result ){
+
+        GetGlobalResult getGlobalResult = (GetGlobalResult)result;
+        String identifier = getGlobalResult.getIdentifier();
+        try {
+            Object globalObject = getGlobalResult.getValue();
+            Element el = rt.makeElement( globalObject );
+            ObjectFactory objFact = rt.getObjFact();
+            GlobalType getGlobalXml = objFact.createGlobalType();
+            getGlobalXml.setIdentifier( identifier );
+            getGlobalXml.setAny( el );
+            rt.addResult( getGlobalXml );
+        } catch (JAXBException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+}
+
+class QueryResultTransformer extends ResultTransformer {
+    void transform( ResultTranslator rt, GenericResult result ){
+        QueryResult queryResult = (QueryResult)result;
+
+        String identifier = queryResult.getIdentifier();
+       	QueryResults qr = queryResult.getResults();
+        int size = qr.size();
+
+        ObjectFactory objFact = rt.getObjFact();
+        QueryResultsType queryResXml = objFact.createQueryResultsType();
+        queryResXml.setIdentifier( identifier );
+        queryResXml.setSize( size );
+
+        String[] quids = qr.getIdentifiers();
+        for( QueryResultsRow row: qr ){
+            QueryRowType queryRowXml = objFact.createQueryRowType();
+            queryResXml.getRow().add( queryRowXml );
+            for( String quid: quids  ){
+                QueryFieldType queryFieldXml = objFact.createQueryFieldType();
+                queryRowXml.getField().add( queryFieldXml );
+                queryFieldXml.setName( quid );
+                
+                try {
+                    Element el = rt.makeElement( row.get( quid ) );
+                    queryFieldXml.setAny( el );
+                } catch( Throwable t ){
+                    queryFieldXml.setValue( row.get( quid ).toString() );
+                }
+            }
+        }
+        rt.addResult( queryResXml );
+    }
+}
+
+


Property changes on: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/main/java/org/drools/runtime/pipeline/impl/ResultTranslator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbFactTest.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbFactTest.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbFactTest.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -64,7 +64,8 @@
         JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
                                                                      kbase );
         Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( unmarshaller );
+
+        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( jaxbCtx );
         transformer.setReceiver( insertStage );
 
         Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );
@@ -87,7 +88,7 @@
 
         //transformer = PipelineFactory.newXStreamToXmlTransformer( xstream );
         Marshaller marshaller = jaxbCtx.createMarshaller();
-        transformer = PipelineFactory.newJaxbToXmlTransformer( marshaller );
+        transformer = PipelineFactory.newJaxbToXmlTransformer( jaxbCtx );
         transformer.setReceiver( assignAsResult );
 
         KnowledgeRuntimeCommand getObject = PipelineFactory.newStatefulKnowledgeSessionGetObject();

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbGlobalTest.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbGlobalTest.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbGlobalTest.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -63,8 +63,7 @@
 
         JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
                                                                      kbase );
-        Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( unmarshaller );
+        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( jaxbCtx );
         transformer.setReceiver(setGlobalStage );
 
         Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );
@@ -83,8 +82,7 @@
         assignAsResult.setReceiver( executeResult );
         
         //transformer = PipelineFactory.newXStreamToXmlTransformer( xstream );
-        Marshaller marshaller = jaxbCtx.createMarshaller();
-        transformer = PipelineFactory.newJaxbToXmlTransformer( marshaller );
+        transformer = PipelineFactory.newJaxbToXmlTransformer( jaxbCtx );
         transformer.setReceiver( assignAsResult );
         
         KnowledgeRuntimeCommand getGlobalStage = PipelineFactory.newStatefulKnowledgeSessionGetGlobal( );        

Modified: labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbTest.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbTest.java	2010-01-19 20:24:30 UTC (rev 31152)
+++ labs/jbossrules/branches/camel_jaxb_marshaller-lucaz/drools-pipeline/drools-transformer-jaxb/src/test/java/org/drools/runtime/pipeline/impl/JaxbTest.java	2010-01-19 23:18:01 UTC (rev 31153)
@@ -106,8 +106,7 @@
 
         JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
                                                                      kbase );
-        Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( unmarshaller );
+        Transformer transformer =  PipelineFactory.newJaxbFromXmlTransformer( jaxbCtx );
         transformer.setReceiver( insertStage );
 
         Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );
@@ -172,8 +171,7 @@
 
         JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
                                                                      kbase );
-        Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
-        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( unmarshaller );
+        Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( jaxbCtx );
         transformer.setReceiver( expression );
 
         Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );



More information about the jboss-svn-commits mailing list