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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jul 25 06:20:45 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-07-25 06:20:45 -0400 (Fri, 25 Jul 2008)
New Revision: 21219

Added:
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/deployment.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/jboss-esb.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/esb-jbm-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/esb-jbmq-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/jbpmReplyTest.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/test-jbpm-service.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmReplyUnitTest.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServer.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServerMBean.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/ReplyAction.java
Modified:
   labs/jbossesb/trunk/product/docs/ServicesGuide.odt
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
   labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java
   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/NewProcessInstanceFacade.java
   labs/jbossesb/trunk/qa/junit/build.xml
Log:
Support originator ReplyTo/FaultTo in jBPM: JBESB-1457

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/Constants.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java	2008-07-25 10:08:20 UTC (rev 21218)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -64,6 +64,8 @@
 	public static final String ERROR_MESSAGE   				="jbpmErrorMsg";
 	public static final String RETURN_CODE					="jbpmReturnCode";
     public static final String JBPM_LOG_MAP                 ="jbpmLogMap";
+    public static final String REPLY_TO                     ="jbpmReplyTo";
+    public static final String FAULT_TO                     ="jbpmFaultTo";
 	
 	// Possible values of return codes after execution of an action
 	public static final String RETCODE_OK					="jbpmReturnOK";
@@ -89,6 +91,7 @@
 	public static final String ONE_ACTOR_TAG				="actor";
 	public static final String OVERWRITE_SWIMLANE_TAG		="overwrite-swimlane";
     public static final String KEY_TAG                      ="key";
+	public static final String REPLY_TO_ORIGINATOR_TAG		="reply-to-originator";
     
     //tag names for xml configuration of jBPM actions
     public static final String BPM_TO_ESB_VARS_TAG = "bpmToEsbVars";
@@ -97,6 +100,8 @@
     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 static final String EPR_REPLY = "reply" ;
