[jboss-svn-commits] JBL Code SVN: r21177 - in labs/jbossesb/trunk: product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 22 14:01:58 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-07-22 14:01:58 -0400 (Tue, 22 Jul 2008)
New Revision: 21177

Added:
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/deployment.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/jboss-esb.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbm-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbmq-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/jbpmLocalTest.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/test-jbpm-service.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/CounterAction.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalLogHandler.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServer.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServerMBean.java
Modified:
   labs/jbossesb/trunk/product/docs/ServicesGuide.odt
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CallbackCommand.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
   labs/jbossesb/trunk/qa/junit/build.xml
Log:
Support setting of local scope jBPM variables: JBESB-1843

Modified: labs/jbossesb/trunk/product/docs/ServicesGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java	2008-07-22 17:35:38 UTC (rev 21176)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -177,22 +177,7 @@
     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);
+        return mapFromEsbMessageToJBpmMap(message, getMappingList(esbToBpmXml));
     }
     /**
      * This 
@@ -223,7 +208,68 @@
         }
         return map;
     }
+    /**
+     * 
+     * @param message
+     * @param esbToBpmXml
+     * @return
+     */
+    public HashMap<Mapping,Object> mapFromEsbMessageToJBpmMapping(Message message, final String esbToBpmXml)
+    throws ConfigurationException
+    {
+        return mapFromEsbMessageToJBpmMapping(message, getMappingList(esbToBpmXml));
+    }
+    /**
+     * This 
+     * @param message
+     * @param token
+     * @throws Exception
+     */
+    public HashMap<Mapping,Object> mapFromEsbMessageToJBpmMapping(Message message, final List<Mapping> mappingList)
+    {
+        HashMap<Mapping,Object> map = new HashMap<Mapping, 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, value);
+        }
+        return map;
+    }
     
