[jboss-svn-commits] JBL Code SVN: r17104 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product: samples/quickstarts/bpm_orchestration1/processDefinition and 17 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Dec 7 15:14:15 EST 2007


Author: kurt.stam at jboss.com
Date: 2007-12-07 15:14:15 -0500 (Fri, 07 Dec 2007)
New Revision: 17104

Added:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackException.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackHelper.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Mapping.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/JBpmCallback.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandServiceImpl.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/ConfigUtil.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbm-queue-service.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbmq-queue-service.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.jpg
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.jpg
Removed:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/FacadeUtil.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMapping.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMappingUnitTest.java
Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/processDefinition/processdefinition.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/jboss-esb.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/processDefinition/processdefinition.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/jboss-esb.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/processDefinition/processdefinition.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/jboss-esb.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/processDefinition/processdefinition.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/MessageFacade.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/SignalFacade.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/META-INF/jboss-esb.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.xml
Log:
JBESB-1301 Cutting over to asycn Callback.

As summarized in: http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossESBjBPMIntegration

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -116,10 +116,10 @@
                     <property name="command" value="NewProcessInstanceCommand" />
                     <property name="process-definition-name" value="processDefinition2"/>   
                     <property name="actor" value="FrankSinatra"/>                                                 
-                    <property name="object-paths">
+                    <property name="esbToBpmVars">
                       <!-- esb-name maps to getBody().get("eVar1") -->
-                        <object-path esb="eVar1" bpm="counter" value="45" />
-                        <object-path esb="BODY_CONTENT" bpm="theBody" />
+                        <mapping esb="eVar1" bpm="counter" value="45" />
+                        <mapping esb="BODY_CONTENT" bpm="theBody" />
                     </property>
                                  
                  </action>  
@@ -134,10 +134,10 @@
                    class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
                     <property name="command" value="SignalCommand" />
                     <property name="process-definition-name" value="processDefinition2"/>   
-                    <property name="object-paths">
+                    <property name="esbToBpmVars">
                       <!-- esb-name maps to getBody().get("eVar1") -->
-                        <object-path esb="eVar1" bpm="counter"  value="45" />  
-                        <object-path esb="BODY_CONTENT" bpm="theBody" />
+                        <mapping esb="eVar1" bpm="counter"  value="45" />  
+                        <mapping esb="BODY_CONTENT" bpm="theBody" />
                     </property>                    
                  </action>
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/processDefinition/processdefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/processDefinition/processdefinition.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/processDefinition/processdefinition.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -14,12 +14,12 @@
          <esbCategoryName>BPM_Orchestration_Service1</esbCategoryName>
          <esbServiceName>Service1</esbServiceName>
          <millisToWaitForResponse>5000</millisToWaitForResponse>
-         <jbpmToEsbVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </jbpmToEsbVars>
-         <returnVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </returnVars>
+         <bpmToEsbVars>
+         	<mapping bpm="theBody" esb="BODY_CONTENT" />
+         </bpmToEsbVars>
+         <esbToBpmVars>
+         	<mapping esb="BODY_CONTENT" bpm="theBody" />
+         </esbToBpmVars>
       </action>
       <transition name="" to="node2"></transition>
    </node>
@@ -28,12 +28,12 @@
          <esbCategoryName>BPM_Orchestration_Service2</esbCategoryName>
          <esbServiceName>Service2</esbServiceName>
          <millisToWaitForResponse>5000</millisToWaitForResponse>
-         <jbpmToEsbVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </jbpmToEsbVars>
-         <returnVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </returnVars>
+         <bpmToEsbVars>
+         	<mapping bpm="theBody" esb="BODY_CONTENT" />
+         </bpmToEsbVars>
+         <esbToBpmVars>
+         	<mapping esb="BODY_CONTENT" bpm="theBody"/>
+         </esbToBpmVars>
       </action>
       <transition name="" to="node3"></transition>
    </node>
@@ -42,12 +42,12 @@
          <esbCategoryName>BPM_Orchestration_Service3</esbCategoryName>
          <esbServiceName>Service3</esbServiceName>         
          <millisToWaitForResponse>5000</millisToWaitForResponse>            
-         <jbpmToEsbVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </jbpmToEsbVars>
-         <returnVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </returnVars>
+         <bpmToEsbVars>
+         	<mapping bpm="theBody" esb="BODY_CONTENT" />
+         </bpmToEsbVars>
+         <esbToBpmVars>
+         	<mapping esb="BODY_CONTENT" bpm="theBody"/>
+         </esbToBpmVars>
       </action>
       <transition name="" to="Send Results"></transition>
    </node>
@@ -60,12 +60,12 @@
          <esbCategoryName>BPM_Orchestration_ResultsService</esbCategoryName>
          <esbServiceName>ResultsService</esbServiceName>         
          <millisToWaitForResponse>5000</millisToWaitForResponse>            
-         <jbpmToEsbVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </jbpmToEsbVars>
-         <returnVars>
-         	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-         </returnVars>
+         <bpmToEsbVars>
+         	<mapping bpm="theBody" esb="BODY_CONTENT" />
+         </bpmToEsbVars>
+         <esbToBpmVars>
+         	<mapping esb="BODY_CONTENT" bpm="theBody"/>
+         </esbToBpmVars>
       </action>
    
       <transition name="" to="end1"></transition>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/jboss-esb.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/jboss-esb.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -104,9 +104,9 @@
                    class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
                     <property name="command" value="StartProcessInstanceCommand" />
                     <property name="process-definition-name" value="bpm_orchestration2Process"/>   
-                     <property name="object-paths">
-                        <object-path esb="eVar1" bpm="counter"  value="45" />
-                        <object-path esb="BODY_CONTENT" bpm="theBody" />
+                     <property name="esbToBpmVars">
+                        <mapping esb="eVar1" bpm="counter"  value="45" />
+                        <mapping esb="BODY_CONTENT" bpm="theBody" />
                     </property>
 				</action>
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/processDefinition/processdefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/processDefinition/processdefinition.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/processDefinition/processdefinition.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -10,13 +10,12 @@
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service1</esbCategoryName>
             <esbServiceName>Service1</esbServiceName>
-            <millisToWaitForResponse>5000</millisToWaitForResponse>
-            <jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>
+            <bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody" />
+            </esbToBpmVars>
          </action>
 		<transition to="Credit Check"></transition>
 	</node>
@@ -25,13 +24,12 @@
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service2</esbCategoryName>
             <esbServiceName>Service2</esbServiceName>
-            <millisToWaitForResponse>5000</millisToWaitForResponse>
-            <jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>           
+            <bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody"/>
+            </esbToBpmVars>           
          </action>
 		<transition to="Inventory Check"></transition>
    </node>
@@ -45,14 +43,13 @@
 
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service5</esbCategoryName>
-            <esbServiceName>Service5</esbServiceName>         
-            <millisToWaitForResponse>5000</millisToWaitForResponse>            
-			<jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>            
+            <esbServiceName>Service5</esbServiceName>                    
+			<bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody" />
+            </esbToBpmVars>            
          </action>
 
       <transition name="" to="join1"></transition>
@@ -61,14 +58,13 @@
 
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service6</esbCategoryName>
-            <esbServiceName>Service6</esbServiceName>         
-            <millisToWaitForResponse>5000</millisToWaitForResponse>            
-			<jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>           
+            <esbServiceName>Service6</esbServiceName>                    
+			<bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping  esb="BODY_CONTENT" bpm="theBody" />
+            </esbToBpmVars>           
          </action>
 
       <transition name="" to="join1"></transition>
@@ -78,14 +74,13 @@
 
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service7</esbCategoryName>
-            <esbServiceName>Service7</esbServiceName>         
-            <millisToWaitForResponse>5000</millisToWaitForResponse>            
-			<jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>           
+            <esbServiceName>Service7</esbServiceName>                   
+			<bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody"/>
+            </esbToBpmVars>           
          </action>
 		
       <transition name="" to="join1"></transition>   
@@ -99,12 +94,12 @@
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_ResultsService</esbCategoryName>
             <esbServiceName>ResultsService</esbServiceName>                 
-			<jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>         
+			<bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody"/>
+            </esbToBpmVars>         
          </action>
       
    
@@ -116,14 +111,13 @@
          
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service3</esbCategoryName>
-            <esbServiceName>Service3</esbServiceName>         
-            <millisToWaitForResponse>5000</millisToWaitForResponse>            
-			<jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>         
+            <esbServiceName>Service3</esbServiceName>                 
+			<bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody" />
+            </esbToBpmVars>         
          </action>
 		<transition to="Validate Order"></transition>
    </node>
@@ -131,14 +125,13 @@
       
          <action name="esbAction" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
             <esbCategoryName>BPM_Orchestration2_Service4</esbCategoryName>
-            <esbServiceName>Service4</esbServiceName>         
-            <millisToWaitForResponse>5000</millisToWaitForResponse>            
-			<jbpmToEsbVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="theBody" esb="BODY_CONTENT" />
-            </returnVars>            
+            <esbServiceName>Service4</esbServiceName>                  
+			<bpmToEsbVars>
+            	<mapping bpm="theBody" esb="BODY_CONTENT" />
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="BODY_CONTENT" bpm="theBody" />
+            </esbToBpmVars>            
          </action>
 		<transition to="fork1"></transition>
    </node>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/jboss-esb.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/jboss-esb.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -94,9 +94,9 @@
                     <property name="command" value="StartProcessInstanceCommand" />
                     <property name="process-definition-name" value="bpm_orchestration3Process"/>   
                     <property name="key" value="businessKey"/>
-                     <property name="object-paths">                        
-                        <object-path esb="BODY_CONTENT" bpm="theBody" />
-                        <object-path esb="contentsAsString" bpm="theData" /> 
+                    <property name="esbToBpmVars">                        
+                        <mapping esb="BODY_CONTENT" bpm="theBody" />
+                        <mapping esb="contentsAsString" bpm="theData" /> 
                     </property>
                  </action>
             </actions>
@@ -123,9 +123,9 @@
                  <action  name="signal_a_process_instance" 
                    class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
                     <property name="command" value="SignalCommand" />
-                    <property name="object-paths">                        
-                        <object-path esb="BODY_CONTENT" bpm="theBody" /> 
-                        <object-path esb="body" bpm="theData" /> 
+                    <property name="esbToBpmVars">                        
+                        <mapping esb="BODY_CONTENT" bpm="theBody" /> 
+                        <mapping esb="body" bpm="theData" /> 
                     </property>
                  </action>
                  

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/processDefinition/processdefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/processDefinition/processdefinition.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/processDefinition/processdefinition.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -15,12 +15,12 @@
 				BPM_Orchestration3_Service1
 			</esbCategoryName>
 			<esbServiceName>Service1</esbServiceName>
-			<jbpmToEsbVars>
-				<mapping jbpm="theBody" esb="BODY_CONTENT" />
-			</jbpmToEsbVars>
-			<returnVars>
-				<mapping jbpm="theBody" esb="BODY_CONTENT" />
-			</returnVars>
+			<bpmToEsbVars>
+				<mapping bpm="theBody" esb="BODY_CONTENT" />
+			</bpmToEsbVars>
+			<esbToBpmVars>
+				<mapping esb="BODY_CONTENT" bpm="theBody"/>
+			</esbToBpmVars>
 		</action>
 		<transition to="Service 2"></transition>
 	</node>
@@ -32,12 +32,12 @@
 				BPM_Orchestration3_Service2
 			</esbCategoryName>
 			<esbServiceName>Service2</esbServiceName>
-			<jbpmToEsbVars>
-				<mapping jbpm="theBody" esb="BODY_CONTENT" />
-			</jbpmToEsbVars>
-			<returnVars>
-				<mapping jbpm="theBody" esb="BODY_CONTENT" />
-			</returnVars>
+			<bpmToEsbVars>
+				<mapping bpm="theBody" esb="BODY_CONTENT" />
+			</bpmToEsbVars>
+			<esbToBpmVars>
+				<mapping esb="BODY_CONTENT" bpm="theBody" />
+			</esbToBpmVars>
 		</action>
 		<transition to="Service 3"></transition>
 	</node>
@@ -49,12 +49,12 @@
 				BPM_Orchestration3_Service3
 			</esbCategoryName>
 			<esbServiceName>Service3</esbServiceName>
-			<jbpmToEsbVars>
-				<mapping jbpm="theBody" esb="BODY_CONTENT" />
-			</jbpmToEsbVars>
-			<returnVars>
-				<mapping jbpm="theBody" esb="BODY_CONTENT" />
-			</returnVars>
+			<bpmToEsbVars>
+				<mapping bpm="theBody" esb="BODY_CONTENT" />
+			</bpmToEsbVars>
+			<esbToBpmVars>
+				<mapping esb="BODY_CONTENT" bpm="theBody" />
+			</esbToBpmVars>
 		</action>
 		<transition to="end-state1"></transition>
 	</node>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/jboss-esb.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/jboss-esb.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -75,8 +75,8 @@
 					<property name="process-definition-name"
 						value="bpm4_ESBOrderProcess" />
 					<property name="key" value="body.businessKey" />
-					<property name="object-paths">
-						<object-path esb="BODY_CONTENT"	bpm="entireOrderAsXML" />
+					<property name="esbToBpmVars">
+						<mapping esb="BODY_CONTENT"	bpm="entireOrderAsXML" />
 					</property>
 
 				</action>
@@ -94,7 +94,7 @@
 				<jms-listener name="ESB-Listener"
 					busidref="intakeServiceEsbChannel" maxThreads="1" />
 			</listeners>
-			<actions mep="OneWay">
+			<actions>
 				
 				<action name="dump1" class="org.jboss.soa.esb.actions.SystemPrintln">
 					<property name="message" value="INTAKE START" />
@@ -140,52 +140,21 @@
 					<property name="ruleSet"
 						value="Priority_Rules.drl" />
 					<property name="ruleReload" value="true" />