+    public static final String EPR_FAULT = "fault" ;
 
 	public enum OpCode
 	{

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java	2008-07-25 10:08:20 UTC (rev 21218)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -23,17 +23,22 @@
 
 import org.apache.log4j.Logger;
 import org.dom4j.tree.DefaultElement;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
 import org.jboss.internal.soa.esb.util.LRUCache;
 import org.jboss.soa.esb.ConfigurationException;
 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.couriers.Courier;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.couriers.CourierUtil;
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
 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.actions.JBpmCallback;
+import org.jbpm.context.exe.ContextInstance;
 import org.jbpm.graph.def.ActionHandler;
 import org.jbpm.graph.exe.ExecutionContext;
 import org.jbpm.graph.exe.Token;
@@ -67,6 +72,8 @@
     
     public String exceptionTransition;
 
+    public String replyToOriginator;
+    
     private transient Logger logger = Logger.getLogger(getClass());
     
     private static transient LRUCache<String, ServiceInvoker> siCache = new LRUCache<String, ServiceInvoker>(20);
@@ -74,12 +81,18 @@
     public void execute (ExecutionContext executionContext) throws Exception
     {
         //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 (replyToOriginator != null) {
+            if (!(Constants.EPR_REPLY.equals(replyToOriginator) || Constants.EPR_FAULT.equals(replyToOriginator))) {
+                throw new ConfigurationException("EPR type (replyToOriginator) must be \"" + Constants.EPR_REPLY + "\" or \"" + Constants.EPR_FAULT + "\"");
+            }
+        } else {
+            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.");
@@ -101,7 +114,34 @@
         }
         //Sending the message on its way
         if (logger.isDebugEnabled()) logger.debug("Created ESB message=" + message);
-        getServiceInvoker().deliverAsync(message);
+        
+        if (replyToOriginator != null) {
+            final EPR epr ;
+            final ContextInstance contextInstance = executionContext.getContextInstance() ;
+            final Object replyToEPR = contextInstance.getVariable(Constants.REPLY_TO);
+            final Object faultToEPR = contextInstance.getVariable(Constants.FAULT_TO);
+
+            if (Constants.EPR_FAULT.equals(replyToOriginator) && (faultToEPR != null)) {
+                epr = EPRHelper.fromXMLString(faultToEPR.toString()) ;
+            } else if (replyToEPR != null) {
+                epr = EPRHelper.fromXMLString(replyToEPR.toString()) ;
+            } else {
+                throw new ConfigurationException("No EPR present in process instance") ;
+            }
+            if(epr instanceof LogicalEPR) {
+                final ServiceInvoker invoker = ((LogicalEPR)epr).getServiceInvoker();
+                invoker.deliverAsync(message);
+            } else {
+                final Courier courier = CourierFactory.getCourier(epr);
+                try {
+                    courier.deliver(message);
+                } finally {
+                    CourierUtil.cleanCourier(courier);
+                }
+            }
+        } else {
+            getServiceInvoker().deliverAsync(message);
+        }
         logger.debug("Message send successfully");
     }
     /**
@@ -113,8 +153,9 @@
     private ServiceInvoker getServiceInvoker() throws MessageDeliverException
     {
         String key = esbCategoryName + esbServiceName;
-        if (siCache.containsKey(key)) {
-            return siCache.get(key);
+        final ServiceInvoker origInvoker = siCache.get(key) ;
+        if (origInvoker != null) {
+            return origInvoker;
         } else {
             ServiceInvoker invoker = new ServiceInvoker(esbCategoryName,  esbServiceName);
             siCache.put(key, invoker);

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java	2008-07-25 10:08:20 UTC (rev 21218)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbNotifier.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -23,12 +23,20 @@
 package org.jboss.soa.esb.services.jbpm.actionhandlers;
 import org.apache.log4j.Logger;
 import org.dom4j.tree.DefaultElement;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
 import org.jboss.internal.soa.esb.util.LRUCache;
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
 import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.couriers.Courier;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.couriers.CourierUtil;
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
 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.jbpm.context.exe.ContextInstance;
 import org.jbpm.graph.def.ActionHandler;
 import org.jbpm.graph.exe.ExecutionContext;
 
@@ -65,23 +73,60 @@
      */
     public DefaultElement bpmToEsbVars;
     /**
+     * Use the replyTo or faultTo EPR from the originator.
+     */
+    public String useEPR;
+    
+    /**
      * 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 (useEPR != null) {
+            if (!(Constants.EPR_REPLY.equals(useEPR) || Constants.EPR_FAULT.equals(useEPR))) {
+                throw new ConfigurationException("EPR type (useEPR) must be \"" + Constants.EPR_REPLY + "\" or \"" + Constants.EPR_FAULT + "\"");
+            }
+        } else {
+            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 (null == esbServiceName) {
-            throw new ConfigurationException(
-                "Service name (esbServiceName element) must not be null");
-        }
         JBpmObjectMapper mapper = new JBpmObjectMapper();
         Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, globalProcessScope, executionContext);
         if (logger.isDebugEnabled()) logger.debug("Created ESB message=" + message);
-        getServiceInvoker().deliverAsync(message);
+        if (useEPR != null) {
+            final EPR epr ;
+            final ContextInstance contextInstance = executionContext.getContextInstance() ;
+            final Object replyToEPR = contextInstance.getVariable(Constants.REPLY_TO);
+            final Object faultToEPR = contextInstance.getVariable(Constants.FAULT_TO);
+
+            if (Constants.EPR_FAULT.equals(useEPR) && (faultToEPR != null)) {
+                epr = EPRHelper.fromXMLString(faultToEPR.toString()) ;
+            } else if (replyToEPR != null) {
+                epr = EPRHelper.fromXMLString(replyToEPR.toString()) ;
+            } else {
+                throw new ConfigurationException("No EPR present in process instance") ;
+            }
+            if(epr instanceof LogicalEPR) {
+                final ServiceInvoker invoker = ((LogicalEPR)epr).getServiceInvoker();
+                invoker.deliverAsync(message);
+            } else {
+                final Courier courier = CourierFactory.getCourier(epr);
+                try {
+                    courier.deliver(message);
+                } finally {
+                    CourierUtil.cleanCourier(courier);
+                }
+            }
+        } else {
+            getServiceInvoker().deliverAsync(message);
+        }
         logger.debug("Message send successfully");
     }
     /**

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-25 10:08:20 UTC (rev 21218)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -54,7 +54,7 @@
  */
 public class CommandExecutor
 {
-    static CommandExecutor commandExecutor;
+    private static CommandExecutor commandExecutor = new CommandExecutor();
     
     private static Logger logger = Logger.getLogger(CommandExecutor.class);
     private static JbpmConfiguration jbpmConfig;
@@ -62,9 +62,6 @@
 	
     public static CommandExecutor getInstance() 
     {
-        if (commandExecutor==null) {
-            commandExecutor =new CommandExecutor();
-        }
         return commandExecutor;
     }
     
@@ -210,7 +207,22 @@
 			if (null!=actorId) command.setActorId(actorId);
 			Boolean createStartTask = MessageHelper.getBooleanValue(request, Constants.CREATE_START_TASK);
 			if (null!=createStartTask) command.setCreateStartTask(createStartTask);
+			
 			Map<String, Object> variables = MessageHelper.getVariablesMap(request, Constants.VARIABLE_VALUES);
+			
+			final String replyTo = MessageHelper.getStringValue(request, Constants.REPLY_TO) ;
+			final String faultTo = MessageHelper.getStringValue(request, Constants.FAULT_TO) ;
+			
+			if ((replyTo != null) || (faultTo != null)) {
+				final Map<String, Object> newVariables = (variables == null ? new HashMap<String, Object>() : new HashMap<String, Object>(variables)) ;
+				if (replyTo != null) {
+					newVariables.put(Constants.REPLY_TO, replyTo) ;
+				}
+				if (faultTo != null) {
+					newVariables.put(Constants.FAULT_TO, faultTo) ;
+				}
+				variables = newVariables ;
+			}
 			if (null!=variables) command.setVariables(variables);
             
             logger.debug("New process instance with command=" + command);

Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java	2008-07-25 10:08:20 UTC (rev 21218)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/NewProcessInstanceFacade.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -25,7 +25,11 @@
 import java.util.List;
 import java.util.Map;
 
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.message.Body;
 import org.jboss.soa.esb.message.Message;
@@ -68,6 +72,7 @@
 		if (_start) {
 			_transitionName	= config.getAttribute(Constants.TRANSITION_NAME_TAG);
         }
+		_replyToOriginator = config.getBooleanAttribute(Constants.REPLY_TO_ORIGINATOR_TAG, false) ;
 	}
 	
 	public void setJBPMContextParameters(Message message) 