+    private List<Mapping> getMappingList(final String esbToBpmXml)
+    	throws ConfigurationException
+    {
+        final 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 mappingList ;
+    }
+    
     private Object getObjectFromMessage(Message message, Mapping mapping) 
     throws ConfigurationException
     {

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java	2008-07-22 17:35:38 UTC (rev 21176)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -31,6 +31,7 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.common.TransactionStrategy;
+import org.jboss.soa.esb.services.jbpm.Mapping;
 import org.jbpm.JbpmContext;
 import org.jbpm.JbpmException;
 import org.jbpm.command.SignalCommand;
@@ -93,9 +94,11 @@
      * @param token The token to signal.
      * @param transitionName The transition to signal or null if the default transition is to be used.
      * @param actor The actor to use.
+     * @param globalProcessScope The default process scope to use.
      * @param variables Any variables to update.
      */
-    static void createSignalJob(final JbpmContext jbpmContext, final Token token, final String transitionName, final String actor, final Map variables)
+    static void createSignalJob(final JbpmContext jbpmContext, final Token token, final String transitionName, final String actor,
+    		final boolean defaultProcessScope, final Map<Mapping, Object> variables)
     {
         final boolean isDebugEnabled = logger.isDebugEnabled() ;
         final long tokenId = token.getId() ;
@@ -115,19 +118,29 @@
         setVariable(contextInstance, token, actorVariableName, actor) ;
         
         final int numVariables = (variables == null ? 0 : variables.size()) ;
-        setVariable(contextInstance, token, ESB_ASYNC_SIGNAL_VARIABLE_COUNT, Integer.toString(numVariables)) ;
         if (numVariables > 0)
         {
             int count = 0 ;
-            final Iterator<Map.Entry> variableEntryIter = variables.entrySet().iterator() ;
+            final Iterator<Map.Entry<Mapping, Object>> variableEntryIter = variables.entrySet().iterator() ;
             do
             {
-                final Map.Entry variableEntry = variableEntryIter.next() ;
-                final String name = variableEntry.getKey().toString() ;
+                final Map.Entry<Mapping, Object> variableEntry = variableEntryIter.next() ;
+                final Mapping mapping = (Mapping)variableEntry.getKey() ;
+                final String name = mapping.getBpm() ;
                 setVariable(contextInstance, token, name, variableEntry.getValue()) ;
-                setVariable(contextInstance, token, ESB_ASYNC_SIGNAL_VARIABLE_NAMES + (count++), name) ;
+                final Boolean isProcessScope = mapping.getIsProcessScope() ;
+                final boolean setScope = (isProcessScope == null ? defaultProcessScope : isProcessScope.booleanValue()) ;
+                if (setScope)
+                {
+                	setVariable(contextInstance, token, ESB_ASYNC_SIGNAL_VARIABLE_NAMES + (count++), name) ;
+                }
             } while (variableEntryIter.hasNext()) ;
+            setVariable(contextInstance, token, ESB_ASYNC_SIGNAL_VARIABLE_COUNT, Integer.toString(count)) ;
         }
+        else
+        {
+        	setVariable(contextInstance, token, ESB_ASYNC_SIGNAL_VARIABLE_COUNT, String.valueOf(0)) ;
+        }
         
         final ExecuteActionJob signalJob = new ExecuteActionJob(token) ;
         signalJob.setAction(getAsyncSignalAction(token)) ;

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CallbackCommand.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CallbackCommand.java	2008-07-22 17:35:38 UTC (rev 21176)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CallbackCommand.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -26,6 +26,7 @@
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Mapping;
 import org.jbpm.JbpmContext;
 import org.jbpm.command.Command;
 import org.jbpm.context.exe.ContextInstance;
@@ -51,7 +52,7 @@
     /**
      * The variable map.
      */
-    private Map variables ;
+    private Map<Mapping, Object> variables ;
     
     private EPR callbackEpr;
     
@@ -70,7 +71,7 @@
         this.transitionName = transitionName ;
     }
     
-    public void setVariables(final Map variables) {
+    public void setVariables(final Map<Mapping, Object> variables) {
         this.variables = variables ;
     }
     
@@ -118,7 +119,11 @@
                         ") is not the expected version (version=" + processNodeVersion + ").");
             }
             
-            AsyncProcessSignal.createSignalJob(jbpmContext, token, transitionName, jbpmContext.getActorId(), variables) ;
+            final String globalProcessScopeVal = callbackEpr.getAddr().getExtensionValue(Constants.PROCESS_SCOPE_ATTR) ;
+            // Default to global scope as that matches the previous functionality
+            // N.B. This is different from retrieving variables!!
+            final boolean globalProcessScope = (globalProcessScopeVal == null ? true : Boolean.parseBoolean(globalProcessScopeVal));
+            AsyncProcessSignal.createSignalJob(jbpmContext, token, transitionName, jbpmContext.getActorId(), globalProcessScope, variables) ;
         } catch (CallbackException jbpmCe) {
             logger.warn(jbpmCe.getMessage());
         }

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java	2008-07-22 17:35:38 UTC (rev 21176)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -33,6 +33,7 @@
 import org.jboss.soa.esb.message.mapping.ObjectMappingException;
 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.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
 import org.jbpm.JbpmException;
@@ -133,7 +134,7 @@
                 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);
+                Map<Mapping,Object> variableMap = mapper.mapFromEsbMessageToJBpmMapping(message, esbToBpmXml);
                 if (null!=variableMap) command.setVariables(variableMap);
                 String transition = (toEpr.getAddr().getExtensionValue(Constants.TRANSITION_NAME));
                 //The transition can be overriden if needed, by setting the following variable.
@@ -277,7 +278,7 @@
             if (result instanceof ProcessInstance)
             {
                 final ProcessInstance processInstance = (ProcessInstance)result ;
-                AsyncProcessSignal.createSignalJob(jbpmContext, processInstance.getRootToken(), transitionName, getActorId(), null) ;
+                AsyncProcessSignal.createSignalJob(jbpmContext, processInstance.getRootToken(), transitionName, getActorId(), false, null) ;
             }
             return result ;
         }