-					<property name="object-paths">
-						<object-path esb="body.orderHeader" />
-						<object-path esb="body.customer" />
+					<property name="esbToBpmVars">
+						<mapping esb="body.orderHeader" />
+						<mapping esb="body.customer" />
 					</property>
 				</action>
-
 				<action name="setupPriority"
 					class="org.jboss.soa.esb.actions.scripting.GroovyActionProcessor">
 					<property name="script"
 						value="/scripts/setup_priority.groovy" />
 				</action>
-
-        <action name="monitor" class="org.jboss.soa.esb.samples.quickstarts.bpm_orchestration4.esb_actions.SimpleJMSNotifier">
-					  <property name="ALERT_QUEUE_NAME" value="quickstart_bpm_orchestration4_monitor" />     
-					  <property name="PREPENDED_TEXT" value="Priority" />     
-					  <property name="BODY_KEY" value="order_orderPriority" />
-        </action>
- 				
- 				<!-- signal the process to indicate that intake is complete -->
- 				<action  name="signal_a_process_instance" 
-                   class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
-                    <property name="command" value="SignalCommand" />
-                    <property name="object-paths">                        
-						<object-path esb="body.entireOrderAsXML"
-							bpm="entireOrderAsXML" />
-						<object-path esb="body.orderHeader"
-							bpm="entireOrderAsObject" />
-						<object-path esb="body.customer"
-							bpm="entireCustomerAsObject" />							
-						<object-path esb="body.order_orderId"
-							bpm="order_orderid" />
-						<object-path esb="body.order_totalAmount"
-							bpm="order_totalamount" />
-							
-						<!-- is it set on the message? -->
-						<object-path esb="body.order_orderPriority"
-							bpm="order_priority" />
-
-						<object-path esb="body.customer_firstName"
-							bpm="customer_firstName" />
-						<object-path esb="body.customer_lastName"
-							bpm="customer_lastName" />
-						<object-path esb="body.customer_status"
-							bpm="customer_status" />
-                    </property>
-                 </action>
+		        <action name="monitor" class="org.jboss.soa.esb.samples.quickstarts.bpm_orchestration4.esb_actions.SimpleJMSNotifier">
+							  <property name="ALERT_QUEUE_NAME" value="quickstart_bpm_orchestration4_monitor" />     
+							  <property name="PREPENDED_TEXT" value="Priority" />     
+							  <property name="BODY_KEY" value="order_orderPriority" />
+		        </action>		
 			</actions>
 		</service>
 		<service category="BPM_Orchestration4" name="DiscountService"
@@ -212,9 +181,9 @@
 					<property name="ruleSet"
 						value="Discount_Rules.drl" />
 					<property name="ruleReload" value="true" />
-					<property name="object-paths">
-						<object-path esb="body.orderHeader" />
-						<object-path esb="body.customer" />
+					<property name="esbToBpmVars">
+						<mapping esb="body.orderHeader" />
+						<mapping esb="body.customer" />
 					</property>
 				</action>
 				
@@ -224,23 +193,12 @@
 						value="/scripts/setup_discount.groovy" />
 				</action>				
 
-        <action name="monitor" class="org.jboss.soa.esb.samples.quickstarts.bpm_orchestration4.esb_actions.SimpleJMSNotifier">
-				  <property name="ALERT_QUEUE_NAME" value="quickstart_bpm_orchestration4_monitor" />     
-				  <property name="PREPENDED_TEXT" value="Discount Service" />
-				  <property name="BODY_KEY" value="order_orderDiscount" />
-        </action>
+		        <action name="monitor" class="org.jboss.soa.esb.samples.quickstarts.bpm_orchestration4.esb_actions.SimpleJMSNotifier">
+						  <property name="ALERT_QUEUE_NAME" value="quickstart_bpm_orchestration4_monitor" />     
+						  <property name="PREPENDED_TEXT" value="Discount Service" />
+						  <property name="BODY_KEY" value="order_orderDiscount" />
+		        </action>
         
- 				<!-- signal the process to indicate that discount is complete -->
- 				<action  name="signal_a_process_instance" 
-                   class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
-                    <property name="command" value="SignalCommand" />
-                    <property name="object-paths">                                          
-						<object-path esb="body.order_orderDiscount"
-							bpm="order_discount" />
-                    </property>
-                 </action>
-				
-        
 			</actions>
 		</service>
 		
@@ -322,9 +280,9 @@
 			</listeners>
 			<actions>
                 <action name="monitor" class="org.jboss.soa.esb.samples.quickstarts.bpm_orchestration4.esb_actions.SimpleJMSNotifier">
-								  <property name="ALERT_QUEUE_NAME" value="quickstart_bpm_orchestration4_monitor" />     
-								  <property name="PREPENDED_TEXT" value="Basic:Lowest Priority Customers/Orders" />     
-								  <property name="BODY_KEY" value="orderHeader" />
+				  <property name="ALERT_QUEUE_NAME" value="quickstart_bpm_orchestration4_monitor" />     
+				  <property name="PREPENDED_TEXT" value="Basic:Lowest Priority Customers/Orders" />     
+				  <property name="BODY_KEY" value="orderHeader" />
                 </action>
 			</actions>
 		</service>				

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/processDefinition/processdefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/processDefinition/processdefinition.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/processDefinition/processdefinition.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -12,13 +12,21 @@
             <esbCategoryName>BPM_Orchestration4</esbCategoryName>
             <esbServiceName>IntakeService</esbServiceName>
             <!-- async call of IntakeService -->            
-		    <jbpmToEsbVars>
-            	<mapping jbpm="entireOrderAsXML" esb="BODY_CONTENT" />            	
-            </jbpmToEsbVars>
-            <!--  since this async, should skip returnVars -->
-            <returnVars>
-            	<mapping jbpm="entireOrderAsXML" esb="BODY_CONTENT" />            	
-            </returnVars>
+		    <bpmToEsbVars>
+            	<mapping bpm="entireOrderAsXML" esb="BODY_CONTENT" />            	
+            </bpmToEsbVars>
+            <esbToBpmVars>
+            	<mapping esb="body.entireOrderAsXML" bpm="entireOrderAsXML" />
+				<mapping esb="body.orderHeader" bpm="entireOrderAsObject" />
+				<mapping esb="body.customer" bpm="entireCustomerAsObject" />							
+				<mapping esb="body.order_orderId" bpm="order_orderid" />
+				<mapping esb="body.order_totalAmount" bpm="order_totalamount" />	
+				<!-- is it set on the message? -->
+				<mapping esb="body.order_orderPriority" bpm="order_priority" />
+				<mapping esb="body.customer_firstName" bpm="customer_firstName" />
+				<mapping esb="body.customer_lastName" bpm="customer_lastName" />
+				<mapping esb="body.customer_status" bpm="customer_status" />            	
+            </esbToBpmVars>
          </action>
          
       <transition name="" to="Review Order"></transition>
@@ -47,13 +55,14 @@
             <esbCategoryName>BPM_Orchestration4</esbCategoryName>
             <esbServiceName>DiscountService</esbServiceName>         
 			<jbpmToEsbVars>
-			<mapping jbpm="entireCustomerAsObject" esb="customer" />
-			<mapping jbpm="entireOrderAsObject" esb="orderHeader" />
-			<mapping jbpm="entireOrderAsXML" esb="BODY_CONTENT" />
+				<mapping bpm="entireCustomerAsObject" esb="customer" />
+				<mapping bpm="entireOrderAsObject"    esb="orderHeader" />
+				<mapping bpm="entireOrderAsXML"       esb="BODY_CONTENT" />
 			</jbpmToEsbVars>
-            <returnVars>
-            	<mapping jbpm="entireOrderAsObject" esb="order" />            	
-            </returnVars>         
+            <esbToBpmVars>
+            	<mapping esb="order" bpm="entireOrderAsObject" /> 
+            	<mapping esb="body.order_orderDiscount" bpm="order_discount" />       	
+            </esbToBpmVars>         
          </action>
           
       <transition name="" to="Review Discount"></transition>
@@ -72,11 +81,11 @@
             <esbCategoryName>BPM_Orchestration4</esbCategoryName>
             <esbServiceName>ShippingService</esbServiceName>                 
             <millisToWaitForResponse>10000</millisToWaitForResponse>            
-			<jbpmToEsbVars><mapping jbpm="entireCustomerAsObject" esb="customer" />	<mapping jbpm="entireOrderAsObject" esb="orderHeader" /><mapping jbpm="entireOrderAsXML" esb="entireOrderAsXML" />
-					
-			
-			
-				</jbpmToEsbVars>   
+			<jbpmToEsbVars>
+				<mapping bpm="entireCustomerAsObject" esb="customer" />
+				<mapping bpm="entireOrderAsObject"    esb="orderHeader" />
+				<mapping bpm="entireOrderAsXML"       esb="entireOrderAsXML" />
+			</jbpmToEsbVars>   
          </action>
          </event>
       <transition name="" to="end"></transition>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -53,10 +53,12 @@
 	public static final String ACTOR_NAMES_ARRAY			="jbpmActorNamesArray";
 	public static final String OVERWRITE_SWIMLANE			="jbpmOverwriteSwim";
     public static final String KEYPATH                      ="pathTojbpmKey";
+    public static final String NODE_ID                      ="jbpmNodeId";
+    public static final String PROCESS_NODE_VERSION_COUNTER ="jbpmProcessNodeVersionCounter";
 
 	public static final String TRANSITION_NAME				="jbpmTransitionName";
 	public static final String CURRENT_NODE_NAME			="jbpmCurrentNodeName";
-	public static final String VARIABLE_VALUES				="jbpmVariableValuesMap";
+	public static final String VARIABLE_VALUES				="jbpmVariableMappings";
 	public static final String JBPM_RETURN_OBJECT			="jbpmReturnObject";
 	public static final String EXCEPTION     				="jbpmException";
 	public static final String ERROR_MESSAGE   				="jbpmErrorMsg";
@@ -79,17 +81,26 @@
 	public static final String INCLUDE_ALL_VARS_TAG			="include-all-variables";
 	public static final String INCLUDE_LOGS_TAG				="include-logs";
 	public static final String VARIABLES_TAG				="variables";
-    public static final String OBJECT_PATH_TAG              ="object-path";
 	public static final String ONE_VARIABLE_TAG				="variable";
 	public static final String ESB_VARNAME_TAG				="esb";
-	public static final String JBPM_VARNAME_TAG				="bpm";
+	public static final String BPM_VARNAME_TAG				="bpm";
+    public static final String DEFAULT_VALUE_TAG            ="default";
 	public static final String ACTORS_TAG					="actors";
 	public static final String ONE_ACTOR_TAG				="actor";
 	public static final String OVERWRITE_SWIMLANE_TAG		="overwrite-swimlane";
     public static final String KEY_TAG                      ="key";