@@ -86,7 +91,25 @@
 		Map<String,Object> variableMap = _mapper.mapFromEsbMessageToJBpmMap(message,_esbToBpm);
         if (null!=variableMap)
             body.add(Constants.VARIABLE_VALUES, variableMap);
+        if (_replyToOriginator) {
+            final Call call = message.getHeader().getCall() ;
+            body.add(Constants.REPLY_TO, getEPR(call.getReplyTo())) ;
+            body.add(Constants.FAULT_TO, getEPR(call.getFaultTo())) ;
+        }
 	}
+	
+	private String getEPR(final EPR epr)
+	{
+		if (epr == null) {
+			return null ;
+		}
+		
+		try {
+			return EPRHelper.toXMLString(epr) ;
+		} catch (final MarshalException me) {
+			throw new IllegalArgumentException("Failed to marshall epr", me) ;
+		}
+	}
 
 	boolean			_start;
     String          _keyPath;
@@ -96,4 +119,5 @@
 	Long			_processId;
 	List<Mapping>   _esbToBpm;
     JBpmObjectMapper _mapper = new JBpmObjectMapper();
+    private boolean _replyToOriginator ;
 }

Modified: labs/jbossesb/trunk/qa/junit/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/build.xml	2008-07-25 10:08:20 UTC (rev 21218)
+++ labs/jbossesb/trunk/qa/junit/build.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -147,6 +147,20 @@
             <include name="META-INF/*.xml"/>
          </fileset>
       </jar>
