[jboss-svn-commits] JBL Code SVN: r11312 - in labs/jbossesb/trunk/product/services/jbpm/src: main/java/org/jboss/soa/esb/services/jbpm/actionhandlers and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Apr 24 16:08:00 EDT 2007
Author: estebanschifman
Date: 2007-04-24 16:08:00 -0400 (Tue, 24 Apr 2007)
New Revision: 11312
Added:
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
Removed:
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandExecutorFactory.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandler.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/MessageFacadeFactory.java
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/actions/CommandInterpreter.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessor.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/FacadeUtil.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandlerUnitTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessorUnitTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml
Log:
new package names. rearrange classes in packages. standardize xml tags
Copied: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java (from rev 11310, labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandExecutorFactory.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -0,0 +1,52 @@
+/*
+ * 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,
+ */
+package org.jboss.soa.esb.services.jbpm;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.actions.CommandInterpreter;
+import org.jboss.soa.esb.services.jbpm.actions.impl.DefaultCommandExecutorFactoryImpl;
+
+/**
+ * Factory to obtain appropriate Performer for the jBPM CommandInterpreter
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ *
+ */
+public abstract class CommandExecutorFactory
+{
+
+ public abstract CommandInterpreter.CommandExecutor
+ getExecutor(Message message) throws Exception;
+
+
+ protected static final Object s_oSynch = new Integer(0);
+
+ protected static CommandExecutorFactory _factory;
+ public static CommandExecutorFactory getInstance()
+ {
+ if (null==_factory)
+ synchronized(s_oSynch)
+ {
+ if (null==_factory)
+ _factory=new DefaultCommandExecutorFactoryImpl();
+ };
+ return _factory;
+ } //________________________________
+}
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 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -66,19 +66,19 @@
// tag names for xml configuration of actions
public static final String COMMAND_CODE_TAG ="command";
- public static final String PROCESS_DEFINITION_XML_TAG ="ProcessDefinitionXml";
- public static final String PROCESS_DEFINITION_NAME_TAG ="processDefinitionName";
- public static final String PROCESS_DEFINITION_ID_TAG ="processDefinitionId";
- public static final String TRANSITION_NAME_TAG ="transitionName";
- public static final String INCLUDE_ALL_VARS_TAG ="includeAllVariables";
- public static final String INCLUDE_LOGS_TAG ="includeLogs";
- public static final String VARIABLES_TAG ="Variables";
+ public static final String PROCESS_DEFINITION_XML_TAG ="process-definition-xml";
+ public static final String PROCESS_DEFINITION_NAME_TAG ="process-definition-name";
+ public static final String PROCESS_DEFINITION_ID_TAG ="process-definition-id";
+ public static final String TRANSITION_NAME_TAG ="transition-name";
+ 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 ONE_VARIABLE_TAG ="variable";
- public static final String ESB_VARNAME_TAG ="esbName";
- public static final String JBPM_VARNAME_TAG ="jbpmName";
- public static final String ACTORS_TAG ="Actors";
+ public static final String ESB_VARNAME_TAG ="esb-name";
+ public static final String JBPM_VARNAME_TAG ="jbpm-name";
+ public static final String ACTORS_TAG ="actors";
public static final String ONE_ACTOR_TAG ="actor";
- public static final String OVERWRITE_SWIMLANE_TAG ="overwriteSwimlane";
+ public static final String OVERWRITE_SWIMLANE_TAG ="overwrite-swimlane";
public enum OpCode
{
Copied: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java (from rev 11309, labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/MessageFacadeFactory.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -0,0 +1,53 @@
+/*
+ * 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,
+ */
+package org.jboss.soa.esb.services.jbpm;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
+import org.jboss.soa.esb.services.jbpm.actions.impl.DefaultMessageFacadeFactoryImpl;
+
+/**
+ * Factory to obtain appropriate MessageManipulator for jBPM SingleCommandProcessors
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ *
+ */
+public abstract class MessageFacadeFactory
+{
+
+ public abstract SingleCommandProcessor.MessageFacade
+ getPreProcessor(ConfigTree config) throws ConfigurationException;
+
+
+ protected static final Object s_oSynch = new Integer(0);
+
+ private static MessageFacadeFactory _factory;
+ public static MessageFacadeFactory getInstance()
+ {
+ if (null==_factory)
+ synchronized(s_oSynch)
+ {
+ if (null==_factory)
+ _factory=new DefaultMessageFacadeFactoryImpl();
+ };
+ return _factory;
+ } //________________________________
+}
Copied: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java (from rev 11309, labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandler.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -0,0 +1,277 @@
+/*
+ * 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 java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.listeners.message.Invoker;
+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.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.util.Helper;
+import org.jboss.soa.esb.util.Util;
+import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.graph.def.ActionHandler;
+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 - for ESB registry lookup
+ * <li>jbpmToEsb_variables
+ * <br/> if this variable missing in the jpdl (null value in the context),
+ * then <b>ALL</b> context instance variables will be added to the body of the esb message using
+ * the jbpm variable name as the key in the message body
+ * <br/> otherwise, you can specify a comma delimited list of
+ * names indicating which jbpm context variables must be added to the message body
+ * <br/> if you wish NOT to add objects in the body of the
+ * outgoing message, you must specify a zero-length string as the value
+ * </li>
+ * <li>jbpmToEsb_esbNames
+ * <br/> if this value is not specified, then the jbpm variable
+ * names will be used as a key to add the objects in the message body
+ * <br/> otherwise, a comma delimited list of names
+ * <b>of the same length as</b>
+ * the jbpmToEsb_variables list, must be supplied and will be used as keys in the message body
+ * </li>
+ * <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>
+ * <li>return_esbNames
+ * <br/> If this value is missing in the jpdl (null value in the context), then an attempt will me made
+ * to find <b>ALL</b> jbpm context variables in the body of the incoming message, and only those objects
+ * found with a valid jbpm context variable name, will update the jbpm context
+ * <br/> Otherwise, a comma delimited list of names must be supplied. These will
+ * be used to obtain values from the incoming response from the ESB service
+ * <br/> If you wish NOT to use objects in the body of the
+ * response to update the context, you must specify a zero-length string as the value
+ * </li>
+ * <li>return_variables
+ * <br/> if this value is not specified, then the esb object
+ * names will be used both as key in the message body, and as the jbpm variable name
+ * <br/> otherwise, a comma delimited list of names of the same lenght as
+ * the return_esbNames list, must be supplied and will be used as the jbpm variable names
+ * </li>
+ * <li>processVariables
+ * <br/> If this variable is specified with a 'true' value, then
+ * process instance level variables will be used to populate the message, and values returned
+ * in the response message, will go back to process instance level, otherwise, token variables will
+ * be used, (and set with response values)
+ * </li>
+ * @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
+ *
+ */
+
+public class EsbActionHandler implements ActionHandler
+{
+
+ private static final long serialVersionUID = 1L;
+
+ public String esbCategoryName;
+ public String esbServiceName;
+
+ public String jbpmToEsb_variables;
+ public String jbpmToEsb_esbNames;
+
+ public Integer millisToWaitForResponse;
+ public String return_esbNames;
+ public String return_variables;
+
+ public Boolean processVariables;
+
+ protected Logger _logger = Logger.getLogger(getClass());
+
+ 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)
+ {
+ Invoker.invoke(request,esbCategoryName, esbServiceName);
+ return;
+ }
+
+ Message response = Invoker.invokeAndAwaitResponse
+ (request,esbCategoryName, esbServiceName, millisToWaitForResponse);
+ if (null!=response)
+ varsFromResponse(response);
+ } //________________________________
+
+ protected void varsToRequest(Message request)
+ throws Exception
+ {
+ ContextInstance ctxInstance = _token.getProcessInstance().getContextInstance();
+ Body body = request.getBody();
+ boolean global = (null==processVariables) ? false : processVariables;
+ if (null==jbpmToEsb_variables)
+ {
+ Map map = (global)? 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;
+ }
+ String[]jbpmNames = jbpmToEsb_variables.split(",");
+ // do nothing if empty list
+ if (jbpmNames.length==1 && Util.isNullString(jbpmNames[0]))
+ return;
+
+ String[]esbNames = (null==jbpmToEsb_esbNames)
+ ? jbpmNames
+ : jbpmToEsb_esbNames.split(",");
+ if (jbpmNames.length != esbNames.length)
+ throw new ConfigurationException("One to one mapping required from jbpm variables to esb names");
+
+ int index = 0;
+ for (String curr: jbpmNames)
+ {
+ Object obj = (global) ? ctxInstance.getVariable(curr)
+ : ctxInstance.getVariable(curr, _token);
+ if (null!=obj)
+ body.add(esbNames[index], obj);
+ index++;
+ }
+ } //________________________________
+
+ protected void varsFromResponse(Message response) throws Exception
+ {
+ ContextInstance ctxInstance = _token.getProcessInstance().getContextInstance();
+ Body body = response.getBody();
+ boolean global = (null==processVariables) ? false : processVariables;
+ if (null==return_esbNames)
+ {
+ Map map = (global)? 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 (global)
+ ctxInstance.setVariable(key, obj);
+ else
+ ctxInstance.setVariable(key, obj, _token);
+ }
+ }
+ return;
+ }
+ String[]esbNames = return_esbNames.split(",");
+ // do nothing if empty list
+ if (esbNames.length==1 && Util.isNullString(esbNames[0]))
+ return;
+
+ String[]jbpmNames = (null==return_variables)
+ ? esbNames
+ : return_variables.split(",");
+ if (jbpmNames.length != esbNames.length)
+ throw new ConfigurationException("One to one mapping required between esb returned variables and jbpm names");
+
+ int index = 0;
+ for (String curr: esbNames)
+ {
+ Object obj = body.get(curr);
+ String jbpmVar = jbpmNames[index];
+ Object oldVal = (global) ? ctxInstance.getVariable(jbpmVar)
+ : ctxInstance.getVariable(jbpmVar,_token);
+ if (null==oldVal)
+ {
+ if (null!=obj)
+ {
+ if (global)
+ ctxInstance.createVariable(jbpmVar, obj);
+ else
+ ctxInstance.createVariable(jbpmVar, obj, _token);
+ }
+ }
+ else
+ {
+ if (null==obj)
+ {
+ if (global)
+ ctxInstance.deleteVariable(jbpmVar);
+ else
+ ctxInstance.deleteVariable(jbpmVar, _token);
+ }
+ else
+ {
+ if (global)
+ ctxInstance.setVariable(jbpmVar,obj);
+ else
+ ctxInstance.setVariable(jbpmVar,obj,_token);
+ }
+ }
+ index++;
+ }
+ } //________________________________
+
+ 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()));
+
+ Helper.setLongValue (template,Constants.TOKEN_ID,_token.getId());
+ Helper.setStringValue(template, Constants.CURRENT_NODE_NAME, _token.getNode().getName());
+
+ ProcessInstance instance = _token.getProcessInstance();
+ Helper.setLongValue(template,Constants.PROCESS_INSTANCE_ID,instance.getId());
+
+ ProcessDefinition process = instance.getProcessDefinition();
+ Helper.setObjectValue(template ,Constants.PROCESS_DEFINITION_NAME, process.getName());
+ Helper.setIntValue (template ,Constants.PROCESS_DEFINITION_VERSION, process.getVersion());
+ Helper.setLongValue (template ,Constants.PROCESS_DEFINITION_ID, process.getId());
+
+
+ return template;
+ } //________________________________
+
+}
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandExecutorFactory.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandExecutorFactory.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandExecutorFactory.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -1,51 +0,0 @@
-/*
- * 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,
- */
-package org.jboss.soa.esb.services.jbpm.actions;
-
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.actions.impl.DefaultCommandExecutorFactoryImpl;
-
-/**
- * Factory to obtain appropriate Performer for the jBPM CommandInterpreter
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public abstract class CommandExecutorFactory
-{
-
- public abstract CommandInterpreter.CommandExecutor
- getExecutor(Message message) throws Exception;
-
-
- protected static final Object s_oSynch = new Integer(0);
-
- protected static CommandExecutorFactory _factory;
- public static CommandExecutorFactory getInstance()
- {
- if (null==_factory)
- synchronized(s_oSynch)
- {
- if (null==_factory)
- _factory=new DefaultCommandExecutorFactoryImpl();
- };
- return _factory;
- } //________________________________
-}
Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -34,6 +34,7 @@
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.CommandExecutorFactory;
import org.jboss.soa.esb.services.jbpm.Constants;
import org.jboss.soa.esb.services.jbpm.util.Helper;
import org.jbpm.JbpmConfiguration;
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandler.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandler.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandler.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -1,277 +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.net.URI;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.listeners.message.Invoker;
-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.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.util.Helper;
-import org.jboss.soa.esb.util.Util;
-import org.jbpm.context.exe.ContextInstance;
-import org.jbpm.graph.def.ActionHandler;
-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 - for ESB registry lookup
- * <li>jbpmToEsb_variables
- * <br/> if this variable missing in the jpdl (null value in the context),
- * then <b>ALL</b> context instance variables will be added to the body of the esb message using
- * the jbpm variable name as the key in the message body
- * <br/> otherwise, you can specify a comma delimited list of
- * names indicating which jbpm context variables must be added to the message body
- * <br/> if you wish NOT to add objects in the body of the
- * outgoing message, you must specify a zero-length string as the value
- * </li>
- * <li>jbpmToEsb_esbNames
- * <br/> if this value is not specified, then the jbpm variable
- * names will be used as a key to add the objects in the message body
- * <br/> otherwise, a comma delimited list of names
- * <b>of the same length as</b>
- * the jbpmToEsb_variables list, must be supplied and will be used as keys in the message body
- * </li>
- * <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>
- * <li>return_esbNames
- * <br/> If this value is missing in the jpdl (null value in the context), then an attempt will me made
- * to find <b>ALL</b> jbpm context variables in the body of the incoming message, and only those objects
- * found with a valid jbpm context variable name, will update the jbpm context
- * <br/> Otherwise, a comma delimited list of names must be supplied. These will
- * be used to obtain values from the incoming response from the ESB service
- * <br/> If you wish NOT to use objects in the body of the
- * response to update the context, you must specify a zero-length string as the value
- * </li>
- * <li>return_variables
- * <br/> if this value is not specified, then the esb object
- * names will be used both as key in the message body, and as the jbpm variable name
- * <br/> otherwise, a comma delimited list of names of the same lenght as
- * the return_esbNames list, must be supplied and will be used as the jbpm variable names
- * </li>
- * <li>processVariables
- * <br/> If this variable is specified with a 'true' value, then
- * process instance level variables will be used to populate the message, and values returned
- * in the response message, will go back to process instance level, otherwise, token variables will
- * be used, (and set with response values)
- * </li>
- * @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
- *
- */
-
-public class EsbActionHandler implements ActionHandler
-{
-
- private static final long serialVersionUID = 1L;
-
- public String esbCategoryName;
- public String esbServiceName;
-
- public String jbpmToEsb_variables;
- public String jbpmToEsb_esbNames;
-
- public Integer millisToWaitForResponse;
- public String return_esbNames;
- public String return_variables;
-
- public Boolean processVariables;
-
- protected Logger _logger = Logger.getLogger(getClass());
-
- 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)
- {
- Invoker.invoke(request,esbCategoryName, esbServiceName);
- return;
- }
-
- Message response = Invoker.invokeAndAwaitResponse
- (request,esbCategoryName, esbServiceName, millisToWaitForResponse);
- if (null!=response)
- varsFromResponse(response);
- } //________________________________
-
- protected void varsToRequest(Message request)
- throws Exception
- {
- ContextInstance ctxInstance = _token.getProcessInstance().getContextInstance();
- Body body = request.getBody();
- boolean global = (null==processVariables) ? false : processVariables;
- if (null==jbpmToEsb_variables)
- {
- Map map = (global)? 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;
- }
- String[]jbpmNames = jbpmToEsb_variables.split(",");
- // do nothing if empty list
- if (jbpmNames.length==1 && Util.isNullString(jbpmNames[0]))
- return;
-
- String[]esbNames = (null==jbpmToEsb_esbNames)
- ? jbpmNames
- : jbpmToEsb_esbNames.split(",");
- if (jbpmNames.length != esbNames.length)
- throw new ConfigurationException("One to one mapping required from jbpm variables to esb names");
-
- int index = 0;
- for (String curr: jbpmNames)
- {
- Object obj = (global) ? ctxInstance.getVariable(curr)
- : ctxInstance.getVariable(curr, _token);
- if (null!=obj)
- body.add(esbNames[index], obj);
- index++;
- }
- } //________________________________
-
- protected void varsFromResponse(Message response) throws Exception
- {
- ContextInstance ctxInstance = _token.getProcessInstance().getContextInstance();
- Body body = response.getBody();
- boolean global = (null==processVariables) ? false : processVariables;
- if (null==return_esbNames)
- {
- Map map = (global)? 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 (global)
- ctxInstance.setVariable(key, obj);
- else
- ctxInstance.setVariable(key, obj, _token);
- }
- }
- return;
- }
- String[]esbNames = return_esbNames.split(",");
- // do nothing if empty list
- if (esbNames.length==1 && Util.isNullString(esbNames[0]))
- return;
-
- String[]jbpmNames = (null==return_variables)
- ? esbNames
- : return_variables.split(",");
- if (jbpmNames.length != esbNames.length)
- throw new ConfigurationException("One to one mapping required between esb returned variables and jbpm names");
-
- int index = 0;
- for (String curr: esbNames)
- {
- Object obj = body.get(curr);
- String jbpmVar = jbpmNames[index];
- Object oldVal = (global) ? ctxInstance.getVariable(jbpmVar)
- : ctxInstance.getVariable(jbpmVar,_token);
- if (null==oldVal)
- {
- if (null!=obj)
- {
- if (global)
- ctxInstance.createVariable(jbpmVar, obj);
- else
- ctxInstance.createVariable(jbpmVar, obj, _token);
- }
- }
- else
- {
- if (null==obj)
- {
- if (global)
- ctxInstance.deleteVariable(jbpmVar);
- else
- ctxInstance.deleteVariable(jbpmVar, _token);
- }
- else
- {
- if (global)
- ctxInstance.setVariable(jbpmVar,obj);
- else
- ctxInstance.setVariable(jbpmVar,obj,_token);
- }
- }
- index++;
- }
- } //________________________________
-
- 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()));
-
- Helper.setLongValue (template,Constants.TOKEN_ID,_token.getId());
- Helper.setStringValue(template, Constants.CURRENT_NODE_NAME, _token.getNode().getName());
-
- ProcessInstance instance = _token.getProcessInstance();
- Helper.setLongValue(template,Constants.PROCESS_INSTANCE_ID,instance.getId());
-
- ProcessDefinition process = instance.getProcessDefinition();
- Helper.setObjectValue(template ,Constants.PROCESS_DEFINITION_NAME, process.getName());
- Helper.setIntValue (template ,Constants.PROCESS_DEFINITION_VERSION, process.getVersion());
- Helper.setLongValue (template ,Constants.PROCESS_DEFINITION_ID, process.getId());
-
-
- return template;
- } //________________________________
-
-}
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/MessageFacadeFactory.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/MessageFacadeFactory.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/MessageFacadeFactory.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -1,52 +0,0 @@
-/*
- * 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,
- */
-package org.jboss.soa.esb.services.jbpm.actions;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.services.jbpm.actions.impl.DefaultMessageFacadeFactoryImpl;
-
-/**
- * Factory to obtain appropriate MessageManipulator for jBPM SingleCommandProcessors
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public abstract class MessageFacadeFactory
-{
-
- public abstract SingleCommandProcessor.MessageFacade
- getPreProcessor(ConfigTree config) throws ConfigurationException;
-
-
- protected static final Object s_oSynch = new Integer(0);
-
- private static MessageFacadeFactory _factory;
- public static MessageFacadeFactory getInstance()
- {
- if (null==_factory)
- synchronized(s_oSynch)
- {
- if (null==_factory)
- _factory=new DefaultMessageFacadeFactoryImpl();
- };
- return _factory;
- } //________________________________
-}
Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessor.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessor.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessor.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -29,6 +29,7 @@
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.MessageFacadeFactory;
/**
*
Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -28,8 +28,8 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.CommandExecutorFactory;
import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.actions.CommandExecutorFactory;
import org.jboss.soa.esb.services.jbpm.actions.CommandInterpreter;
import org.jboss.soa.esb.services.jbpm.actions.CommandInterpreter.CommandExecutor;
import org.jboss.soa.esb.services.jbpm.util.Helper;
Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -26,8 +26,8 @@
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.MessageFacadeFactory;
import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.MessageFacadeFactory;
import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor;
import org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor.MessageFacade;
import org.jboss.soa.esb.services.jbpm.actions.impl.facades.DeployProcessDefinitionFacade;
Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/FacadeUtil.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/FacadeUtil.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/FacadeUtil.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -69,7 +69,7 @@
{
if (Util.isNullString(esbName) || Util.isNullString(jbpmName))
throw new ConfigurationException("Either 'name' or the pair '"
- +Constants.JBPM_VARNAME_TAG+"' and"
+ +Constants.JBPM_VARNAME_TAG+"' and "
+Constants.ESB_VARNAME_TAG +"' must be specified");
}
String value = curr.getAttribute("value");
Modified: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandlerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandlerUnitTest.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/EsbActionHandlerUnitTest.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -36,6 +36,7 @@
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.actionhandlers.EsbActionHandler;
import org.jboss.soa.esb.services.jbpm.util.Helper;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.ExecutionContext;
Modified: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessorUnitTest.java 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/SingleCommandProcessorUnitTest.java 2007-04-24 20:08:00 UTC (rev 11312)
@@ -113,7 +113,8 @@
assertTrue(Constants.RETCODE_OK.equals(ret));
// Keep the variables for comparison in future steps
- ConfigTree[] vars = actions[index].getFirstChild("Variables").getChildren("variable");
+ ConfigTree[] vars = actions[index].getFirstChild(Constants.VARIABLES_TAG)
+ .getChildren(Constants.ONE_VARIABLE_TAG);
command = new SingleCommandProcessor(actions[index++]);
response = command.process(Helper.commandMessageTemplate());
@@ -156,6 +157,7 @@
}
catch (Exception e)
{
+ e.printStackTrace();
_logger.error(e);
assertTrue(false);
}
Modified: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml 2007-04-24 18:47:59 UTC (rev 11311)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml 2007-04-24 20:08:00 UTC (rev 11312)
@@ -2,7 +2,7 @@
<action name="TestDeploy"
class="org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor"
command="DeployProcessDefinition">
- <ProcessDefinitionXml version="1.0" encoding="UTF-8">
+ <process-definition-xml version="1.0" encoding="UTF-8">
<process-definition
xmlns="urn:jbpm.org:jpdl-3.1"
name="simple"
@@ -19,29 +19,29 @@
</state>
<end-state name="end"></end-state>
</process-definition>
- </ProcessDefinitionXml>
+ </process-definition-xml>
</action>
<action name="aNewInstance"
class="org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor"
command="NewProcessInstanceCommand"
- processDefinitionName="simple"
+ process-definition-name="simple"
actor="FrankSinatra"
>
- <Variables>
- <variable esbName="eVar1" jbpmName="j1" value="AAAbbb111" />
- <variable esbName="eVar2" jbpmName="vJ22" value="998877" />
- </Variables>
+ <variables>
+ <variable esb-name="eVar1" jbpm-name="j1" value="AAAbbb111" />
+ <variable esb-name="eVar2" jbpm-name="vJ22" value="998877" />
+ </variables>
</action>
<action name="nowGetItBack"
class="org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor"
command="GetProcessInstanceCommand"
>
- <Variables>
- <variable esbName="yyy" jbpmName="vJ22" />
- <variable esbName="xxx" jbpmName="j1" />
- </Variables>
+ <variables>
+ <variable esb-name="yyy" jbpm-name="vJ22" />
+ <variable esb-name="xxx" jbpm-name="j1" />
+ </variables>
</action>
<action name="nowCancelIt"
@@ -53,7 +53,7 @@
<action name="getItAgain"
class="org.jboss.soa.esb.services.jbpm.actions.SingleCommandProcessor"
command="GetProcessInstanceCommand"
- includeAllVariables="true"
+ include-all-variables="true"
>
</action>
More information about the jboss-svn-commits
mailing list