+    
+    //tag names for xml configuration of jBPM actions
+    public static final String BPM_TO_ESB_VARS_TAG = "bpmToEsbVars";
+    public static final String ESB_TO_BPM_VARS_TAG = "esbToBpmVars";
+    public static final String MAPPING_TAG = "mapping";
+    public static final String BPM_NAME_ATTR = "bpm";
+    public static final String ESB_NAME_ATTR = "esb";
+    public static final String PROCESS_SCOPE_ATTR = "process-scope";
 
 	public enum OpCode
 	{
+        CallbackCommand,
 		DeployProcessDefinition
 //		AbstractCancelCommand
 //		,AbstractGetObjectBaseCommand

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackException.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackException.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackException.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm;
+
+import org.jboss.soa.esb.BaseException;
+
+/**
+ * Configuration Exception.
+ * @author <a href="mailto:kurt.stam at jboss.com">kurt.stam at jboss.com</a>
+ * @since Version 4.2
+ */
+public class JBpmCallbackException extends BaseException {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     */
+    public JBpmCallbackException(String message) {
+        super(message);
+    }
+
+    /**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     * @param cause Exception cause.
+     */
+    public JBpmCallbackException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Construct an exception instance. 
+     * @param cause Exception cause.
+     */
+    public JBpmCallbackException(Throwable cause) {
+        super(cause);
+    }
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackException.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackHelper.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackHelper.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,134 @@
+/**
+ * 
+ */
+package org.jboss.soa.esb.services.jbpm;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.services.jbpm.actions.JBpmCallback;
+import org.jboss.soa.esb.services.jbpm.cmd.CommandServiceImpl;
+import org.jbpm.command.GetProcessInstanceCommand;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+
+/**
+ * @author kstam
+ *
+ */
+public class JBpmCallbackHelper 
+{
+    private Logger logger = Logger.getLogger(this.getClass());
+    
+    /**
+     * Setup the replyTo for the CallBack Service.
+     * 
+     * Creates or increments a process-node-version-counter whose name is related to 
+     * the current node ID. The name of the counter is jbpmProcessNodeVersionCounter<NodeId>.
+     * The counter is added to the ProcessVariable Map (global to the ProcessInstance) 
+     * on the jBPM side The same variable should be added to the 
+     * EsbMessage before it is passed onto the ESB. Other parameters added
+     * are the returnVariable mapping, the nodeId and the tokenId.
+     * 
+     * @param returnVars - XML fragment from the processdefinition.xml describing
+     * the mapping of ESB Message objects to the jBPM variableMap.
+     * @param executionContext of the currently invoked EsbActionHandler.
+     * @return the replyTo EPR of the JBpmCallbackService.
+     */
+    public EPR createReplyTo(String esbToJBpmXml, Boolean globalProcessScope, ExecutionContext executionContext)
+    {
+        EPR replyTo = new LogicalEPR(ServiceInvoker.INTERNAL_SERVICE_CATEGORY, JBpmCallback.JBPM_CALL_BACK_SERVICE_NAME);
+        PortReference portReference = replyTo.getAddr();
+        portReference.addExtension(Constants.ESB_TO_BPM_VARS_TAG, esbToJBpmXml);
+        if (globalProcessScope!=null) {
+            portReference.addExtension(Constants.PROCESS_SCOPE_ATTR, globalProcessScope.toString());
+        }
+        portReference.addExtension(Constants.TOKEN_ID, String.valueOf(executionContext.getToken().getId()));
+        String nodeId = "";
+        if (executionContext.getNode()!=null) {
+            nodeId = String.valueOf(executionContext.getNode().getId());
+            portReference.addExtension(Constants.NODE_ID, nodeId);
+            
+        }
+        portReference.addExtension(Constants.PROCESS_INSTANCE_ID, String.valueOf(executionContext.getProcessInstance().getId()));
+        
+        String counterName = Constants.PROCESS_NODE_VERSION_COUNTER  + nodeId;
+        Long counter = Long.getLong(String.valueOf(executionContext.getVariable(counterName)));
+        if (counter!=null) {
+            counter = counter + 1;
+        } else {
+            counter = 0l;
+        }
+        //Adding to the jBPM variableMap
+        executionContext.setVariable(counterName, counter.toString());
+        //Adding same value to the message
+        portReference.addExtension(counterName, counter.toString());
+        return replyTo;
+    }
+    /**
+     * Checks whether the current state in jBPM is the expected state. If so it returns the tokenId
+     * on which we can invoke a signal.
+     * 
+     * @param commandService
+     * @param replyTo
+     * @return
+     * @throws JBpmCallbackException
+     */
+    public long checkCurrentState(CommandServiceImpl commandService, EPR replyTo)
+    throws JBpmCallbackException
+    {
+        long nodeId  = Long.parseLong(replyTo.getAddr().getExtensionValue(Constants.NODE_ID));
+        long tokenId = Long.parseLong(replyTo.getAddr().getExtensionValue(Constants.TOKEN_ID));
+        long processInstanceId = Long.parseLong(replyTo.getAddr().getExtensionValue(Constants.PROCESS_INSTANCE_ID));
+        String counterName = Constants.PROCESS_NODE_VERSION_COUNTER + nodeId;
+        long processNodeVersion = Long.parseLong(replyTo.getAddr().getExtensionValue(counterName));
+        if (logger.isDebugEnabled()) logger.debug("Expected nodeId=" + nodeId + 
+                ", tokenId=" + tokenId + ", processNodeVersion=" + processNodeVersion);
+        //get update on current state of things.
+        try {
+            ProcessInstance instance = (ProcessInstance)commandService
+                                            .execute(new GetProcessInstanceCommand(processInstanceId));
+            Long currentTokenId = null;
+            Long currentNodeId = null;
+            List tokens = instance.findAllTokens();
+            for (Object object : tokens) {
+                Token token = (Token) object;
+                if (token.getId()==tokenId) {
+                    currentTokenId = token.getId();
+                    currentNodeId = token.getNode().getId();
+                }
+            }
+            //Compare current with expected
+            StringBuilder unExpected = new StringBuilder();
+            if (nodeId!=currentNodeId) {
+                unExpected.append("A timeout occured or something else signaled the node, " + currentNodeId +
+                        "causing it to move away from the expected node with id= ").append(nodeId).append(". ");
+            }
+            if (tokenId!=currentTokenId) {
+                unExpected.append("The process is at the expected Node, but the current Token (id=" + currentTokenId +
+                        ") is not the expected Token (").append(tokenId).append("), "); 
+            }
+            if (logger.isDebugEnabled()) logger.debug("Current state nodeId=" + currentNodeId);
+            Long currentProcessNodeVersion = Long.parseLong(String.valueOf(
+                    instance.getContextInstance().getVariable(counterName)));
+            if (logger.isDebugEnabled()) logger.debug("ProcessNodeVersion=" + currentProcessNodeVersion);
+            if (processNodeVersion!=currentProcessNodeVersion) {
+                unExpected.append("The current processNodeVersion (id=" + currentProcessNodeVersion +
+                        ") is not the expected version (version=").append(processNodeVersion).append("). ");
+            }
+            //get the current processNode Version
+            if (!"".equals(unExpected.toString())) {
+                throw new JBpmCallbackException(unExpected.toString());
+            }
+        } finally {
+            commandService.close();
+        }
+        
+        return tokenId;
+    }
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmCallbackHelper.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,243 @@
+/**
+ * 
+ */
+package org.jboss.soa.esb.services.jbpm;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.tree.DefaultElement;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.Token;
+import org.mvel.MVEL;
+
+/**
+ * Mapping glue between jBPM and ESB. Handles setting up the replyTo of the
+ * JBpmCallback Service, and is a wrapper around org.jboss.soa.esb.message.mapping.ObjectMapper 
+ * to handle jBPM specifics around mapping variables from jBPM to ESB and back.
+ * 
+ * @author kstam
+ */
+public class JBpmObjectMapper {
+    
+    public JBpmObjectMapper() {
+        super();
+    }
+
+    private Logger log = Logger.getLogger(getClass());
+    private ObjectMapper objectMapper = new ObjectMapper();
+    
+    /**
+     * Creates an ESB Message, giving the mapping specified in the jbpmToEsbVars Element. 
+     * This element is defined in the jBPM process-definition.xml as child element
+     * of either the EsbNotifier ActionHandler, or the EsbActionHandler.
+     * 
+     * @param jbpmToEsbVars - the configuration of the mapping.
+     * @param isGlobalProcessScope - Variables will be looked up using either the token scope or the process-definition (global) scope
+     * See the jBPM documentation for more details.
+     * @param executionContext - the jBPM ExecutionContext.
+     * @return the newly created ESB message.
+     * 
+     * @throws Exception
+     */
+    public Message mapFromJBpmToEsbMessage (final DefaultElement bpmToEsbVars, final Boolean isGlobalProcessScope, final ExecutionContext executionContext)
+    {
+        Message message = MessageFactory.getInstance().getMessage();
+        boolean gblPrcScope = (null == isGlobalProcessScope) ? false : isGlobalProcessScope;
+     
+        if (bpmToEsbVars==null) {
+            return message;
+        }
+        List mappings = bpmToEsbVars.elements(Constants.MAPPING_TAG);
+        if (mappings.size() < 1) {
+            setAllOnEsbMessage(gblPrcScope, executionContext, message);
+        } else {
+            for (Object mappingElement : mappings) {
+                Element element = (Element) mappingElement;
+                try {
+                    Mapping mapping = Mapping.parseMappingElement(element);
+                    setOnEsbMessage(mapping, gblPrcScope, executionContext, message);
+                } catch (ConfigurationException ce) {
+                    log.error(ce.getMessage(), ce);
+                } catch (ObjectMappingException ome) {
+                    log.error(ome.getMessage(), ome);
+                }
+            }
+        }
+        return message;
+    }
+    /**
+     * Sets all the Objects in the jBPM VariableMap in the body of the ESB Message using the
+     * the jBPM object names as the Esb Message body keys.
+     * 
+     * @param gblPrcScope
+     * @param executionContext
+     * @param message
+     */
+    private void setAllOnEsbMessage(final boolean gblPrcScope, final ExecutionContext executionContext, Message message) 
+    {
+        Token token = executionContext.getToken();
+        ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
+        log.debug("The user has not mapped anything (jbpmToEsbVars is null) " +
+                  "so add all the variables using their jBPM name");
+        Map map = (gblPrcScope) ? ctxInstance.getVariables() : ctxInstance.getVariables(token);
+        if (null != map) {
+            for (Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+                Map.Entry jBPMVariable = (Map.Entry) iter.next();
+                message.getBody().add(jBPMVariable.getKey().toString(), jBPMVariable.getValue());
+            }
+        }
+    }
+    /**
+     * Sets a jBPM object onto the ESB Message. The mapping is defined in the Mapping element.
+     * 
+     * @param mapping          - Mapping object, used to extract the object from jBPM and used to set the object on the ESB Message
+     * @param gblPrcScope      - Global setting for the jBPM scope
+     * @param message          - ESB Message
+     * @param executionContext - jBPM ExcutionContext
+     *
+     * @throws ObjectMappingException
+     */
+    private void setOnEsbMessage(final Mapping mapping, final boolean gblPrcScope, final ExecutionContext executionContext, Message message)
+    throws ObjectMappingException, ConfigurationException
+    {
+        if (mapping.getBpm()==null || "".equals(mapping.getBpm())) {
+            throw new ConfigurationException("The 'bpm' attribute is a required attribute");
+        }
+        if (mapping.getEsb()==null || "".equals(mapping.getEsb())) {
+            mapping.setEsb(mapping.getBpm());
+        }
+        Token token = executionContext.getToken();
+        ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
+        //Each mapping can override the global setting
+        boolean isPrcScope = (null == mapping.getIsProcessScope()) ? gblPrcScope : mapping.getIsProcessScope();
+        //By default assume the object is part of the jBPM variableMap
+        Object object = getObjectFromJBpmVariableMap(isPrcScope, mapping.getBpm(), ctxInstance, token);
+        //if that fails then try to get it from the ExecutionContext
+        if (object==null) {
+            object = MVEL.getProperty(mapping.getBpm(), executionContext);
+        }
+        if (null != object) {
+            ObjectMapper mapper = new ObjectMapper();
+            mapper.setObjectOnMessage(message, mapping.getEsb(), object);
+        } else {
+            log.warn("The object " + mapping.getBpm() + " is null and cannot not be set on the message");
+        }
+    }
+    /**
+     * Obtains an Object from the jBPM variableMap. 
+     * 
+     * @param isPrcScope - if true, within process-instance scope, if false, within token scope, or up the token hierarchy.
+     * @param expression - MVEL expression String.
+     * @param ctxInstance - jBPM ContextInstance where the jBPM variableMap lives.
+     * @param token - the current jBPM token, needed if isPrcScope is false.
+     * @return
+     */
+    private Object getObjectFromJBpmVariableMap(final boolean isPrcScope, final String expression, final ContextInstance ctxInstance, final Token token)
+    {
+        Object object = null;
+        String objectName = expression;
+        String remainingExpression = null;
+        int dotPosition=expression.indexOf(".");
+        if (dotPosition > 0) {
+            objectName = expression.substring(0, dotPosition-1);
+            remainingExpression = expression.substring(dotPosition+1);
+        } 
+        if (isPrcScope) {
+            object = ctxInstance.getVariable(objectName);
+        } else {
+            object = ctxInstance.getVariable(objectName, token);
+        }
+        if (object !=null && remainingExpression!=null) {
+            log.debug("Using MVEL to obtain the object from " + object + " using expression: " + remainingExpression);
+            object = MVEL.getProperty(remainingExpression, object);
+        }
+        return object;
+    }
+    /**
+     * 
+     * @param message
+     * @param esbToBpmXml
+     * @return
+     */
+    public HashMap<String,Object> mapFromEsbMessageToJBpmMap(Message message, final String esbToBpmXml)
+    throws ConfigurationException
+    {
+        List<Mapping> mappingList = new ArrayList<Mapping>();
+        if (esbToBpmXml!=null) {
+            try {
+                Document document = DocumentHelper.parseText(esbToBpmXml);
+                Element element = document.getRootElement();
+                Iterator iterator=element.elementIterator();
+                while(iterator.hasNext()) {
+                    Element mappingElement = (Element) iterator.next();
+                    Mapping mapping = Mapping.parseMappingElement(mappingElement);
+                    mappingList.add(mapping);
+                }
+            } catch (DocumentException de) {
+                throw new ConfigurationException(de.getMessage(), de);
+            }
+        }
+        return mapFromEsbMessageToJBpmMap(message, mappingList);
+    }
+    /**
+     * This 
+     * @param message
+     * @param token
+     * @throws Exception
+     */
+    public HashMap<String,Object> mapFromEsbMessageToJBpmMap (Message message, final List<Mapping> mappingList)
+    {
+        HashMap<String,Object> map = new HashMap<String, Object>();
+        if (null==mappingList || mappingList.size()<1) {
+            return null;
+        }
+        for (Mapping mapping: mappingList) {
+            if (mapping.getBpm()==null || "".equals(mapping.getBpm())) {
+                
+                mapping.setBpm(mapping.getEsb());
+            }
+            Object value = null;
+            try {
+                value = getObjectFromMessage(message, mapping);
+            } catch (ConfigurationException ce) {
+                log.error(ce.getMessage(), ce);
+            } 
+            // only put it in the map if it's not null
+            if (null!=value)
+                map.put(mapping.getBpm(), value);
+        }
+        return map;
+    }
+    
+    private Object getObjectFromMessage(Message message, Mapping mapping) 
+    throws ConfigurationException
+    {
+        Object value = null;
+        if (mapping.getEsb()==null || "".equals(mapping.getEsb())) {
+            throw new ConfigurationException("The 'esb' attribute is a required attribute");
+        }
+        try {
+            value = objectMapper.getObjectFromMessage(message, mapping.getEsb());
+        } catch (ObjectMappingException ome) {
+            log.info(mapping.getEsb() + " not found");
+            value =mapping.getDefaultValue();
+        }
+        log.debug("value=" + value);
+        return value;
+    }
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Mapping.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Mapping.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Mapping.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,88 @@
+/**
+ * 
+ */
+package org.jboss.soa.esb.services.jbpm;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.dom4j.Element;
+import org.jboss.soa.esb.helpers.ConfigTree;
+
+/**
+ * @author kstam
+ *
+ */
+public class Mapping implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+    private String bpm;
+    private String esb;
+    private Boolean isProcessScope;
+    private String defaultValue;
+    private static transient Logger log = Logger.getLogger(Mapping.class);
+    
+    public String getBpm() {
+        return bpm;
+    }
+    public void setBpm(String bpm) {
+        this.bpm = bpm;
+    }
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+    public String getEsb() {
+        return esb;
+    }
+    public void setEsb(String esb) {
+        this.esb = esb;
+    }
+    public Boolean getIsProcessScope() {
+        return isProcessScope;
+    }
+    public void setIsProcessScope(Boolean isProcessScope) {
+        this.isProcessScope = isProcessScope;
+    }
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("Mapping[ esb=").append(esb)
+               .append(", bpm=").append(bpm)
+               .append(", isProcessScope=").append(isProcessScope)
+               .append(", defaultValue=").append(defaultValue).append(" ]");
+        return builder.toString();
+    }
+    /**
+     * 
+     * @param mappingElement
+     * @return
+     */
+    public static Mapping parseMappingElement(Element mappingElement)
+    {
+        Mapping mapping = new Mapping();
+        mapping.setEsb(mappingElement.attributeValue(Constants.ESB_VARNAME_TAG));
+        mapping.setBpm(mappingElement.attributeValue(Constants.BPM_VARNAME_TAG));
+        mapping.setDefaultValue(mappingElement.attributeValue(Constants.DEFAULT_VALUE_TAG));
+        mapping.setIsProcessScope(Boolean.parseBoolean(mappingElement.attributeValue(Constants.PROCESS_SCOPE_ATTR)));
+        if (log.isDebugEnabled()) log.debug(mappingElement.asXML() + ":" + mapping);
+        return mapping;
+    }
+    
+    /**
+     * 
+     * @param mappingElement
+     * @return
+     */
+    public static Mapping parseMappingElement(ConfigTree mappingElement)
+    {
+        Mapping mapping = new Mapping();
+        mapping.setEsb(mappingElement.getAttribute(Constants.ESB_VARNAME_TAG));
+        mapping.setBpm(mappingElement.getAttribute(Constants.BPM_VARNAME_TAG));
+        mapping.setDefaultValue(mappingElement.getAttribute(Constants.DEFAULT_VALUE_TAG));
+        mapping.setIsProcessScope(Boolean.parseBoolean(mappingElement.getAttribute(Constants.PROCESS_SCOPE_ATTR)));
+        if (log.isDebugEnabled()) log.debug(mappingElement.toXml() + ":" + mapping);
+        return mapping;
+    }
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Mapping.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -19,65 +19,38 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-
 package org.jboss.soa.esb.services.jbpm.actionhandlers;
 
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.log4j.Logger;
-import org.dom4j.Element;
 import org.dom4j.tree.DefaultElement;
+import org.jboss.internal.soa.esb.util.LRUCache;
 import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.client.ServiceInvoker;
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.message.Body;
 import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.message.mapping.ObjectMapper;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.cmd.MessageHelper;
-import org.jbpm.context.exe.ContextInstance;
+import org.jboss.soa.esb.services.jbpm.JBpmCallbackHelper;
+import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
 import org.jbpm.graph.def.ActionHandler;
-import org.jbpm.graph.def.Node;
-import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-
 /**
  * 
- * Send messages to ESB services from jBPM applications, and optionally wait for
- * response. <li/>esbCategoryName - for ESB registry lookup <li/>esbServiceName
- * &nbsp; - for ESB registry lookup
+ * Send messages to ESB services from jBPM applications, and leaves the node
+ * in a wait state, waiting for a call back.
+ * 
+ * <li/>esbCategoryName - for ESB registry lookup 
+ * <li/>esbServiceName - for ESB registry lookup
  * <li>millisToWaitForResponse - if a value > 0 is supplied, a response will be
  * expected from the ESB service and maximum wait time will be set accordingly.
  * If response is not received, a CourierTimeoutException will be thrown </li>
  * 
  * @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
- * 
+ * @author <a href="mailto:kstam at jboss.com">Kurt T Stam</a>
  */
-
 public class EsbActionHandler implements ActionHandler
 {
-    public static final String OUTGOING_VARS_TAG = "jbpmToEsbVars";
+    private static final long serialVersionUID = 2L;
 
-    public static final String RETURN_VARS_TAG = "returnVars";
-
-    public static final String MAPPING_TAG = "mapping";
-
-    public static final String JBPM_NAME_ATTR = "jbpm";
-
-    public static final String ESB_NAME_ATTR = "esb";
-
-    public static final String PROCESS_SCOPE_ATTR = "process-scope";
-
-    private static final long serialVersionUID = 1L;
-
     public String esbCategoryName;
 
     public String esbServiceName;
@@ -86,192 +59,57 @@
 
     public Boolean globalProcessScope;
 
-    public DefaultElement jbpmToEsbVars;
+    public DefaultElement bpmToEsbVars;
 
-    public DefaultElement returnVars;
+    public DefaultElement esbToBpmVars;
 
-    protected Logger _logger = Logger.getLogger(getClass());
+    private transient Logger logger = Logger.getLogger(getClass());
+    
+    private transient JBpmCallbackHelper jBpmCallbackHelper = new JBpmCallbackHelper();
+    
+    private transient LRUCache<String, ServiceInvoker> siCache = new LRUCache<String, ServiceInvoker>(20);
 
-    protected Map<String, String> _outVarMapping;
-
-    protected Map<String, String> _retVarMapping;
-
-    protected transient Token _token;
-
     public void execute (ExecutionContext executionContext) throws Exception
     {
-    	_token = executionContext.getToken();
-    
-    	Message request = getMessageTemplate();
-    	varsToRequest(request);
-    	if (null == millisToWaitForResponse || millisToWaitForResponse < 1)
-    	{
-    	    ServiceInvoker invoker = new ServiceInvoker(esbCategoryName,
-    		    esbServiceName);
-    	    invoker.deliverAsync(request);
-    	    return;
-    	}
-    
-    	Message response = null;
-    	if ("MOCK_CATEGORY".equals(esbCategoryName)
-    		&& "MOCK_SERVICE".equals(esbServiceName)) {
-    	    response = request;
-    	} else {
-    	    ServiceInvoker invoker = new ServiceInvoker(esbCategoryName,
-    		    esbServiceName);
-    	    response = invoker.deliverSync(request, millisToWaitForResponse);
-    	}
-    	if (null != response) {
-    	    varsFromResponse(response);
-            if (_token.getNode()!=null) {
-                // _token.signal(); // this is required since the response is sync
-            	executionContext.getNode().leave(executionContext);
-            }
+        //validation
+        if (null == esbCategoryName)
+            throw new ConfigurationException(
+                "Service category (esbCategoryName element) must not be null");
+        if (null == esbServiceName)
+           throw new ConfigurationException(
+                "Service name (esbServiceName element) must not be null");
+        if (millisToWaitForResponse !=null) {
+            logger.info("millisToWaitForResponse is no longer a valid element, please use a " +
+                    "jBPM timer for this node instead.");
+        }
+        //Create the ESB Message
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+    	Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, globalProcessScope, executionContext);
+        //Set the replyTo to the JBpmCallback Service
+        EPR replyTo = jBpmCallbackHelper.createReplyTo(esbToBpmVars.asXML(), globalProcessScope, executionContext);
+        message.getHeader().getCall().setReplyTo(replyTo);
+        //Sending the message on its way
+        if (logger.isDebugEnabled()) logger.debug("Created ESB message=" + message);
+        getServiceInvoker().deliverAsync(message);
+        logger.debug("Message send successfully");
+    }
+    /**
+     * Caches the most recently used ServiceInvokers.
+     * 
+     * @return a ServiceInvoker for the current esbService and esbCategoryName.
+     * @throws MessageDeliverException
+     */
+    private ServiceInvoker getServiceInvoker() throws MessageDeliverException
+    {
+        String key = esbCategoryName + esbServiceName;
+        if (siCache.containsKey(key)) {
+            return siCache.get(key);
         } else {
-            throw new MessageDeliverException("The response from jBPM should not be null");
+            ServiceInvoker invoker = new ServiceInvoker(esbCategoryName,  esbServiceName);
+            siCache.put(key, invoker);
+            return invoker;
         }
     }
 
-    protected void varsToRequest (Message request) throws Exception
-    {
-    	ContextInstance ctxInstance = _token.getProcessInstance()
-    		.getContextInstance();
-    	Body body = request.getBody();
-    	boolean gblPrcScope = (null == globalProcessScope) ? false
-    		: globalProcessScope;
-    	if (null == jbpmToEsbVars)
-    	{
-    	    Map map = (gblPrcScope) ? ctxInstance.getVariables() : ctxInstance
-    		    .getVariables(_token);
-    	    if (null != map)
-    		for (Iterator iter = map.entrySet().iterator(); iter.hasNext();)
-    		{
-    		    Map.Entry curr = (Map.Entry) iter.next();
-    		    body.add(curr.getKey().toString(), curr.getValue());
-    		}
-    	    return;
-    	}
-    	List list = jbpmToEsbVars.elements(MAPPING_TAG);
-    	// do nothing if empty list
-    	if (list.size() < 1)
-    	    return;
     
-    	for (Object iter : list)
-    	{
-    	    Element curr = (Element) iter;
-    	    String jbpmKey = curr.attributeValue(JBPM_NAME_ATTR);
-    	    String esbKey = curr.attributeValue(ESB_NAME_ATTR);
-    	    String processScope = curr.attributeValue(PROCESS_SCOPE_ATTR);
-    	    boolean isPrcScope = (null == processScope) ? gblPrcScope : Boolean
-    		    .parseBoolean(processScope);
-    	    Object obj = (isPrcScope) ? ctxInstance.getVariable(jbpmKey)
-    		    : ctxInstance.getVariable(jbpmKey, _token);
-    	    if (null != obj) {
-                ObjectMapper mapper = new ObjectMapper();
-                mapper.setObjectOnMessage(request, esbKey, obj);
-    	    }
-    	}
-    } // ________________________________
-
-    protected void varsFromResponse (Message response) throws Exception
-    {
-    	ContextInstance ctxInstance = _token.getProcessInstance()
-    		.getContextInstance();
-    	Body body = response.getBody();
-    	boolean gblPrcScope = (null == globalProcessScope) ? false
-    		: globalProcessScope;
-    	if (null == returnVars)
-    	{
-    	    Map map = (gblPrcScope) ? ctxInstance.getVariables() : ctxInstance
-    		    .getVariables(_token);
-    	    if (null != map)
-    		for (Iterator iter = map.keySet().iterator(); iter.hasNext();)
-    		{
-    		    String key = iter.next().toString();
-    		    Object obj = body.get(key);
-    		    if (null != obj)
-    		    {
-    			if (gblPrcScope)
-    			    ctxInstance.setVariable(key, obj);
-    			else
-    			    ctxInstance.setVariable(key, obj, _token);
-    		    }
-    		}
-    	    return;
-    	}
-    	List list = returnVars.elements(MAPPING_TAG);
-    	// do nothing if empty list
-    	if (list.size() < 1)
-    	    return;
-    
-    	for (Object iter : list)
-    	{
-    	    Element curr = (Element) iter;
-    	    String jbpmVar = curr.attributeValue(JBPM_NAME_ATTR);
-    	    String esbVar = curr.attributeValue(ESB_NAME_ATTR);
-    	    String processScope = curr.attributeValue(PROCESS_SCOPE_ATTR);
-    	    boolean isPrcScope = (null == processScope) ? gblPrcScope : Boolean
-    		    .parseBoolean(processScope);
-    	    Object obj = (Constants.BODY_CONTENT_VARIABLE_NAME.equals(esbVar)) ? body
-    		    .get()
-    		    : body.get(esbVar);
-    	    Object oldVal = (isPrcScope) ? ctxInstance.getVariable(jbpmVar)
-    		    : ctxInstance.getVariable(jbpmVar, _token);
-    	    if (null == oldVal) {
-        		if (null != obj) {
-        		    if (isPrcScope)
-        			ctxInstance.createVariable(jbpmVar, obj);
-        		    else
-        			ctxInstance.createVariable(jbpmVar, obj, _token);
-        		}
-    	    } else {
-        		if (null == obj) {
-        		    if (isPrcScope)
-        			ctxInstance.deleteVariable(jbpmVar);
-        		    else
-        			ctxInstance.deleteVariable(jbpmVar, _token);
-        		} else {
-        		    if (isPrcScope)
-        			ctxInstance.setVariable(jbpmVar, obj);
-        		    else
-        			ctxInstance.setVariable(jbpmVar, obj, _token);
-        		}
-    	    }
-    	}
-    } // ________________________________
-
-    protected Message getMessageTemplate () throws Exception
-    {
-	if (null == esbCategoryName)
-	    throw new ConfigurationException(
-		    "Service category (esbCategoryName element) must not be null");
-	if (null == esbServiceName)
-	    throw new ConfigurationException(
-		    "Service name (esbServiceName element) must not be null");
-
-	Message template = MessageFactory.getInstance().getMessage();
-	Call call = template.getHeader().getCall();
-	call.setMessageID(new URI(UUID.randomUUID().toString()));
-
-	MessageHelper.setLongValue(template, Constants.TOKEN_ID, _token.getId());
-	Node node = _token.getNode();
-	if (null != node)
-        MessageHelper.setStringValue(template, Constants.CURRENT_NODE_NAME, node
-		    .getName());
-
-	ProcessInstance instance = _token.getProcessInstance();
-    MessageHelper.setLongValue(template, Constants.PROCESS_INSTANCE_ID, instance
-		.getId());
-
-	ProcessDefinition process = instance.getProcessDefinition();
-    MessageHelper.setObjectValue(template, Constants.PROCESS_DEFINITION_NAME,
-		process.getName());
-    MessageHelper.setIntValue(template, Constants.PROCESS_DEFINITION_VERSION,
-		process.getVersion());
-    MessageHelper.setLongValue(template, Constants.PROCESS_DEFINITION_ID, process
-		.getId());
-
-	return template;
-    } // ________________________________
-
 }

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.actionhandlers;
+import org.apache.log4j.Logger;
+import org.dom4j.tree.DefaultElement;
+import org.jboss.internal.soa.esb.util.LRUCache;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+
+/**
+ * 
+ * Sends ESB messages to ESB services from jBPM in an asynchronous way
+ * 
+ * <li/>esbCategoryName - for ESB registry lookup 
+ * <li/>esbServiceName - for ESB registry lookup
+ * 
+ * @author <a href="mailto:kurt.stam at jboss.com">Kurt Stam</a>
+ * 
+ */
+public class EsbNotifier implements ActionHandler
+{
+    private static final long serialVersionUID = 1L;
+    private transient Logger logger = Logger.getLogger(getClass());
+    private transient LRUCache<String, ServiceInvoker> siCache = new LRUCache<String, ServiceInvoker>(20);
+    /**
+     * The ESB Service Category Name, specified in the processdefinition.xml
+     */
+    public String esbCategoryName;
+    /**
+     * The ESB Service Name, specified in the processdefinition.xml
+     */
+    public String esbServiceName;
+    /**
+     * Default setting of the process scope, can be overriden by setting the
+     * process-scope attribute on the mapping element.
+     */
+    public Boolean globalProcessScope;
+    /**
+     * XML element to specify the mapping of variables from jBPM to ESB.
+     */
+    public DefaultElement jbpmToEsbVars;
+    /**
+     * Constructs an ESB Message and sends sends to the an ESB Service
+     * as defined in the processdefinition.xml.
+     */
+    public void execute (ExecutionContext executionContext) throws Exception
+    {
+        if (null == esbCategoryName) {
+            throw new ConfigurationException(
+                "Service category (esbCategoryName element) must not be null");
+        }
+        if (null == esbServiceName) {
+            throw new ConfigurationException(
+                "Service name (esbServiceName element) must not be null");
+        }
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+        Message message = mapper.mapFromJBpmToEsbMessage(jbpmToEsbVars, globalProcessScope, executionContext);
+        if (logger.isDebugEnabled()) logger.debug("Created ESB message=" + message);
+        getServiceInvoker().deliverAsync(message);
+        logger.debug("Message send successfully");
+    }
+    /**
+     * Caches the most recently used ServiceInvokers.
+     * 
+     * @return a ServiceInvoker for the current esbService and esbCategoryName.
+     * @throws MessageDeliverException
+     */
+    private ServiceInvoker getServiceInvoker() throws MessageDeliverException
+    {
+        String key = esbCategoryName + esbServiceName;
+        if (siCache.containsKey(key)) {
+            return siCache.get(key);
+        } else {
+            ServiceInvoker invoker = new ServiceInvoker(esbCategoryName,  esbServiceName);
+            siCache.put(key, invoker);
+            return invoker;
+        }
+    }
+
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -30,13 +30,14 @@
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.cmd.Command;
 import org.jboss.soa.esb.services.jbpm.cmd.CommandExecutor;
 import org.jboss.soa.esb.services.jbpm.cmd.MessageFacade;
 import org.jbpm.JbpmException;
 
 /**
 *
-* Extend CommandInterpreter by specializing it to a single jBPM command.
+* Processes a single jBPM command.
 * Part of the message content will be taken from constructor time configuration
 * (from the action configuration XML)
 * 
@@ -45,53 +46,45 @@
 */
 public class BpmProcessor implements ActionLifecycle
 {
-    protected MessageFacade _stuffer;
-    protected ConfigTree            _config;
+    protected MessageFacade messageFacade;
+    protected ConfigTree configTree;
     private static Logger _logger = Logger.getLogger(BpmProcessor.class);
 
-	public static final String COMMAND_ATTRIBUTE_TAG	= "command";
-
-    public void destroy() throws ActionLifecycleException {
+    public void destroy() throws ActionLifecycleException
+    {
         _logger.info("destroy() invoked");
     }
-    public void initialise() throws ActionLifecycleException {
-        _logger.info("initialise() invoked - config="+_config);
-        if (null==_config)
-            _config = new ConfigTree("autoGenerated");
+    public void initialise() throws ActionLifecycleException
+    {
+        _logger.info("initialise() invoked - config="+configTree);
+        try {
+            messageFacade   = MessageFacade.getFacade(configTree);
+        } catch (ConfigurationException ce) {
+            throw new ActionLifecycleException(ce.getMessage(), ce);
+        }
     }
     
-	public BpmProcessor(ConfigTree config) throws ConfigurationException
+	public BpmProcessor(ConfigTree configTree) throws ConfigurationException
 	{ 
-        _config = config;
-        checkMyParms();
+        this.configTree = configTree;
 	}
-	public Constants.OpCode getOpCode() { return _stuffer.getOpCode(); }
-	
-	protected void checkMyParms() throws ConfigurationException
-	{
-		_stuffer	= MessageFacade.getFacade(_config);
-	}
 
-	public void process(Message message)
+	public Message process(Message message)
 		throws ActionProcessingException
 	{
-		message.getBody().add(Constants.COMMAND_CODE,getOpCode().toString());
-		_stuffer.setJBPMContextParameters(message);
-        try
-        {
+		message.getBody().add(Constants.COMMAND_CODE, messageFacade.getOpCode().toString());
+		messageFacade.setJBPMContextParameters(message);
+        try {
             CommandExecutor commandExecutor = CommandExecutor.getInstance();
             String commandString  = (String)message.getBody().get(Constants.COMMAND_CODE);
-            commandExecutor.getCommand(commandString).execute(message);
+            Command command = commandExecutor.getCommand(commandString);
+            command.execute(message);
+        }catch (JbpmException jbpme) {
+                throw new ActionProcessingException(jbpme.getMessage(), jbpme);
+        } catch (ConfigurationException ce) {
+            throw new ActionProcessingException(ce.getMessage(), ce);
         }
-        catch (JbpmException e)
-        {
-            throw new ActionProcessingException(e.getMessage(), e);
-        }
-        catch (Exception e)
-        {
-            _logger.error(e.getMessage(), e);
-            throw new ActionProcessingException(e.getMessage(), e);
-        }
+        return message;
 	}
     
 }

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/JBpmCallback.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/JBpmCallback.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/JBpmCallback.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.actions;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionLifecycle;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.cmd.Command;
+import org.jboss.soa.esb.services.jbpm.cmd.CommandExecutor;
+import org.jbpm.JbpmException;
+
+/**
+* @author <a href="mailto:kurt.stam at jboss.com">Kurt Stam</a>
+*/
+public class JBpmCallback implements ActionLifecycle
+{
+    public static final String JBPM_CALL_BACK_SERVICE_NAME = "JBpmCallbackService";
+    protected ConfigTree  configTree;
+    private static Logger logger = Logger.getLogger(JBpmCallback.class);
+
+    public void destroy() throws ActionLifecycleException {
+        logger.info("destroy() invoked");
+    }
+    public void initialise() throws ActionLifecycleException {
+        logger.info("initialise() invoked - config="+configTree);
+    }
+    
+	public JBpmCallback(ConfigTree configTree) throws ConfigurationException
+	{ 
+        this.configTree = configTree;
+	}
+	/**
+     * 
+     * @param message
+     * @return
+     * @throws ActionProcessingException
+	 */
+	public Message process(Message message) throws ActionProcessingException
+	{     
+        //Send a callback signal to jBPM
+        try {
+            CommandExecutor commandExecutor = CommandExecutor.getInstance();
+            String commandString  = Constants.OpCode.CallbackCommand.toString();
+            Command command = commandExecutor.getCommand(commandString);
+            command.execute(message);
+        } catch (JbpmException jbpme) {
+            logger.error(jbpme.getMessage(), jbpme);
+        } catch (ConfigurationException ce) {
+            logger.error(ce.getMessage(), ce);
+        } catch (Throwable t) {
+            //TODO Kurt figure out if what we if and what we want to throw
+            logger.error(t.getMessage(), t);
+        }
+        return message;
+	}
+    
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/JBpmCallback.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -26,20 +26,23 @@
 import java.util.Map;
 
 import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.mapping.ObjectMapper;
 import org.jboss.soa.esb.message.mapping.ObjectMappingException;
 import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.JBpmCallbackException;
+import org.jboss.soa.esb.services.jbpm.JBpmCallbackHelper;
+import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
 import org.jbpm.JbpmException;
 import org.jbpm.command.CancelProcessInstanceCommand;
-import org.jbpm.command.CommandService;
 import org.jbpm.command.GetProcessInstanceCommand;
 import org.jbpm.command.NewProcessInstanceCommand;
 import org.jbpm.command.SignalCommand;
 import org.jbpm.command.StartProcessInstanceCommand;
-import org.jbpm.command.impl.CommandServiceImpl;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 
@@ -54,9 +57,9 @@
 {
     static CommandExecutor commandExecutor;
     
-    private static Logger _logger = Logger.getLogger(CommandExecutor.class);
-    private static JbpmConfiguration s_jbpmConfig;
-    private static CommandService   s_jbpmService;
+    private static Logger logger = Logger.getLogger(CommandExecutor.class);
+    private static JbpmConfiguration jbpmConfig;
+    private static CommandServiceImpl   jbpmService;
 	
     public static CommandExecutor getInstance() 
     {
@@ -66,36 +69,36 @@
         return commandExecutor;
     }
     
-	public Command getCommand(String commandString) throws Exception 
+	public Command getCommand(String commandString) throws ConfigurationException
 	{
 		Constants.OpCode opCode = Constants.OpCode.valueOf(commandString);
 		Command command = _values.get(opCode);
 		if (null==command)
-			throw new Exception(opCode.toString()+" not implemented,");
+			throw new ConfigurationException(opCode.toString()+" not implemented,");
 		return command;
 	}
 
     protected static final Command DEPLOY_PROCESS_DEF_EXECUTOR = new Command() 
     {
-        public void execute(Message request) throws JbpmException
+        public void execute(Message message) throws JbpmException
         {
-            Object obj = MessageHelper.getObjectValue(request, Constants.PROCESS_DEFINITION);
+            Object obj = MessageHelper.getObjectValue(message, Constants.PROCESS_DEFINITION);
             if (null==obj)
             {
                 obj = ProcessDefinition.parseXmlString
-                    ((String)MessageHelper.getObjectValue(request,Constants.PROCESS_DEFINITION_XML));
+                    ((String)MessageHelper.getObjectValue(message,Constants.PROCESS_DEFINITION_XML));
             }
             final ProcessDefinition def = (ProcessDefinition)obj;
-            _logger.debug("Deploying new process definition " + def.getName());
+            logger.debug("Deploying new process definition " + def.getName());
             executeJbpmCommand(new org.jbpm.command.Command()
             {
                 private static final long serialVersionUID = 1L;
                 ProcessDefinition _def = def;
                 
-                public Object execute(JbpmContext jbpmCtx) throws Exception 
+                public Object execute(JbpmContext jbpmCtx)
                 {
                     jbpmCtx.deployProcessDefinition(_def);
-                    _logger.info("Process Definition '" + def.getName() + "' is deployed.");
+                    logger.info("Process Definition '" + def.getName() + "' is deployed.");
                     return null;
                 }
             });
@@ -105,52 +108,84 @@
     
 	protected static final Command CANCEL_PROCESS_INSTANCE_EXECUTOR = new Command() 
 	{
-		public void execute(Message request) throws JbpmException
+		public void execute(Message message) throws JbpmException
 		{
-			long processId = MessageHelper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
-            _logger.debug("Cancel Process Instance Command for ProcessId=" + processId);
+			long processId = MessageHelper.getLongValue(message,Constants.PROCESS_INSTANCE_ID);
+            logger.debug("Cancel Process Instance Command for ProcessId=" + processId);
 			executeJbpmCommand(new CancelProcessInstanceCommand(processId));
 		}
 	};
 
 	protected static final Command SIGNAL_EXECUTOR=new Command()
 	{
-		public void execute(Message request) throws JbpmException
+		public void execute(Message message) throws JbpmException
 		{
 			SignalCommand command = new SignalCommand();
-			Long tokenId = MessageHelper.getLongValue(request,Constants.TOKEN_ID);		
+			Long tokenId = MessageHelper.getLongValue(message,Constants.TOKEN_ID);		
 			if (null== tokenId)
 			{
-                Long processId = MessageHelper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
-                _logger.debug("TokenId was not found, so try to obtain the root token from this process definition, " +
-                        " with ProcessId=" + processId);
+                Long processInstanceId = MessageHelper.getLongValue(message,Constants.PROCESS_INSTANCE_ID);
+                logger.debug("TokenId was not found, so try to obtain the root token from this process definition, " +
+                        " with ProcessId=" + processInstanceId);
 				// now try with the process id (use root token)
-				if (processId==null) {
+				if (processInstanceId==null) {
 					throw new JbpmException("Either <"+Constants.TOKEN_ID+"> or <"+Constants.PROCESS_INSTANCE_ID
 						+"> object must be specified in Message body to know who to signal");
                 }
 				ProcessInstance inst = (ProcessInstance)getJbpmCommandService()
-						.execute(new GetProcessInstanceCommand(processId));
+						.execute(new GetProcessInstanceCommand(processInstanceId));
 				tokenId	= inst.getRootToken().getId();
 			}
 			command.setTokenId(tokenId);
 			
-			String transition = MessageHelper.getStringValue(request, Constants.TRANSITION_NAME);
+			String transition = MessageHelper.getStringValue(message, Constants.TRANSITION_NAME);
 			if (null!=transition)
 				command.setTransitionName(transition);
-			
-			Map map = (Map)MessageHelper.getObjectValue(request, Constants.VARIABLE_VALUES);
+            
+			//TODO allow for precise setting
+			Map map = (Map)MessageHelper.getObjectValue(message, Constants.VARIABLE_VALUES);
 			if (null!=map) command.setVariables(map);
 			
-            _logger.debug("Signaling Process with TokenId=" + tokenId + ", Transition=" + transition + ", VariableMap=" + map);
+            logger.debug("Signaling Process with TokenId=" + tokenId + ", Transition=" + transition + ", VariableMap=" + map);
 			executeJbpmCommand(command);
 		}
 	};
+    
+    protected static final Command CALLBACK_EXECUTOR=new Command()
+    {
+        public void execute(Message message) throws JbpmException
+        {
+            SignalCommand command = new SignalCommand();
+            EPR toEPR = message.getHeader().getCall().getTo();
+            JBpmCallbackHelper jBpmCallbackHelper = new JBpmCallbackHelper();
+            try {
+                long tokenId = jBpmCallbackHelper.checkCurrentState(getJbpmCommandService(), toEPR);
+                command.setTokenId(tokenId);
+                
+//              Map the variables
+                String esbToBpmXml = toEPR.getAddr().getExtensionValue(Constants.ESB_TO_BPM_VARS_TAG);
+                JBpmObjectMapper mapper = new JBpmObjectMapper();
+                //Obtaining the VariableMap that is going to be set callback command
+                Map<String,Object> variableMap = mapper.mapFromEsbMessageToJBpmMap(message, esbToBpmXml);
+                if (null!=variableMap) command.setVariables(variableMap);
+                //By default we will not include a named transtion, so it will use the default transition
+                //However this can be overriden if needed, by setting the following variable.
+                String transition = MessageHelper.getStringValue(message, Constants.TRANSITION_NAME);
+                if (null!=transition) command.setTransitionName(transition);
+                logger.debug("Signaling Process with TokenId=" + tokenId + ", Transition=" + transition + ", VariableMap=" + variableMap);
+                executeJbpmCommand(command);
+            } catch (JBpmCallbackException jbce) {
+                throw new JbpmException(jbce.getMessage(), jbce);
+            } catch (ConfigurationException ce) {
+                throw new JbpmException(ce.getMessage(), ce);
+            }
+        }
+    };
 
-	
 	protected static Map<Constants.OpCode,Command> _values = new HashMap<Constants.OpCode,Command>();	
 	static
 	{
+        _values.put(Constants.OpCode.CallbackCommand             ,CALLBACK_EXECUTOR);
 		_values.put(Constants.OpCode.CancelProcessInstanceCommand,CANCEL_PROCESS_INSTANCE_EXECUTOR);
         _values.put(Constants.OpCode.SignalCommand               ,SIGNAL_EXECUTOR);
         _values.put(Constants.OpCode.DeployProcessDefinition     ,DEPLOY_PROCESS_DEF_EXECUTOR);
@@ -171,7 +206,7 @@
 			perform(request,_start);
 		}
 		
-		private void perform(Message request, boolean start) throws JbpmException
+		private void perform(Message request, boolean start)
 		{
             ObjectMapper objectMapper = new ObjectMapper();
             NewProcessInstanceCommand command = null;
@@ -202,7 +237,7 @@
                     String key = String.valueOf(objectMapper.getObjectFromMessage(request, keyPath));
                     command.setKey(key);
                 } catch (ObjectMappingException e) {
-                    _logger.error("Could not locate key " + e.getMessage(), e);
+                    logger.error("Could not locate key " + e.getMessage(), e);
                 }
             }
 			String actorId=MessageHelper.getStringValue(request, Constants.ACTOR_ID);
@@ -212,31 +247,34 @@
 			Map<String, Object> variables = MessageHelper.getVariablesMap(request, Constants.VARIABLE_VALUES);
 			if (null!=variables) command.setVariables(variables);
             
-            _logger.debug("New process instance with command=" + command);
+            logger.debug("New process instance with command=" + command);
 			executeJbpmCommand(command);
 		}
 	}
     
-    private static void executeJbpmCommand(org.jbpm.command.Command command) throws JbpmException
+    private static void executeJbpmCommand(org.jbpm.command.Command command)
     {
-        if (_logger.isDebugEnabled()) {
-            _logger.debug(command);
+        if (logger.isDebugEnabled()) {
+            logger.debug(command);
         }
-        getJbpmCommandService().execute(command);
+        try {
+            getJbpmCommandService().execute(command);
+        } finally {
+            jbpmService.close();
+        }
     }
     
     /**
-     * Encapsulate obtention of jBPM CommandService here
-     * <br/>If it can't be cached, we only need to change this method.
+     * Encapsulate obtention of jBPM CommandService.
      * @return CommandService
      */
-    public static CommandService getJbpmCommandService()
+    public static CommandServiceImpl getJbpmCommandService()
     {
-        if (null== s_jbpmService) {
-                s_jbpmConfig = JbpmConfiguration.getInstance();
-                s_jbpmService = new CommandServiceImpl(s_jbpmConfig);
+        if (null== jbpmService) {
+                jbpmConfig = JbpmConfiguration.getInstance();
+                jbpmService = new CommandServiceImpl(jbpmConfig);
         }
-        return s_jbpmService;
+        return jbpmService;
     }
     
     

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandServiceImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandServiceImpl.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandServiceImpl.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,91 @@
+/**
+ * 
+ */
+package org.jboss.soa.esb.services.jbpm.cmd;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+import java.io.Serializable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
+import org.jbpm.command.Command;
+import org.jbpm.command.CommandService;
+
+/**
+ * Provide services for accessing the jBPM engine. Access is currently provided
+ * through a set of {@link org.jbpm.command.Command} derived operations.
+ * 
+ * @author Jim Rigsbee, Tom Baeyens
+ */
+public class CommandServiceImpl implements CommandService, Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected JbpmConfiguration jbpmConfiguration = null;
+  JbpmContext jbpmContext = null;
+
+  /**
+   * Establish an instance of the command service with a particular jBPM
+   * configuration which provides connectivity to the jBPM engine and its
+   * related services including the persistence manager.
+   * 
+   * @param jbpmConfiguration
+   *          jBPM Configuration
+   */
+  public CommandServiceImpl(JbpmConfiguration jbpmConfiguration) {
+    this.jbpmConfiguration = jbpmConfiguration;
+  }
+
+  /**
+   * Executes command based on its current context. Each command contains the
+   * appropriate context information such as token, process instance, etc. to
+   * insure that the operation is carried out on the proper graph object.
+   * 
+   * @param command
+   *          jBPM engine command to execute
+   */
+  public Object execute(Command command) {
+    Object result = null;
+    if (jbpmContext==null) {
+        jbpmContext = jbpmConfiguration.createJbpmContext();
+    }
+    try {
+      log.debug("executing " + command);
+      result = command.execute(jbpmContext);
+    } catch (Exception e) {
+      throw new JbpmException("couldn't execute "+command, e);
+    }
+    return result;
+  }
+  
+  public void close(){
+       jbpmContext.close();
+       jbpmContext=null;
+  }
+
+  private static final Log log = LogFactory.getLog(CommandServiceImpl.class);
+}
+


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandServiceImpl.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/ConfigUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/ConfigUtil.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/ConfigUtil.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.cmd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Mapping;
+
+public class ConfigUtil 
+{
+	static List<Mapping> getMappingConfig(ConfigTree tree)
+		throws ConfigurationException
+	{   
+        List<Mapping> mappingList = new ArrayList<Mapping>();
+        ConfigTree[] esbToBpm = tree.getChildren(Constants.MAPPING_TAG);
+        if (esbToBpm != null) {
+            for (ConfigTree mappingElement : esbToBpm) {
+                Mapping mapping = Mapping.parseMappingElement(mappingElement);
+                mappingList.add(mapping);
+            }
+        }
+		return mappingList;
+	}
+
+	static String[] actorsFromConfig(ConfigTree tree, boolean acceptValue)
+		throws ConfigurationException
+	{
+		String tag = Constants.ACTORS_TAG;
+		ConfigTree[] childs = tree.getChildren(tag);
+		if (null==childs || childs.length<1)
+			return null;
+		if (childs.length>1)
+			throw new ConfigurationException("Only one <"+tag
+					+"> element allowed in configuration");
+		
+		tag = Constants.ONE_ACTOR_TAG;
+		childs	= childs[0].getChildren(tag);
+		if (null==childs || childs.length<1)
+			throw new ConfigurationException("At least one <"+tag
+					+"> child element required for <"+Constants.VARIABLES_TAG+">");
+		String[] ret = new String[childs.length];
+		int i1=0;
+		for (ConfigTree curr: childs)
+		{
+			String name		= curr.getAttribute("name");
+			if (null==name)
+			{
+				throw new ConfigurationException
+				("You must specify the 'name' attribute for all <"
+						+tag+"> element");
+			}
+			ret[i1++]	= name;
+		}
+		return ret;
+	}
+
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/ConfigUtil.java
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/FacadeUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/FacadeUtil.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/FacadeUtil.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.services.jbpm.cmd;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.mapping.ObjectMapper;
-import org.jboss.soa.esb.message.mapping.ObjectMappingException;
-import org.jboss.soa.esb.services.jbpm.Constants;
-
-public class FacadeUtil 
-{
-	static Boolean booleanFromConfig(ConfigTree tree, String tag) 
-		throws ConfigurationException
-	{
-		ConfigTree[] childs = tree.getChildren(tag);
-		if (null==childs || childs.length<1)
-			return null;
-		if (childs.length>1)
-			throw new ConfigurationException("Only one <"+tag
-					+"> element allowed in configuration");
-		try
-		{
-			return Boolean.parseBoolean(childs[0].getAttribute("value"));
-		}
-		catch (Exception e)
-		{
-			throw new ConfigurationException("<"+tag
-					+"> must have a 'value' attribute containing 'true' or 'false'");
-		}
-	} //________________________________
-
-	static VariableMapping variablesFromConfig(ConfigTree tree, boolean acceptValue)
-		throws ConfigurationException
-	{   
-        VariableMapping ret = new VariableMapping();
-        ConfigTree[] objectList = tree.getChildren(Constants.OBJECT_PATH_TAG);
-        if (objectList != null) {
-            for (ConfigTree curr : objectList) {
-                String esbName  = curr.getAttribute(Constants.ESB_VARNAME_TAG);
-                String jbpmName = curr.getAttribute(Constants.JBPM_VARNAME_TAG);
-                String value    = curr.getAttribute("value");
-                ret.setVariable(esbName, jbpmName, value);
-            }
-        }
-		return ret;
-	}
-
-	static String[] actorsFromConfig(ConfigTree tree, boolean acceptValue)
-		throws ConfigurationException
-	{
-		String tag = Constants.ACTORS_TAG;
-		ConfigTree[] childs = tree.getChildren(tag);
-		if (null==childs || childs.length<1)
-			return null;
-		if (childs.length>1)
-			throw new ConfigurationException("Only one <"+tag
-					+"> element allowed in configuration");
-		
-		tag = Constants.ONE_ACTOR_TAG;
-		childs	= childs[0].getChildren(tag);
-		if (null==childs || childs.length<1)
-			throw new ConfigurationException("At least one <"+tag
-					+"> child element required for <"+Constants.VARIABLES_TAG+">");
-		String[] ret = new String[childs.length];
-		int i1=0;
-		for (ConfigTree curr: childs)
-		{
-			String name		= curr.getAttribute("name");
-			if (null==name)
-			{
-				throw new ConfigurationException
-				("You must specify the 'name' attribute for all <"
-						+tag+"> element");
-			}
-			ret[i1++]	= name;
-		}
-		return ret;
-	}
-
-	
-	static void populateVariableValues (Message message, VariableMapping mapping)
-	{
-		if (null==mapping || mapping.size()<1)
-			return;
-
-		Body body	= message.getBody();
-		HashMap<String,Object> map = new HashMap<String, Object>();
-		for (Map.Entry<String, Object> curr: mapping.esbVariables().entrySet())
-		{
-			String esbName	= curr.getKey();
-			String jbpmName = mapping.getJbpmName(esbName);
-            
-            ObjectMapper objectMapper = new ObjectMapper();
-            Object value = null;
-            try {
-                value = objectMapper.getObjectFromMessage(message, esbName);
-            } catch (ObjectMappingException ome) {
-                throw new IllegalArgumentException(ome.getMessage(), ome);
-            }   
-			// if object not found in body, use default value (from config)
-			if (null==value)
-				value = curr.getValue();
-			// only put it in the map if it's not null
-			if (null!=value)
-				map.put(jbpmName, value);
-		}
-		body.add(Constants.VARIABLE_VALUES, map);
-	}
-
-}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/MessageFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/MessageFacade.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/MessageFacade.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -7,7 +7,6 @@
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
 
 /**
  * @author kstam
@@ -36,11 +35,11 @@
     throws ConfigurationException, UnsupportedOperationException
     {
         Constants.OpCode opCode = null;
-        String sAux = config.getRequiredAttribute(BpmProcessor.COMMAND_ATTRIBUTE_TAG);
-        try { opCode = Constants.OpCode.valueOf(sAux); }
-        catch (IllegalArgumentException e)
-        {
-            throw new ConfigurationException("Attribute '"+BpmProcessor.COMMAND_ATTRIBUTE_TAG+"' has an invalid value"
+        String sAux = config.getRequiredAttribute(Constants.COMMAND_CODE_TAG);
+        try { 
+            opCode = Constants.OpCode.valueOf(sAux);
+        } catch (IllegalArgumentException e) {
+            throw new ConfigurationException("Attribute '"+Constants.COMMAND_CODE_TAG+"' has an invalid value"
                         +"- see CommandVehicle.Operation enum for possible values");
         }
         

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -22,11 +22,16 @@
 
 package org.jboss.soa.esb.services.jbpm.cmd;
 
+import java.util.List;
+import java.util.Map;
+
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.message.Body;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
+import org.jboss.soa.esb.services.jbpm.Mapping;
 import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
 
 /**
@@ -51,17 +56,18 @@
 		_actor		= config.getAttribute(Constants.ONE_ACTOR_TAG);
 		_processName= config.getAttribute(Constants.PROCESS_DEFINITION_NAME_TAG);
         _keyPath    = config.getAttribute(Constants.KEY_TAG);
-		String aux	= config.getAttribute(Constants.PROCESS_DEFINITION_ID_TAG);
-		if (null!=aux)
-			try {_processId = Long.parseLong(aux); }
-			catch(NumberFormatException e)
-			{
+		String pId	= config.getAttribute(Constants.PROCESS_DEFINITION_ID_TAG);
+		if (null!=pId) {
+			try {
+                _processId = Long.parseLong(pId); 
+            } catch(NumberFormatException e) {
 				throw new ConfigurationException("Invalid value for '"+Constants.PROCESS_DEFINITION_ID_TAG+"'");
 			}
-		_variables	= FacadeUtil.variablesFromConfig(config, true);
-		
-		if (_start)
+        }
+        _esbToBpm	= ConfigUtil.getMappingConfig(config);
+		if (_start) {
 			_transitionName	= config.getAttribute(Constants.TRANSITION_NAME_TAG);
+        }
 	}
 	
 	public void setJBPMContextParameters(Message message) 
@@ -77,8 +83,9 @@
 			body.add(Constants.PROCESS_DEFINITION_ID	,_processId);
 		if (null!=_transitionName)
 			body.add(Constants.TRANSITION_NAME, _transitionName);
-
-		FacadeUtil.populateVariableValues(message,_variables);
+		Map<String,Object> variableMap = _mapper.mapFromEsbMessageToJBpmMap(message,_esbToBpm);
+        if (null!=variableMap)
+            body.add(Constants.VARIABLE_VALUES, variableMap);
 	}
 
 	boolean			_start;
@@ -87,5 +94,6 @@
 	String			_processName;
 	String			_transitionName;
 	Long			_processId;
-	VariableMapping _variables;
+	List<Mapping>   _esbToBpm;
+    JBpmObjectMapper _mapper = new JBpmObjectMapper();
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/SignalFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/SignalFacade.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/SignalFacade.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -22,11 +22,16 @@
 
 package org.jboss.soa.esb.services.jbpm.cmd;
 
+import java.util.List;
+import java.util.Map;
+
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.message.Body;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
+import org.jboss.soa.esb.services.jbpm.Mapping;
 import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
 
 /**
@@ -43,7 +48,7 @@
 	public SignalFacade(ConfigTree config) throws ConfigurationException
 	{
 		_transition		= config.getAttribute(Constants.TRANSITION_NAME_TAG);
-		_variables		= FacadeUtil.variablesFromConfig(config, false);
+        _esbToBpm       = ConfigUtil.getMappingConfig(config);
 	}
 	
 	public void setJBPMContextParameters(Message message) 
@@ -51,9 +56,12 @@
 		Body body = message.getBody();
 		if (null!=_transition)
 			body.add(Constants.TRANSITION_NAME, _transition);
-		FacadeUtil.populateVariableValues(message, _variables);
+        Map<String,Object> variableMap = _mapper.mapFromEsbMessageToJBpmMap(message, _esbToBpm);
+        if (null!=variableMap)
+            body.add(Constants.VARIABLE_VALUES, variableMap);
 	}
-
-	String			_transition;
-	VariableMapping _variables;
+    
+    String          _transition;
+    List<Mapping>   _esbToBpm;
+    JBpmObjectMapper _mapper = new JBpmObjectMapper();
 }

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMapping.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMapping.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMapping.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -1,66 +0,0 @@
-package org.jboss.soa.esb.services.jbpm.cmd;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.soa.esb.util.Util;
-
-/**
- * A container for variable names and values with access both by esb name and jbpm name.
- * 
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a> 
- *
- */
-public class VariableMapping
-{
-	// internal key is always esb name
-	private Map<String,Object> _values 		= new HashMap<String, Object>();
-	// map jbpm names to esb names
-	private Map<String,String> _jbpmNames 	= new HashMap<String, String>();
-	// map esb names to jbpm names
-	private Map<String,String> _esbNames 	= new HashMap<String, String>();
-
-	public int size()	{ return _values.size(); }
-	
-	private String setMapping(String esbName, String jbpmName)
-	{
-		if (Util.isNullString(esbName) && Util.isNullString(jbpmName))
-			throw new IllegalArgumentException("You must specify at least one valid variable name (esb or bpm)");
-		if (Util.isNullString(jbpmName))
-			jbpmName = getName(esbName);
-		if (Util.isNullString(esbName))
-			esbName = getName(jbpmName);
-		String oldMapping = _esbNames.get(jbpmName);
-		if (null!=oldMapping && !oldMapping.equals(jbpmName))
-			throw new IllegalArgumentException
-			("Illegal mapping esb=<"+esbName+"> was mapped to bpm=<"+oldMapping+ "> cannot remap to "+jbpmName);
-			
-		_esbNames	.put(esbName, jbpmName);
-		_jbpmNames	.put(jbpmName, esbName);
-		// Internally, esbName is the key to the variable values
-		return esbName;
-	}
-    
-    protected String getName(String path) 
-    {
-        String name = path;
-        int index = path.lastIndexOf(".");
-        if (index > 0) {
-            name = path.substring(index+1);
-        }
-        return name;
-    }
-
-	public void setVariable(String esbName, String jbpmName, Object value)
-	{
-		_values		.put(setMapping(esbName, jbpmName), value);
-	}
-	
-	public String getEsbName	 (String key) { return _jbpmNames.get(key); }
-	public String getJbpmName	 (String key) { return _esbNames.get(key); }
-
-	public Object getEsbVariable (String key) { return _values.get(key); }
-	public Object getJbpmVariable(String key) { return _values.get(_jbpmNames.get(key)); }
-	
-	public Map<String,Object> esbVariables()  { return _values; }
-}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/META-INF/jboss-esb.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/META-INF/jboss-esb.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -1,4 +1,34 @@
 <?xml version = "1.0" encoding = "UTF-8"?>
 <jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
-     
+     <!--  
+     		jbossesb internal services 
+     -->
+     <providers>
+     	  <!-- change the following element to jms-jca-provider to enable transactional context  -->
+          <jms-provider name="CallbackQueue-JMS-Provider" connection-factory="ConnectionFactory">          
+              <jms-bus busid="jBPMCallbackBus">
+                  <jms-message-filter
+                      dest-type="QUEUE"
+                      dest-name="queue/CallbackQueue"
+                  />
+              </jms-bus>
+          </jms-provider>
+      </providers>
+      
+	<services>   
+		<service category="JBossESB-Internal"
+				name="JBpmCallbackService"
+				description="Service which makes Callbacks into jBPM">
+			<listeners>
+				<jms-listener name="JMS-DCQListener"
+							busidref="jBPMCallbackBus"
+							maxThreads="1"
+				/>
+			</listeners>
+			<actions mep="OneWay">
+				<action name="action" class="org.jboss.soa.esb.services.jbpm.actions.JBpmCallback"/>
+			</actions>
+		</service>
+	</services>	
+		
 </jbossesb>

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbm-queue-service.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbm-queue-service.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+           name="jboss.esb.destination:service=Queue,name=CallbackQueue"
+           xmbean-dd="xmdesc/Queue-xmbean.xml">
+        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+    </mbean>
+</server>


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbm-queue-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbmq-queue-service.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbmq-queue-service.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.esb.destination:service=Queue,name=CallbackQueue">
+        <depends optional-attribute-name="DestinationManager">
+            jboss.mq:service=DestinationManager
+        </depends>
+    </mbean>
+</server>


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbmq-queue-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,249 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.dom4j.tree.DefaultElement;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * Tests the capabilities of the JBpmObjectMapper.
+ * 
+ * @author kstam
+ *
+ */
+public class JBpmObjectMapperTest 
+{
+    private static String PROCESS_DEF_XML = "JBpmObjectMapperTestProcessDefinition.xml";
+	private static Logger logger = Logger.getLogger(JBpmObjectMapperTest.class);
+    private static ProcessInstance processInstance = null;
+
+    @BeforeClass
+    public static void setup()
+    {
+        logger.info("Setting up jBPM");
+        //Extract a process definition from the processdefinition.xml file.
+        ProcessDefinition processDefinition 
+            = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
+        assertNotNull(processDefinition);
+        //Create an instance of the process definition.
+        processInstance = new ProcessInstance(processDefinition);
+        assertTrue(
+                "Instance is in start state", 
+                "start".equals(processInstance.getRootToken().getNode().getName()));
+    }
+
+    /**
+     * Tests obtaining variables from the jBPM variableMap and setting them on the EsbMessage.
+     * We are making sure the jBPM -> EsbMessage works using
+     *  
+     *  <pre>
+     *  &lt;jbpmToEsbVars&gt;
+     *      &lt;mapping jbpm="v1" esb="esbObj1" /&gt;
+     *      &lt;mapping jbpm="g2" esb="esbObj2" process-scope="true" /&gt;
+     *  &lt;/jbpmToEsbVars>
+     *  <pre>
+     *  
+     * @throws Exception
+     */
+    @Test
+	public void jBpmVariableMap() throws Exception
+	{    
+        SAXReader reader = new SAXReader();
+        Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+        Element element = document.getRootElement();
+        DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
+
+		String helloWorldTokenScope  = "Hello world token scope";
+        String helloWorldGlobalScope = "Hello world process-instance scope";
+		
+		Token token = processInstance.getRootToken();
+        processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
+        processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
+        ExecutionContext executionContext = new ExecutionContext(token);
+        
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+        
+        assertEquals(helloWorldTokenScope,String.valueOf(message.getBody().get("esbObj1")));
+        assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
+	}
+    /**
+     * Tests obtaining *no* variables from the jBPM variableMap.
+     *  
+     * @throws Exception
+     */
+    @Test
+    public void jBpmCompleteVariableMap() throws Exception
+    {    
+        //Let's NOT give a mapping, this should get us all the variables in the VariableMap.
+        DefaultElement jbpmToEsbVars = null;
+
+        String helloWorldTokenScope  = "Hello world token scope";
+        String helloWorldGlobalScope = "Hello world process-instance scope";
+        
+        Token token = processInstance.getRootToken();
+        processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
+        processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+        ExecutionContext executionContext = new ExecutionContext(token);
+        
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+        Message message = mapper.mapFromJBpmToEsbMessage(jbpmToEsbVars, Boolean.FALSE, executionContext);
+        assertEquals(message.getBody().getNames().length,0);
+    }
+    /**
+     * Tests obtaining *all* variables from the jBPM variableMap and setting them on the EsbMessage.
+     *  
+     * @throws Exception
+     */
+    @Test
+    public void jBpmGetNothingFromVariableMap() throws Exception
+    {    
+        SAXReader reader = new SAXReader();
+        Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+        Element element = document.getRootElement();
+        Element secondMiddleState = (Element) element.elements("state").toArray()[0];
+        DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
+
+        String helloWorldTokenScope  = "Hello world token scope";
+        String helloWorldGlobalScope = "Hello world process-instance scope";
+        
+        Token token = processInstance.getRootToken();
+        processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
+        processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+        ExecutionContext executionContext = new ExecutionContext(token);
+        
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+        //We should find 2 variables which are named just like their jBPM counterparts.
+        assertEquals(message.getBody().getNames().length,2);
+        assertEquals(String.valueOf(message.getBody().get("v1")),helloWorldTokenScope);
+        assertEquals(String.valueOf(message.getBody().get("g2")),helloWorldGlobalScope);
+    }
+    /**
+     * Tests obtaining info about the jBPM ExecutionContext, such as current token and node, transition etc.
+     * <PRE>
+     *      &lt;jbpmToEsbVars&gt;
+     *          &lt;mapping jbpm="token.id" esb="esbTokenId" /&gt;
+     *          &lt;mapping jbpm="token.name" esb="esbTokenName" /&gt;
+     *          &lt;mapping jbpm="node.name" esb="NodeName" /&gt;
+     *          &lt;mapping jbpm="node.id" esb="esbNodeId" /&gt;
+     *          &lt;mapping jbpm="node.leavingTransitions[0].name" esb="transName" /&gt;
+     *          &lt;mapping jbpm="processInstance.id" esb="piId" /&gt;
+                &lt;mapping jbpm="processInstance.version" esb="piVersion" /&gt;
+     *      &lt;/jbpmToEsbVars&gt;
+     * </PRE>
+     * @throws Exception
+     */
+    @Test
+    public void jBpmTokenInfo() throws Exception
+    {    
+        SAXReader reader = new SAXReader();
+        Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+        Element element = document.getRootElement();
+        Element secondMiddleState = (Element) element.elements("state").toArray()[1];
+        DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
+        
+        Token token = processInstance.getRootToken();
+        ExecutionContext executionContext = new ExecutionContext(token);
+        Node node = executionContext.getNode();
+        Transition transition = (Transition) node.getLeavingTransitions().get(0);
+        
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+        
+        assertEquals(message.getBody().getNames().length,6);
+        assertEquals(String.valueOf(String.valueOf(message.getBody().get("TokenId"))), String.valueOf(token.getId()));
+        //The token name is null.
+        assertNull(message.getBody().get("TokenName"));
+        //Get info about the node.
+        assertEquals(String.valueOf(String.valueOf(message.getBody().get("NodeName"))), String.valueOf(node.getName()));
+        assertEquals(String.valueOf(String.valueOf(message.getBody().get("esbNodeId"))), String.valueOf(node.getId()));
+        assertEquals(String.valueOf(String.valueOf(message.getBody().get("transName"))), String.valueOf(transition.getName()));
+        assertEquals(String.valueOf(String.valueOf(message.getBody().get("piId"))), String.valueOf(processInstance.getId()));
+        assertEquals(String.valueOf(String.valueOf(message.getBody().get("piVersion"))), String.valueOf(processInstance.getVersion()));
+        logger.info("Message=" + message);
+    }
+    /**
+     * Tests if the variableMapping can go roundtrip (via the callbackService code)
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void esbToJBpmAndBack() throws Exception
+    {
+        SAXReader reader = new SAXReader();
+        Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+        Element element = document.getRootElement();
+        DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
+        DefaultElement esbToBpmVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("esbToBpmVars");
+        
+        String helloWorldTokenScope  = "Hello world token scope";
+        String helloWorldGlobalScope = "Hello world process-instance scope";
+        
+        Token token = processInstance.getRootToken();
+        processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
+        processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+        ExecutionContext executionContext = new ExecutionContext(token);
+        
+        JBpmObjectMapper mapper = new JBpmObjectMapper();
+        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+        
+        //Setting up return mapping for the callback service.
+        JBpmCallbackHelper callbackHelper = new JBpmCallbackHelper();
+        EPR epr = callbackHelper.createReplyTo(esbToBpmVars.asXML(), Boolean.FALSE, executionContext);
+        String esbToBpmXml = epr.getAddr().getExtensionValue(Constants.ESB_TO_BPM_VARS_TAG);
+        
+        //Obtaining the VariableMap that is going to be set callback command
+        Map<String,Object> variableMap = mapper.mapFromEsbMessageToJBpmMap(message, esbToBpmXml);
+        logger.info(variableMap);
+        //Let's make sure that what we put in is going to make it roundtrip.
+        assertEquals(helloWorldTokenScope, variableMap.get("x1"));
+        assertEquals(helloWorldGlobalScope,variableMap.get("x2"));
+    }
+    
+    public static junit.framework.Test suite(){
+        return new JUnit4TestAdapter(JBpmObjectMapperTest.class);
+    }
+
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -22,59 +22,44 @@
 
 package org.jboss.soa.esb.services.jbpm.actionhandlers;
 
-import java.io.File;
+import static org.junit.Assert.assertTrue;
 
+import java.net.URI;
+
 import junit.framework.JUnit4TestAdapter;
-import junit.framework.TestCase;
 
 import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.addressing.EPR;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.graph.exe.Token;
-import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class EsbActionHandlerUnitTest extends TestCase 
+public class EsbActionHandlerUnitTest
 {
 
 	private static Class thisClass = EsbActionHandlerUnitTest.class;
 	static Logger 				_logger = Logger.getLogger(thisClass);
 
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(thisClass);
-    }
+    private static EPR epr1;
+    private static MockCourier courier1;
+    private static String MOCK_CATEGORY="MockCategory";
+    private static String MOCK_SERVICE ="MockService";
     
-    static File WORKDIR;
-    static
-    {
-    	String os = System.getProperty("os.name","").toLowerCase();
-    	String dflt = (os.indexOf("win")>=0) ? "/temp": "/tmp";
-    	WORKDIR	= new File(System.getProperty("java.io.tmpdir",dflt));
-    }
-
     @BeforeClass
-    public static void runBeforeAllTests()
+    public static void setup() throws Exception
     {
-        _logger.info("@BeforeClass invoked");
-    	try
-    	{
-    	}
-    	catch (Exception e)
-    	{
-    		e.printStackTrace();
-    		assertTrue(false);
-    	}
+        MockCourierFactory.install();
+        MockRegistry.install();
+        epr1 = new EPR(new URI("test1"));
+        courier1 = new MockCourier(true);
+        MockRegistry.register(MOCK_CATEGORY, MOCK_SERVICE, epr1, courier1);
     }
-
-
-    @AfterClass
-    public static void runAfterAllTests() throws Exception
-    {
-    	_logger.info("@AfterClass invoked");
-    }
-
+    
     @Test
 	public void testSimpleProcess() throws Exception 
 	{
@@ -97,21 +82,14 @@
 		instance.getContextInstance().createVariable("v1", varVal, token);
 		instance.getContextInstance().createVariable("g2", second);
 		instance.getContextInstance().createVariable("body", body.getBytes(),token);
+        
+        //Signal the token and the Mock Service will be called.
 		instance.signal();
-
-		assertTrue(
-				"Instance is in first state", 
-				instance.getRootToken().getNode().getName().equals("first"));
-
-		_logger.info("Instance Var x1= "+varVal);
-		assertTrue(varVal.equals(instance.getContextInstance().getVariable("x1")));
-		_logger.info("Token    Var x2= "+second);
-		assertTrue(second.equals(instance.getContextInstance().getVariable("x2",instance.getRootToken())));
-		_logger.info("Token    Var x3= "+body);
         
-        byte[] byteArray = (byte[]) instance.getContextInstance().getVariable("x3",instance.getRootToken());
-        String string = new String(byteArray);
-		assertEquals(body,string);
+        //the node is now in a wait state in the "first" state
+        assertTrue(
+                "Instance is in first state", 
+                instance.getRootToken().getNode().getName().equals("first"));
 
 		instance.signal();
 		assertTrue(
@@ -119,5 +97,10 @@
 				instance.getRootToken().getNode().getName().equals("end"));
 		assertTrue("Instance has ended", instance.hasEnded());
 	}
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(thisClass);
+    }
 
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -25,12 +25,15 @@
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.InputStream;
 
 import junit.framework.JUnit4TestAdapter;
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.services.jbpm.cmd.MessageHelper;
+import org.jboss.soa.esb.testutils.FileUtil;
+import org.jboss.soa.esb.util.ClassUtil;
 import org.jbpm.JbpmConfiguration;
 import org.junit.AfterClass;
 import org.junit.Test;
@@ -71,10 +74,12 @@
     {
         try
         {
-            String xml = JbpmTestUtil.stringFromFile("testDeployFromFile.xml");
+            InputStream in = ClassUtil.getResourceAsStream("testDeployFromFile.xml",getClass());
+            String xml = FileUtil.readStream(in);
             ConfigTree[] actions = ConfigTree.fromXml(xml).getChildren("action");
 
             BpmProcessor command = new BpmProcessor(actions[0]);
+            command.initialise();
             command.process(MessageHelper.commandMessageTemplate());
         }
         catch (Exception e)
@@ -90,10 +95,12 @@
 	{
 		try
 		{
-			String xml = JbpmTestUtil.stringFromFile("testSingleCommands.xml");
+            InputStream in = ClassUtil.getResourceAsStream("testSingleCommands.xml",getClass());
+            String xml = FileUtil.readStream(in);
 			ConfigTree[] actions = ConfigTree.fromXml(xml).getChildren("action");
 			int	index	= 0;
             BpmProcessor command = new BpmProcessor(actions[index++]);
+            command.initialise();
     		command.process(MessageHelper.commandMessageTemplate());
 		}
 		catch (Exception e)

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.services.jbpm.actions;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.util.ClassUtil;
-
-public class JbpmTestUtil 
-{
-	private static final Class thisClass = JbpmTestUtil.class;
-
-	public static String stringFromFile(String pFileName) throws IOException
-	{
-	    InputStream in = ClassUtil.getResourceAsStream(pFileName,thisClass);
-		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		byte[]ba = new byte[1000];
-		int iQ = -1;
-		while (-1<(iQ=in.read(ba)))
-			if (iQ>0)	out.write(ba,0,iQ);
-		in.close();
-		return out.toString();
-	}
-	
-	public static void copyFile(String resource, File target) throws IOException
-	{
-	    InputStream in = thisClass.getResourceAsStream(resource);
-		FileOutputStream out = new FileOutputStream(target);
-		byte[]ba = new byte[1000];
-		int iQ = -1;
-		while (-1<(iQ=in.read(ba)))
-			if (iQ>0)	out.write(ba,0,iQ);
-		out.close();
-		in.close();
-	}
-	
-	public static String dumpResponse(Message message, Constants.OpCode opCode)
-	{
-		StringBuilder sb = new StringBuilder("\nInvoked: ").append(opCode.toString()).append("\n");
-		if (null==message)
-			return sb.append(" - No response received").toString();
-		sb.append(getObject(message,Constants.RETURN_CODE));
-		sb.append(getObject(message,Constants.ERROR_MESSAGE));
-		sb.append(getObject(message,Constants.EXCEPTION));
-		sb.append(getObject(message,Constants.ACTOR_ID));
-		sb.append(getObject(message,Constants.ACTOR_NAMES_ARRAY));
-		sb.append(getObject(message,Constants.CURRENT_NODE_NAME));
-		sb.append(getObject(message,Constants.JBPM_RETURN_OBJECT));
-		sb.append(getObject(message,Constants.PROCESS_DEFINITION_NAME));
-		sb.append(getObject(message,Constants.PROCESS_DEFINITION_VERSION));
-		sb.append(getObject(message,Constants.PROCESS_INSTANCE_ID));
-		sb.append(getObject(message,Constants.TASK_INSTANCE_ID));
-		sb.append(getObject(message,Constants.TOKEN_ID));
-		sb.append(getObject(message,Constants.HAS_ENDED));
-		sb.append(getObject(message,Constants.BODY_CONTENT_VARIABLE_NAME));
-        sb.append(getObject(message,Constants.JBPM_LOG_MAP));
-        
-		return sb.append("_______________________________________________________________________")
-			.toString();		
-	}
-	
-	public static String getObject(Message message, String key)
-	{
-		Object obj = null;
-		if(Constants.BODY_CONTENT_VARIABLE_NAME.equals(key))
-		{
-			obj = message.getBody().get();
-			return "Message body content = "
-				+((null==obj) ? "<null>" : obj)
-				+"\n";
-		}
-		
-		obj = message.getBody().get(key);
-		if (null==obj)
-			return "";
-		if (!(obj instanceof Exception))
-		 return key+" = "+obj.toString()+"\n";
-		ByteArrayOutputStream ba = new ByteArrayOutputStream();
-		((Exception)obj).printStackTrace(new PrintStream(ba));
-		return key+" = "+obj.toString()+"\n"+ba.toString();
-	}
-	
-}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -7,10 +7,10 @@
 			actor="FrankSinatra"
 			key="body.key"
 			>
-				<object-path esb="BODY_CONTENT" bpm="theBody" value="DEF DEF DEF"/>
-				<object-path esb="body.eVar1" bpm="j1"  value="AAAbbb111" />
-				<object-path esb="eVar2" bpm="vJ22"  value="998877" />
-				<object-path esb="body.newVar" value="123" />
+				<mapping esb="BODY_CONTENT" bpm="theBody" default="DEF DEF DEF"/>
+				<mapping esb="body.eVar1" bpm="j1"  default="AAAbbb111" />
+				<mapping esb="eVar2" bpm="vJ22"  default="998877" />
+				<mapping esb="body.newVar" default="123" />
 	</action>
 
 	

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMappingUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMappingUnitTest.java	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/cmd/VariableMappingUnitTest.java	2007-12-07 20:14:15 UTC (rev 17104)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.jbpm.cmd;
-
-import static org.junit.Assert.assertEquals;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.jboss.soa.esb.services.jbpm.cmd.VariableMapping;
-import org.junit.Test;
-
-
-/**
- * @author kstam
- *
- */
-public class VariableMappingUnitTest 
-{
-
-    @Test
-    public void testGetName() 
-    {
-        VariableMapping mapper = new VariableMapping();
-        String path = "body.someobjectname";
-        String name = mapper.getName(path);
-        assertEquals("someobjectname",name);
-    }
-    
-    
-    
-    
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(VariableMappingUnitTest.class);
-    }
-}

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.jpg
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition 
+  xmlns="urn:jbpm.org:jpdl-3.1"
+  name="JBpmObjectMapperTestDefinition">
+   <start-state name="start">
+      <transition name="to_first_middle_state" to="first-middle">
+      	<action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+      		<esbCategoryName>MockCategory</esbCategoryName>
+      		<esbServiceName>MockService</esbServiceName>
+      		<bpmToEsbVars>
+      			<mapping bpm="v1" esb="esbObj1" />
+      			<mapping bpm="g2" esb="esbObj2" process-scope="true" />
+      		</bpmToEsbVars>
+      		<esbToBpmVars>
+      			<mapping esb="esbObj1" bpm="x1" process-scope="true" />
+      			<mapping esb="esbObj2" bpm="x2" />
+      		</esbToBpmVars>
+      	</action>
+      </transition>
+   </start-state>
+   <state name="first-middle">
+      <transition name="to_second_middle_state" to="second-middle">
+        <action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+      		<esbCategoryName>MockCategory</esbCategoryName>
+      		<esbServiceName>MockService</esbServiceName>
+      		<bpmToEsbVars/>
+      	</action>
+      </transition>
+   </state>
+   <state name="second-middle">
+      <transition name="to_end" to="end">
+        <action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+      		<esbCategoryName>MockCategory</esbCategoryName>
+      		<esbServiceName>MockService</esbServiceName>
+      		<bpmToEsbVars>
+      			<mapping bpm="token.id"                        esb="TokenId" />
+      			<mapping bpm="token.name"                      esb="TokenName" />
+      			<mapping bpm="node.name"                       esb="NodeName" />
+      			<mapping bpm="node.id"                         esb="esbNodeId" />
+      			<mapping bpm="node.leavingTransitions[0].name" esb="transName" />
+      			<mapping bpm="processInstance.id"              esb="piId" />
+      			<mapping bpm="processInstance.version"         esb="piVersion" />
+      		</bpmToEsbVars>
+      	</action>
+      </transition>
+   </state>
+   <end-state name="end"></end-state>
+</process-definition>
\ No newline at end of file


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/JBpmObjectMapperTestProcessDefinition.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.jpg
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.xml	2007-12-07 19:23:29 UTC (rev 17103)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/resources/testMappingDefinition.xml	2007-12-07 20:14:15 UTC (rev 17104)
@@ -6,19 +6,19 @@
    <start-state name="start">
       <transition name="to_state" to="first">
       	<action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
-      		<esbCategoryName>MOCK_CATEGORY</esbCategoryName>
-      		<esbServiceName>MOCK_SERVICE</esbServiceName>
+      		<esbCategoryName>MockCategory</esbCategoryName>
+      		<esbServiceName>MockService</esbServiceName>
       		<millisToWaitForResponse>1</millisToWaitForResponse>
-      		<jbpmToEsbVars>
-      			<mapping jbpm="v1" esb="esbObj1" />
-      			<mapping jbpm="g2" esb="esbObj2" process-scope="true" />
-      			<mapping jbpm="body" esb="BODY_CONTENT" />
-      		</jbpmToEsbVars>
-      		<returnVars>
-      			<mapping jbpm="x1" esb="esbObj1" process-scope="true" />
-      			<mapping jbpm="x2" esb="esbObj2" />
-      			<mapping jbpm="x3" esb="BODY_CONTENT" />
-      		</returnVars>
+      		<bpmToEsbVars>
+      			<mapping bpm="v1" esb="esbObj1" />
+      			<mapping bpm="g2" esb="esbObj2" process-scope="true" />
+      			<mapping bpm="body" esb="BODY_CONTENT" />
+      		</bpmToEsbVars>
+      		<esbToBpmVars>
+      			<mapping bpm="x1" esb="esbObj1" process-scope="true" default="esbObj1 not found"/>
+      			<mapping bpm="x2" esb="esbObj2" />
+      			<mapping bpm="x3" esb="BODY_CONTENT" />
+      		</esbToBpmVars>
       	</action>
       </transition>
     </start-state>




More information about the jboss-svn-commits mailing list