+    <jar jarfile="${qa.build.lib}/jbpm-reply-test.esb">
+       <fileset dir="${qa.junit.classes}">
+          <include name="org/jboss/soa/esb/server/jbpmReply/*.class"/>
+       </fileset>
+       <fileset dir="${qa.junit.classes}">
+          <include name="org/jboss/soa/esb/server/Redelivery*.class"/>
+       </fileset>
+       <fileset dir="${qa.junit.resources}/server/jbpmReply">
+          <include name="esb-${org.jboss.soa.esb.qa.jmsprovider}-service.xml"/>
+          <include name="test-jbpm-service.xml"/>
+          <include name="jbpmReplyTest.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/jbpmReply/META-INF/deployment.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/deployment.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,5 @@
+<jbossesb-deployment>
+  <depends>jboss.esb.qa.junit.destination:service=Queue,name=jbpm_reply_create_channel</depends>
+  <depends>jboss.esb.qa.junit.destination:service=Queue,name=jbpm_reply_channel</depends>
+  <depends>jboss.esb:test=JbpmReplyServer</depends>
+</jbossesb-deployment>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/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/jbpmReply/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/META-INF/jboss-esb.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,37 @@
+<?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_reply_channel">
+        <jms-message-filter dest-type="QUEUE" dest-name="queue/jbpm_reply_channel"/>
+      </jms-bus>
+      <jms-bus busid="jbpm_reply_create_channel">
+        <jms-message-filter dest-type="QUEUE" dest-name="queue/jbpm_reply_create_channel"/>
+      </jms-bus>
+    </jms-jca-provider>
+  </providers>
+
+  <services>
+    <service category="TestJBPMReplyESB" name="Create" description="Create service">
+      <listeners>
+        <jms-listener name="JBPM-ESBListener" busidref="jbpm_reply_create_channel"/>
+      </listeners>
+      <actions mep="OneWay">
+        <action name="create_new_process_instance"
+          class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
+          <property name="command" value="StartProcessInstanceCommand"/>
+          <property name="process-definition-name" value="jBPMReplyTest"/>
+          <property name="reply-to-originator" value="true"/>
+        </action>
+      </actions>
+    </service>
+    <service category="TestJBPMReplyESB" name="Reply" description="Reply service">
+      <listeners>
+        <jms-listener name="JBPM-ESBListener" busidref="jbpm_reply_channel"/>
+      </listeners>
+      <actions>
+        <action name="replyAction" class="org.jboss.soa.esb.server.jbpmReply.ReplyAction"/>
+      </actions>
+    </service>
+  </services>
+</jbossesb>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/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/jbpmReply/esb-jbm-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/esb-jbm-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/esb-jbm-service.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,15 @@
+<?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_reply_create_channel"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
+   <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.esb.qa.junit.destination:service=Queue,name=jbpm_reply_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/jbpmReply/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/jbpmReply/esb-jbmq-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/esb-jbmq-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/esb-jbmq-service.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,15 @@
+<?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_reply_create_channel">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+  </mbean>
+  <mbean code="org.jboss.mq.server.jmx.Queue"
+    name="jboss.esb.qa.junit.destination:service=Queue,name=jbpm_reply_channel">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+  </mbean>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/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/jbpmReply/jbpmReplyTest.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/jbpmReplyTest.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/jbpmReplyTest.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  
+<process-definition name="jBPMReplyTest">
+   <start-state name="start">
+      <transition to="reply"/>
+   </start-state>
+   
+   <node name="reply">
+      <event type="node-enter">
+         <action name="notify" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbNotifier">
+            <replyToOriginator>reply</replyToOriginator>
+         </action>
+      </event>
+      <action name="sendToESB" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+         <replyToOriginator>reply</replyToOriginator>
+      </action>
+      <transition to="fault"/>
+   </node>
+   
+   <node name="fault">
+      <event type="node-enter">
+         <action name="notify" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbNotifier">
+            <replyToOriginator>fault</replyToOriginator>
+         </action>
+      </event>
+      <action name="sendToESB" class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+         <replyToOriginator>fault</replyToOriginator>
+      </action>
+      <transition to="end"/>
+   </node>
+   
+   <end-state name="end"/>
+</process-definition>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/jbpmReplyTest.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/jbpmReply/test-jbpm-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/test-jbpm-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbpmReply/test-jbpm-service.xml	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.esb:test=JbpmReplyServer" code="org.jboss.soa.esb.server.jbpmReply.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/jbpmReply/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/jbpmReply/JbpmReplyUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmReplyUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmReplyUnitTest.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,102 @@
+/*
+ * 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.jbpmReply;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+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 JbpmReplyUnitTest extends JBossTestCase
+{
+    /**
+     * The name of the deployment archive.
+     */
+    private static final String ESB_ARCHIVE = "jbpm-reply-test.esb" ;
+    
+    /**
+     * Construct the test case with the specified name.
+     * @param name The name of the test case.
+     */
+    public JbpmReplyUnitTest(final String name)
+    {
+        super(name) ;
+    }
+    
+    /**
+     * Test for replies.
+     * @throws Exception For any failures.
+     */
+    public void testReplies()
+        throws Exception
+    {
+        getServer().invoke(new ObjectName(JbpmServerMBean.OBJECT_NAME), "deployProcess", null, null) ;
+        
+        final Message message = MessageFactory.getInstance().getMessage() ;
+        final Call call = message.getHeader().getCall() ;
+        final EPR replyToEPR = new LogicalEPR("TestJBPMReplyESB", "Reply") ;
+        replyToEPR.getAddr().addExtension(ReplyAction.REPLY_TYPE, "reply") ;
+        call.setReplyTo(replyToEPR) ;
+        
+        final EPR faultToEPR = new LogicalEPR("TestJBPMReplyESB", "Reply") ;
+        faultToEPR.getAddr().addExtension(ReplyAction.REPLY_TYPE, "fault") ;
+        call.setFaultTo(faultToEPR) ;
+        
+        final ServiceInvoker si = new ServiceInvoker("TestJBPMReplyESB", "Create") ;
+        si.deliverAsync(message) ;
+        
+        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("Reply notification", "EsbNotifier:reply", messages[0]) ;
+        assertEquals("Reply action", "EsbActionHandler:reply", messages[1]) ;
+        assertEquals("Fault notification", "EsbNotifier:fault", messages[2]) ;
+        assertEquals("Fault action", "EsbActionHandler:fault", messages[3]) ;
+    }
+    
+    /**
+     * Create the test suite.
+     * @return The suite representing this test case.
+     */
+    public static Test suite()
+        throws Exception
+    {
+        return getDeploySetup(JbpmReplyUnitTest.class, ESB_ARCHIVE);
+    }
+}


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

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServer.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServer.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServer.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -0,0 +1,50 @@
+/*
+ * 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.jbpmReply;
+
+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;
+
+/**
+ * MBean to manage jBPM reply tests.
+ * 
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class JbpmServer implements JbpmServerMBean
+{
+    private static final String PROCESS_DEFINITION = "/jbpmReplyTest.xml" ;
+    
+    public synchronized void deployProcess()
+    {
+        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) ;
+        
+        jbpmContext.close() ;
+    }
+}


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

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServerMBean.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServerMBean.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/JbpmServerMBean.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -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.jbpmReply;
+
+/**
+ * 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=JbpmReplyServer" ;
+    
+    public void deployProcess() ;
+}


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

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/ReplyAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/ReplyAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jbpmReply/ReplyAction.java	2008-07-25 10:20:45 UTC (rev 21219)
@@ -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.server.jbpmReply;
+
+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.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.server.RedeliveryMBean;
+
+/**
+ * Action Handler for jBPM local test.
+ */
+public class ReplyAction extends AbstractActionLifecycle implements ActionPipelineProcessor
+{
+    /**
+     * The reply type extension on the EPR.
+     */
+    public static final String REPLY_TYPE = "replyType" ;
+    /**
+     * Construct the action.
+     */
+    public ReplyAction(final ConfigTree config)
+    {
+    }
+    
+    /**
+     * Handle reply.
+     */
+    public Message process(final Message message)
+        throws ActionProcessingException
+    {
+        final Call call = message.getHeader().getCall() ;
+        final EPR replyEPR = call.getReplyTo() ;
+        final EPR toEPR = call.getTo() ;
+        
+        final String type = toEPR.getAddr().getExtensionValue(REPLY_TYPE) ;
+        
+        final String value ;
+        final Message reply ;
+        if (replyEPR == null)
+        {
+            value = "EsbNotifier:" + type ;
+            reply = null ;
+        }
+        else
+        {
+            value = "EsbActionHandler:" + type ;
+            reply = message ;
+        }
+        getRedeliveryMBean().logMessage(value) ;
+        
+        return reply ;
+    }
+    
+    private RedeliveryMBean getRedeliveryMBean()
+        throws ActionProcessingException
+    {
+        final MBeanServer server = MBeanServerLocator.locateJBoss();
+        
+        try
+        {
+            return (RedeliveryMBean) MBeanProxyExt.create(RedeliveryMBean.class, RedeliveryMBean.objectName, server);
+        }
+        catch (final MalformedObjectNameException mone)
+        {
+            throw new ActionProcessingException("Error retrieving MBean", mone) ;
+        }
+    }
+    
+    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/jbpmReply/ReplyAction.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list