Modified: labs/jbossesb/trunk/qa/junit/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/build.xml	2008-07-22 17:35:38 UTC (rev 21176)
+++ labs/jbossesb/trunk/qa/junit/build.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -133,6 +133,20 @@
             <include name="META-INF/*.xml"/>
          </fileset>
       </jar>
+      <jar jarfile="${qa.build.lib}/jbpm-local-test.esb">
+         <fileset dir="${qa.junit.classes}">
+            <include name="org/jboss/soa/esb/server/jbpmLocal/*.class"/>
+         </fileset>
+         <fileset dir="${qa.junit.classes}">
+            <include name="org/jboss/soa/esb/server/Redelivery*.class"/>
+         </fileset>
+         <fileset dir="${qa.junit.resources}/server/jbpmLocal">
+            <include name="esb-${org.jboss.soa.esb.qa.jmsprovider}-service.xml"/>
+            <include name="test-jbpm-service.xml"/>
+            <include name="jbpmLocalTest.xml"/>
+            <include name="META-INF/*.xml"/>
+         </fileset>
+      </jar>
    </target>
 
    <target name="one-test" if="test" depends="jars"

Added: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/deployment.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/deployment.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,4 @@
+<jbossesb-deployment>
+  <depends>jboss.esb.qa.junit.destination:service=Queue,name=jbpm_local_channel</depends>
+  <depends>jboss.esb:test=JbpmLocalServer</depends>
+</jbossesb-deployment>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/deployment.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/jboss-esb.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,21 @@
+<?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">
+  <providers>
+    <jms-jca-provider name="JMS" connection-factory="ConnectionFactory">
+      <jms-bus busid="jbpm_local_channel">
+        <jms-message-filter dest-type="QUEUE" dest-name="queue/jbpm_local_channel"/>
+      </jms-bus>
+    </jms-jca-provider>
+  </providers>
+
+  <services>
+    <service category="TestJBPMLocalESB" name="Counter" description="Echo service">
+      <listeners>
+        <jms-listener name="JBPM-ESBListener" busidref="jbpm_local_channel" maxThreads="1"/>
+      </listeners>
+      <actions>
+        <action name="echoAction" class="org.jboss.soa.esb.server.jbpmLocal.CounterAction"/>
+      </actions>
+    </service>
+  </services>
+</jbossesb>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/META-INF/jboss-esb.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbm-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbm-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbm-service.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.esb.qa.junit.destination:service=Queue,name=jbpm_local_channel"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbm-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbmq-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbmq-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbmq-service.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+  <mbean code="org.jboss.mq.server.jmx.Queue"
+    name="jboss.esb.qa.junit.destination:service=Queue,name=jbpm_local_channel">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+  </mbean>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/esb-jbmq-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/jbpmLocalTest.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/jbpmLocalTest.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/jbpmLocalTest.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  
+<process-definition name="jBPMLocalTest">
+   <start-state name="start">
+      <transition to="node1"/>
+   </start-state>
+   
+   <node name="node1">
+      <action name="sendToESB" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+         <esbCategoryName>TestJBPMLocalESB</esbCategoryName>
+         <esbServiceName>Counter</esbServiceName>
+         <esbToBpmVars>
+            <!-- should be set on root as that is the active task -->
+            <mapping esb="BODY_CONTENT" bpm="theBody" process-scope="false"/>
+         </esbToBpmVars>
+      </action>
+      <transition to="fork"/>
+   </node>
+   
+   <fork name="fork">
+      <event type="node-enter">
+         <action name="logRoot" class="org.jboss.soa.esb.server.jbpmLocal.JbpmLocalLogHandler"/>
+      </event>
+      <transition name="child1" to="child1"/>
+      <transition name="child2" to="child2"/>
+   </fork>
+   
+   <node name="child1">
+      <action name="child1SendToESB" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+         <esbCategoryName>TestJBPMLocalESB</esbCategoryName>
+         <esbServiceName>Counter</esbServiceName>
+         <bpmToEsbVars>
+            <!-- should inherit the root value as current task is not set -->
+            <mapping bpm="theBody" esb="BODY_CONTENT" process-scope="false"/>
+         </bpmToEsbVars>
+         <esbToBpmVars>
+            <!-- should be set on child as that is the active task -->
+            <mapping esb="BODY_CONTENT" bpm="theBody" process-scope="false"/>
+         </esbToBpmVars>
+      </action>
+      <transition to="join"/>
+   </node>
+   
+   <node name="child2">
+      <action name="child2SendToESB" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+         <esbCategoryName>TestJBPMLocalESB</esbCategoryName>
+         <esbServiceName>Counter</esbServiceName>
+         <bpmToEsbVars>
+            <!-- should inherit the root value as current task is not set -->
+            <mapping bpm="theBody" esb="BODY_CONTENT" process-scope="false"/>
+         </bpmToEsbVars>
+         <esbToBpmVars>
+            <!-- should be set on child as that is the active task -->
+            <mapping esb="BODY_CONTENT" bpm="theBody" process-scope="false"/>
+         </esbToBpmVars>
+      </action>
+      <transition to="join"/>
+   </node>
+   
+   <join name="join">
+      <event type="node-enter">
+         <action name="logChild" class="org.jboss.soa.esb.server.jbpmLocal.JbpmLocalLogHandler"/>
+      </event>
+      <transition to="end"/>  
+   </join>
+   
+   <end-state name="end">
+      <event type="node-enter">
+         <action name="logRoot2" class="org.jboss.soa.esb.server.jbpmLocal.JbpmLocalLogHandler"/>
+      </event>
+   </end-state>
+</process-definition>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/jbpmLocalTest.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/test-jbpm-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/test-jbpm-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/test-jbpm-service.xml	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.esb:test=JbpmLocalServer" code="org.jboss.soa.esb.server.jbpmLocal.JbpmServer"/>
+   <mbean name="jboss.esb:test=RedeliveryServer" code="org.jboss.soa.esb.server.Redelivery"/>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmLocal/test-jbpm-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/CounterAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/CounterAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/CounterAction.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,62 @@
+/*
+* 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.server.jbpmLocal;
+
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Action class using a counter as response message.
+ * 
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public class CounterAction extends AbstractActionLifecycle implements ActionPipelineProcessor
+{
+    private int counter ;
+
+    public CounterAction(final ConfigTree config)
+    {
+    }
+
+    public Message process(final Message message)
+        throws ActionProcessingException
+    {
+    	message.getBody().add(getCounter()) ;
+    	return message ;
+    }
+    
+    private synchronized int getCounter()
+    {
+    	return counter++ ;
+    }
+    
+    public void processException(final Message message, final Throwable th)
+    {
+    }
+    
+    public void processSuccess(final Message message)
+    {
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/CounterAction.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalLogHandler.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalLogHandler.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalLogHandler.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,65 @@
+/*
+ * 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.server.jbpmLocal;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.soa.esb.server.RedeliveryMBean;
+import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.Token;
+
+/**
+ * Action Handler for jBPM local test.
+ */
+public class JbpmLocalLogHandler implements ActionHandler
+{
+    /**
+     * Serial version UID for this class.
+     */
+    private static final long serialVersionUID = -2640937298056584812L;
+
+    /**
+     * Wait for a notification from the test.
+     */
+    public void execute(final ExecutionContext executionContext)
+        throws Exception
+    {
+        final ContextInstance contextInstance = executionContext.getContextInstance() ;
+        final Token token = executionContext.getToken() ;
+        final Object value = contextInstance.getVariable("theBody", token) ;
+        
+        getRedeliveryMBean().logMessage(String.valueOf(value)) ;
+    }
+    
+    private RedeliveryMBean getRedeliveryMBean()
+        throws MalformedObjectNameException
+    {
+        final MBeanServer server = MBeanServerLocator.locateJBoss();
+        
+        return (RedeliveryMBean) MBeanProxyExt.create(RedeliveryMBean.class, RedeliveryMBean.objectName, server);
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalLogHandler.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalUnitTest.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.server.jbpmLocal;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.soa.esb.server.RedeliveryMBean;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test local variables for jBPM processes.
+ * 
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class JbpmLocalUnitTest extends JBossTestCase
+{
+    /**
+     * The name of the deployment archive.
+     */
+    private static final String ESB_ARCHIVE = "jbpm-local-test.esb" ;
+    
+    /**
+     * Construct the test case with the specified name.
+     * @param name The name of the test case.
+     */
+    public JbpmLocalUnitTest(final String name)
+    {
+        super(name) ;
+    }
+    
+    /**
+     * Test for local variables.
+     * @throws Exception For any failures.
+     */
+    public void testLocalVariables()
+        throws Exception
+    {
+        getServer().invoke(new ObjectName(JbpmServerMBean.OBJECT_NAME), "startProcess", null, null) ;
+        
+        final String expected = "0" ;
+        
+        final int numMessages = 4 ;
+        final String[] messages = (String[])getServer().invoke(new ObjectName(RedeliveryMBean.objectName), "waitForMessages",
+                new Integer[] {Integer.valueOf(numMessages)}, new String[] { Integer.TYPE.getName() });
+        assertNotNull("log messages", messages) ;
+        assertEquals("Message count", numMessages, messages.length) ;
+        for(int count = 0 ; count < numMessages ; count++)
+        {
+        	assertNotNull("Message: " + count, messages[count]) ;
+        }
+        assertEquals("Initial message", expected, messages[0]) ;
+        assertFalse("First child message", expected.equals(messages[1])) ;
+        assertFalse("Second child message", expected.equals(messages[2])) ;
+        assertFalse("Children are identical", messages[1].equals(messages[2])) ;
+        assertEquals("Last message", expected, messages[3]) ;
+    }
+    
+    /**
+     * Create the test suite.
+     * @return The suite representing this test case.
+     */
+    public static Test suite()
+        throws Exception
+    {
+        return getDeploySetup(JbpmLocalUnitTest.class, ESB_ARCHIVE);
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmLocalUnitTest.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServer.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServer.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServer.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.server.jbpmLocal;
+
+import java.io.InputStream;
+
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * MBean to manage jBPM local variable tests.
+ * 
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class JbpmServer implements JbpmServerMBean
+{
+    private static final String PROCESS_DEFINITION = "/jbpmLocalTest.xml" ;
+    
+    public synchronized void startProcess()
+    {
+        final JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance() ;
+        final JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext() ;
+        
+        // Create process definition
+        final InputStream is = ClassUtil.getResourceAsStream(PROCESS_DEFINITION, getClass()) ;
+        final ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(is) ;
+        jbpmContext.deployProcessDefinition(processDefinition) ;
+        
+        // Create process instance
+        final ProcessInstance processInstance = jbpmContext.newProcessInstance(processDefinition.getName()) ;
+        
+        // Start process instance
+        processInstance.signal() ;
+        
+        jbpmContext.close() ;
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServer.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServerMBean.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServerMBean.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServerMBean.java	2008-07-22 18:01:58 UTC (rev 21177)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.server.jbpmLocal;
+
+/**
+ * MBean to manage jBPM local variable tests.
+ * 
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public interface JbpmServerMBean
+{
+    public static final String OBJECT_NAME="jboss.esb:test=JbpmLocalServer" ;
+    
+    public void startProcess() ;
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmLocal/JbpmServerMBean.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list