[jboss-svn-commits] JBL Code SVN: r16704 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product: rosetta/src/org/jboss/soa/esb/util and 16 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 20 11:14:50 EST 2007
Author: kurt.stam at jboss.com
Date: 2007-11-20 11:14:49 -0500 (Tue, 20 Nov 2007)
New Revision: 16704
Added:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/Command.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/CancelProcessInstanceFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageHelper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java
Removed:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/AbstractCommandVehicle.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/util/AbstractCommandVehicleUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetProcessInstanceFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetTaskInstanceFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetTaskListFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/StartWorkOnTaskFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/TaskInstanceEndFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariablesFacade.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/util/Helper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreterUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/impl/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/message/mapping/ObjectMapper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/readme.txt
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/esb_actions/ProcessInfo.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/process_actions/MyBPMActionHandler.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml
Log:
JBESB-1301 Removing some jBPM commands, making the calls one way.
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/message/mapping/ObjectMapper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/message/mapping/ObjectMapper.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/message/mapping/ObjectMapper.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -251,6 +251,7 @@
if (path.length==3) {
object = MVEL.getProperty(path[2], object);
}
+ logger.debug("expression=" + expression + " value=" + object);
return object;
}
/**
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/AbstractCommandVehicle.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/AbstractCommandVehicle.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/AbstractCommandVehicle.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,139 +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.util;
-
-import java.io.Serializable;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-/**
- * Auxiliary class that deals with implementation details of event messages handled by ESB aware applications.
- * <p/>The '_command' enumeration is inteded to contain all accepted command codes, and should be provided
- * by all classes that extend AbstractCommandMessage
- * <br/>Values that this class is able to render are (arbitrarily) stored in a Map<String,Object>
- * contained in the message body as a named Object with key getCommandValuesTag()
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public abstract class AbstractCommandVehicle implements Serializable
-{
- /**
- * Provide a name for the named object to look for in the ESB Message body.
- * @return String : intended to be used as the key in Message.getBody().get(arg)
- */
- public abstract String getCommandValuesTag();
-
- /**
- * The key for the command operation code in the command values map
- * @return String : intended to be used as the key in _values.get(arg)
- */
- public abstract String getCommandOpcodeKey();
-
- /**
- * Valid operator for this command vehicle, from String value
- * @param value - the String value of the operator
- * @return the Enum value that represents arg0
- */
- public abstract Enum operatorFromString(String value);
-
- private Logger _logger = Logger.getLogger(AbstractCommandVehicle.class);
-
- protected Map<String,Object>_values = new HashMap<String,Object>();
-
- protected Enum _operator;
- public Enum getOperator() { return _operator; }
- protected void setOperator(Enum operator) { _operator = operator; }
-
- protected AbstractCommandVehicle(Enum command)
- {
- _operator = command;
- }
-
- /**
- * Populate this event's associated values contained in the ESB message
- * <br/>Values that this class is able to render are expected to be in a Map<String,Object>
- * contained in the message body as a named Object (key=getCommandValuesTag())
- * @param message : Message - the vehicle of this command
- */
- @SuppressWarnings("unchecked")
- protected AbstractCommandVehicle(Message message)
- {
- Object obj = message.getBody().get(getCommandValuesTag());
- if (! (obj instanceof Map))
- throw new IllegalArgumentException("Message command values must be stored as a Map<String,Object>");
- _values.putAll((Map)obj);
- _operator = operatorFromString((String)_values.get(getCommandOpcodeKey()));
- _values.remove(getCommandValuesTag());
- } //________________________________
-
- /**
- * Instantiate a new message, and put values where they belong
- * @return Message - a fresh Message, with the command values in the appropriate spot
- */
- public Message toCommandMessage()
- {
- Message message = MessageFactory.getInstance().getMessage();
- URI uri = null;
- try { uri = new URI(UUID.randomUUID().toString()); }
- catch (URISyntaxException e)
- {
- _logger.fatal("Problem with UUID.randomUUID() - This should not happen");
- return null;
- }
- message.getHeader().getCall().setMessageID(uri);
-
- _values.put(getCommandOpcodeKey(), _operator.toString());
- message.getBody().add(getCommandValuesTag(), _values);
-
- return message;
- } //________________________________
-
- /**
- * Clean all values from this command object
- * <br/>Operator will still remain the same as before
- * @return Map<String,Object> the old contents of _values
- */
- public Map <String,Object>cleanValues()
- {
- Map <String,Object> oldVals = _values;
- _values = new HashMap<String,Object>();
- return oldVals;
- } //________________________________
-
- protected Object setValue(String key, Object value)
- {
- if (null==key)
- throw new IllegalArgumentException("Key must not be null");
- Object oldVal = _values.get(key);
- if (null==value)
- _values.remove(key);
- else
- oldVal = _values.put(key, value);
- return oldVal;
- } //________________________________
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/util/AbstractCommandVehicleUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/util/AbstractCommandVehicleUnitTest.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/util/AbstractCommandVehicleUnitTest.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,85 +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.util;
-
-import junit.framework.TestCase;
-
-import org.jboss.soa.esb.message.Message;
-
-/**
- * AbstractCommandVehicle unit tests.
- * @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
- */
-public class AbstractCommandVehicleUnitTest extends TestCase {
-
- static class MyVehicle extends AbstractCommandVehicle
- {
- private static final long serialVersionUID = 1L;
- @Override
- public String getCommandOpcodeKey() { return "myCmdOpcodeKey"; }
- @Override
- public String getCommandValuesTag() { return "CMD_VALUES_TAG"; }
- @Override
- public Operation operatorFromString(String value) {return Operation.valueOf(value); }
-
- public static final String VAL1 = "value1_tag";
-
- public enum Operation
- {
- oper1
- ,oper2
- }
-
- public MyVehicle(Enum command) { super(command); }
- public MyVehicle(Message message) { super(message); }
-
- public void setVal1(String obj) { super.setValue(VAL1, obj); }
- public String getVal1() { return (String)_values.get(VAL1); }
- }
-
- public void test_01()
- {
- String compareValue = "12345";
-
- MyVehicle vh1 = new MyVehicle(MyVehicle.Operation.oper1);
- vh1.setVal1(compareValue);
- Message msg = vh1.toCommandMessage();
-
- MyVehicle newVh = new MyVehicle(msg);
- assertEquals(MyVehicle.Operation.oper1, newVh.getOperator());
- assertEquals(compareValue, newVh.getVal1());
- }
-
- public void test_02()
- {
- String compareValue = "ZZZZZZZZZZZZZZ";
-
- MyVehicle vh1 = new MyVehicle(MyVehicle.Operation.oper2);
- vh1.setVal1(compareValue);
- Message msg = vh1.toCommandMessage();
-
- MyVehicle newVh = new MyVehicle(msg);
- assertEquals(MyVehicle.Operation.oper2, newVh.getOperator());
- assertEquals(compareValue, newVh.getVal1());
- }
-
-}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/readme.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/readme.txt 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/readme.txt 2007-11-20 16:14:49 UTC (rev 16704)
@@ -12,28 +12,19 @@
'[SchemaExport] schema export complete' to appear on the console.
4. Switch back to "Window2", type 'ant startProcess'.
5. Switch back to Application Server console to see the output from the ESB.
- 6. To undeploy the esb archive, type 'ant undeploy' ("Window1").
+
+ Sample Output from "ant startProcess":
+ ======================================
+ 10:42:14,386 INFO [MessageSpy] Body: Start It Up
+ 10:42:14,463 INFO [ProcessInfo] Token ID: 1
+ 10:42:14,463 INFO [ProcessInfo] Process Name: null
+ 10:42:14,463 INFO [ProcessInfo] Process Version: null
+ 10:42:14,463 INFO [MessageSpy] Body: Start It Up
+
+ 6. In the http://localhost:8080/jbpm-console, you can check that the "processDefinition2" is
+ deployed and that there is one running instance.
+ 7. To undeploy the esb archive, type 'ant undeploy' ("Window1").
-Sample Output from "ant startProcess":
-======================================
-10:42:14,386 INFO [MessageSpy] Body: Start It Up
-10:42:14,463 INFO [ProcessInfo] Token ID: 1
-10:42:14,463 INFO [ProcessInfo] Process Name: null
-10:42:14,463 INFO [ProcessInfo] Process Version: null
-10:42:14,463 INFO [MessageSpy] Body: Start It Up
-10:42:14,482 WARN [ProxyWarnLog] Narrowing proxy to class org.jbpm.graph.node.StartState - this operation breaks ==
-10:42:15,182 INFO [STDOUT] 1********** Begin Service 1 ***********
-10:42:15,263 INFO [STDOUT] In: Start It Up
-10:42:15,263 INFO [STDOUT] Out: Service 1 Start It Up
-10:42:15,263 INFO [STDOUT] ************ End Service 1 ************
-10:42:15,747 INFO [STDOUT] 2********** Begin Service 2 ***********
-10:42:15,747 INFO [STDOUT] In: Start It Up
-10:42:15,747 INFO [STDOUT] Out: Service 2 Start It Up
-10:42:15,748 INFO [STDOUT] ************ End Service 2 ************
-10:42:16,889 INFO [STDOUT] 3********** Begin Service 3 ***********
-10:42:16,890 INFO [STDOUT] In: Start It Up
-10:42:16,890 INFO [STDOUT] Out: Service 3 Start It Up
-10:42:16,890 INFO [STDOUT] ************ End Service 3 ************
-10:42:17,596 INFO [STDOUT] Executed by the process, not by the ESB
-10:42:17,653 INFO [MessageSpy] Body: Start It Up
-10:42:18,637 INFO [MessageSpy] Body: Start It Up
+
+
+
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/esb_actions/ProcessInfo.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/esb_actions/ProcessInfo.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/esb_actions/ProcessInfo.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -22,7 +22,6 @@
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
import org.apache.log4j.Logger;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/process_actions/MyBPMActionHandler.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/process_actions/MyBPMActionHandler.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/process_actions/MyBPMActionHandler.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -20,10 +20,8 @@
*/
package org.jboss.soa.esb.samples.quickstarts.bpm_orchestration1.process_actions;
-import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.Token;
public class MyBPMActionHandler implements ActionHandler
{
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4
___________________________________________________________________
Name: svn:ignore
+ build
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/CommandExecutorFactory.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -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;
-
-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/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -95,23 +95,23 @@
// ,AbstractGetObjectBaseCommand
// ,AsynchronousCommand
,CancelProcessInstanceCommand
- ,CancelTokenCommand
- ,CancelWorkOnTaskCommand
+// ,CancelTokenCommand
+// ,CancelWorkOnTaskCommand
// ,ChangeProcessInstanceVersionCommand
// ,Command
// ,CommandService
// ,CompositeCommand
// ,GetProcessDefinitionCommand
- ,GetProcessInstanceCommand
+// ,GetProcessInstanceCommand
// ,GetProcessInstancesCommand
- ,GetTaskInstanceCommand
- ,GetTaskListCommand
+// ,GetTaskInstanceCommand
+// ,GetTaskListCommand
,NewProcessInstanceCommand
,SignalCommand
,StartProcessInstanceCommand
- ,StartWorkOnTaskCommand
- ,TaskInstanceEndCommand
- ,VariablesCommand
+// ,StartWorkOnTaskCommand
+// ,TaskInstanceEndCommand
+// ,VariablesCommand
;
}
}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/MessageFacadeFactory.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,53 +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;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-import org.jboss.soa.esb.services.jbpm.actions.impl.DefaultMessageFacadeFactoryImpl;
-
-/**
- * Factory to obtain appropriate MessageManipulator for jBPM BpmProcessor
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public abstract class MessageFacadeFactory
-{
-
- public abstract BpmProcessor.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/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -37,11 +37,10 @@
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.mapping.ObjectMapper;
import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.util.Helper;
+import org.jboss.soa.esb.services.jbpm.mapping.MessageHelper;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.Node;
@@ -254,22 +253,22 @@
Call call = template.getHeader().getCall();
call.setMessageID(new URI(UUID.randomUUID().toString()));
- Helper.setLongValue(template, Constants.TOKEN_ID, _token.getId());
+ MessageHelper.setLongValue(template, Constants.TOKEN_ID, _token.getId());
Node node = _token.getNode();
if (null != node)
- Helper.setStringValue(template, Constants.CURRENT_NODE_NAME, node
+ MessageHelper.setStringValue(template, Constants.CURRENT_NODE_NAME, node
.getName());
ProcessInstance instance = _token.getProcessInstance();
- Helper.setLongValue(template, Constants.PROCESS_INSTANCE_ID, instance
+ MessageHelper.setLongValue(template, Constants.PROCESS_INSTANCE_ID, instance
.getId());
ProcessDefinition process = instance.getProcessDefinition();
- Helper.setObjectValue(template, Constants.PROCESS_DEFINITION_NAME,
+ MessageHelper.setObjectValue(template, Constants.PROCESS_DEFINITION_NAME,
process.getName());
- Helper.setIntValue(template, Constants.PROCESS_DEFINITION_VERSION,
+ MessageHelper.setIntValue(template, Constants.PROCESS_DEFINITION_VERSION,
process.getVersion());
- Helper.setLongValue(template, Constants.PROCESS_DEFINITION_ID, process
+ MessageHelper.setLongValue(template, Constants.PROCESS_DEFINITION_ID, process
.getId());
return template;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -22,14 +22,17 @@
package org.jboss.soa.esb.services.jbpm.actions;
+import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionLifecycle;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.couriers.CourierException;
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.cmd.CommandExecutor;
+import org.jboss.soa.esb.services.jbpm.mapping.MessageFacade;
+import org.jbpm.JbpmException;
/**
*
@@ -37,52 +40,58 @@
* Part of the message content will be taken from constructor time configuration
* (from the action configuration XML)
*
-* @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+* @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+* @author <a href="mailto:kurt.stam at jboss.com">Kurt Stam</a>
*/
-public class BpmProcessor extends CommandInterpreter
+public class BpmProcessor implements ActionLifecycle
{
+ protected MessageFacade _stuffer;
+ protected ConfigTree _config;
+ private static Logger _logger = Logger.getLogger(BpmProcessor.class);
public static final String COMMAND_ATTRIBUTE_TAG = "command";
+ public void destroy() throws ActionLifecycleException {
+ _logger.info("destroy() invoked");
+ }
+ public void initialise() throws ActionLifecycleException {
+ _logger.info("initialise() invoked - config="+_config);
+ if (null==_config)
+ _config = new ConfigTree("autoGenerated");
+ }
+
public BpmProcessor(ConfigTree config) throws ConfigurationException
{
- super(config);
+ _config = config;
+ checkMyParms();
}
public Constants.OpCode getOpCode() { return _stuffer.getOpCode(); }
- @Override
+
protected void checkMyParms() throws ConfigurationException
{
- _stuffer = MessageFacadeFactory.getInstance().getPreProcessor(_config);
- } // _______________________________
-
- @Override
- public Message process(Message message)
- throws MalformedEPRException, CourierException, ActionProcessingException
+ _stuffer = MessageFacade.getFacade(_config);
+ }
+
+ public void process(Message message)
+ throws ActionProcessingException
{
message.getBody().add(Constants.COMMAND_CODE,getOpCode().toString());
- _stuffer.preFormat(message);
- Message response = super.process(message);
- return _stuffer.postFormat(response);
- } // _______________________________
-
- protected MessageFacade _stuffer;
- public interface MessageFacade
- {
- /**
- * Obtain the operation code that this preprocessor will force into the command message
- * @return Constants.OpCode
- */
- public Constants.OpCode getOpCode();
- /**
- * Some message values are fixed at action configuration time (from the jboss-esb.xml).
- * <br/>This method is responsible of stuffing these static values into every Message
- * before passing it to the generic CommandInterpreter process(Message) method
- * <br/>Some of the Message content will thus come from configuration XML, and some will
- * be the users' responsibility (e.g. processId, tokenId, etc)
- * <br/>Variable name mapping between esb and jBPM is also handled by this interface
- * @param message Message - Into which the static values will be added
- */
- public void preFormat(Message request);
- public Message postFormat(Message response);
+ _stuffer.setJBPMContextParameters(message);
+ try
+ {
+ CommandExecutor commandExecutor = CommandExecutor.getInstance();
+ String commandString = (String)message.getBody().get(Constants.COMMAND_CODE);
+ commandExecutor.getCommand(commandString).execute(message);
+ }
+ catch (JbpmException e)
+ {
+ throw new ActionProcessingException(e.getMessage(), e);
+ }
+ catch (Exception e)
+ {
+ _logger.error(e.getMessage(), e);
+ throw new ActionProcessingException(e.getMessage(), e);
+ }
}
+
}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreter.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,232 +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 org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.actions.ActionLifecycle;
-import org.jboss.soa.esb.actions.ActionLifecycleException;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.actions.ActionProcessingFaultException;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.couriers.CourierException;
-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;
-import org.jbpm.JbpmException;
-import org.jbpm.command.Command;
-import org.jbpm.command.CommandService;
-import org.jbpm.command.impl.CommandServiceImpl;
-
-/**
- *
- * jBPM command interpreter.
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public class CommandInterpreter implements ActionLifecycle
-{
- public void destroy() throws ActionLifecycleException {
- _logger.info("destroy() invoked");
- }
- public void initialise() throws ActionLifecycleException {
- _logger.info("initialise() invoked - config="+_config);
- if (null==_config)
- _config = new ConfigTree("autoGenerated");
-
- }
-
- public CommandInterpreter(ConfigTree config) throws ConfigurationException
- {
- _config = config;
- checkMyParms();
- } // ________________________________
-
- /**
- * If the end state is reached within a jBPM process, then the ESB will propagate back
- * an appropriate error message to the sender.
- *
- * @param message
- * @return
- * @throws MalformedEPRException
- * @throws CourierException
- * @throws ActionProcessingException
- */
-
- public Message process(Message message)
- throws MalformedEPRException, CourierException, ActionProcessingException
- {
- Message response = null;
- try
- {
- response = CommandExecutorFactory.getInstance().getExecutor(message).execute(message);
- }
- catch (JbpmException e)
- {
- _logger.error(e.getMessage(), e);
-
- if (endState(e))
- {
- _logger.info("End-state reached for jBPM process.");
-
- /*
- * Throw an exception so that the fault message can be
- * propagated back to the sender.
- */
-
- throw new ActionProcessingFaultException("jBPM end state reached!");
- }
- else
- throw new ActionProcessingException(e.getMessage(), e);
- }
- catch (Exception e)
- {
- _logger.error(e.getMessage(), e);
- throw new ActionProcessingException(e.getMessage(), e);
- }
-
- return response;
- } //________________________________
-
- public static Message doTheJob(Command command) throws JbpmException
- {
- Message response = Helper.commandMessageTemplate();
- Body body = response.getBody();
-
- try
- {
- Object obj = getJbpmCommandService().execute(command);
- body.add(Constants.RETURN_CODE, Constants.RETCODE_OK);
- if (null!=obj)
- body.add(Constants.JBPM_RETURN_OBJECT, obj);
- }
- catch (JbpmException e)
- {
- // why do we do this when response will clearly not be returned?!
- // http://jira.jboss.com/jira/browse/JBESB-1272
-
- body.add(Constants.RETURN_CODE, Constants.RETCODE_EXCEPTION);
- body.add(Constants.EXCEPTION, e);
- throw e;
- }
-
- return response;
- } //________________________________
-
- /**
- * Should this class need any extra configuration, this is the placeholder where to check
- * if configuration is OK.
- * @throws ConfigurationException
- */
- protected void checkMyParms() throws ConfigurationException
- {
- } // _______________________________
-
- /**
- * Encapsulate obtention of jBPM CommandService here
- * <br/>If it can't be cached, we only need to change this method.
- * @return CommandService
- */
- public static CommandService getJbpmCommandService()
- {
- if (null== s_jbpmService)
- synchronized (s_oSynch)
- {
- if (null!= s_jbpmService)
- return s_jbpmService;
-
- if (null==s_jbpmConfig)
- s_jbpmConfig = JbpmConfiguration.getInstance();
- s_jbpmService = new CommandServiceImpl(s_jbpmConfig);
- }
- return s_jbpmService;
- } //________________________________
-
- protected static JbpmConfiguration getJbpmConfig()
- {
- if (null== s_jbpmConfig)
- synchronized (s_oSynch)
- {
- if (null==s_jbpmConfig)
- s_jbpmConfig = JbpmConfiguration.getInstance();
- }
- return s_jbpmConfig;
- } //________________________________
-
- /**
- * Set an ad hoc jbpm configuration (generally used for testing)
- * @param xmlConfig String - The jbpm.cfg.xml compliant xml string
- * @throws Exception - If jbpm configuration was already set
- */
- public static void setJbpmConfig(String xmlConfig) throws Exception
- {
- if (null== s_jbpmConfig)
- synchronized (s_oSynch)
- {
- if (null==s_jbpmConfig)
- {
- s_jbpmConfig = JbpmConfiguration.getInstance(xmlConfig);
- return;
- }
- }
- throw new Exception("Jbpm configuration has already been set");
- } //________________________________
-
- protected ConfigTree _config;
- private static Logger _logger = Logger.getLogger(CommandInterpreter.class);
-
- private static final Object s_oSynch = new Integer(0);
- private static JbpmConfiguration s_jbpmConfig;
- private static CommandService s_jbpmService;
-
- private final String END_STATE = "couldn't signal token 'Token(/)' : node 'EndState(end-state1)'";
-
- /*
- * Would be nice if JbpmExceptions contained a fault code. Or had more subclasses
- * of JbpmException.
- */
-
- private final boolean endState (JbpmException ex)
- {
- Throwable thrw = ex;
-
- while (thrw != null)
- {
- if (thrw.getMessage().contains(END_STATE))
- return true;
- else
- thrw = thrw.getCause();
- }
-
- return false;
- }
-
- public interface CommandExecutor
- {
- public Message execute (Message message) throws Exception;
- }
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultCommandExecutorFactoryImpl.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,472 +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.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.mapping.ObjectMapper;
-import org.jboss.soa.esb.services.jbpm.CommandExecutorFactory;
-import org.jboss.soa.esb.services.jbpm.Constants;
-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;
-import org.jbpm.JbpmContext;
-import org.jbpm.JbpmException;
-import org.jbpm.command.CancelProcessInstanceCommand;
-import org.jbpm.command.CancelTokenCommand;
-import org.jbpm.command.CancelWorkOnTaskCommand;
-import org.jbpm.command.Command;
-import org.jbpm.command.GetProcessInstanceCommand;
-import org.jbpm.command.GetTaskInstanceCommand;
-import org.jbpm.command.GetTaskListCommand;
-import org.jbpm.command.NewProcessInstanceCommand;
-import org.jbpm.command.SignalCommand;
-import org.jbpm.command.StartProcessInstanceCommand;
-import org.jbpm.command.StartWorkOnTaskCommand;
-import org.jbpm.command.TaskInstanceEndCommand;
-import org.jbpm.command.VariablesCommand;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.jbpm.taskmgmt.exe.TaskInstance;
-
-/**
- * Default implementation of a performer factory for the CommandInterpreter
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public class DefaultCommandExecutorFactoryImpl extends CommandExecutorFactory
-{
-
- @Override
- public CommandExecutor getExecutor(Message message) throws Exception
- {
- String strCommand = (String)message.getBody().get(Constants.COMMAND_CODE);
- Constants.OpCode opCode = Constants.OpCode.valueOf(strCommand);
- CommandExecutor ret = _values.get(opCode);
- if (null==ret)
- throw new Exception(opCode.toString()+" not implemented via jBossESB message");
- return ret;
- }
-
- protected Logger _logger = Logger.getLogger(this.getClass());
-
- protected static final CommandExecutor DEPLOY_PROCESS_DEF_EXECUTOR = new CommandExecutor()
- {
- public Message execute(Message request) throws JbpmException
- {
- Object obj = Helper.getObjectValue(request, Constants.PROCESS_DEFINITION);
- if (null==obj)
- {
- obj = ProcessDefinition.parseXmlString
- ((String)Helper.getObjectValue(request,Constants.PROCESS_DEFINITION_XML));
- }
- final ProcessDefinition def = (ProcessDefinition)obj;
- Message response = CommandInterpreter.doTheJob(
- new Command()
- {
- private static final long serialVersionUID = 1L;
- ProcessDefinition _def = def;
- public Object execute(JbpmContext jbpmCtx) throws Exception
- {
- jbpmCtx.deployProcessDefinition(_def);
- return null;
- }
- });
- Helper.setObjectValue(response, Constants.PROCESS_DEFINITION_NAME ,def.getName());
- Helper.setObjectValue(response, Constants.PROCESS_DEFINITION_ID ,def.getId());
- Helper.setObjectValue(response, Constants.PROCESS_DEFINITION_VERSION,def.getVersion());
- return response;
- }
- };
-
- protected static final CommandExecutor CANCEL_PROCESS_INSTANCE_EXECUTOR = new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- long processId = Helper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
- return CommandInterpreter.doTheJob(new CancelProcessInstanceCommand(processId));
- } // _______________________________
- };
-
- protected static final CommandExecutor CANCEL_TOKEN_EXECUTOR = new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- long tokenId = Helper.getLongValue(request,Constants.TOKEN_ID);
- return CommandInterpreter.doTheJob(new CancelTokenCommand(tokenId));
- } // _______________________________
- };
-
- protected static final CommandExecutor CANCEL_WORK_ON_TASK_EXECUTOR = new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- long taskId = Helper.getLongValue(request,Constants.TASK_INSTANCE_ID);
- return CommandInterpreter.doTheJob(new CancelWorkOnTaskCommand(taskId));
- } // _______________________________
- };
-
- protected static final CommandExecutor GET_PROCESS_INSTANCE_EXECUTOR=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- Boolean includeLogs = Helper.getBooleanValue(request, Constants.INCLUDE_LOGS);
- if (includeLogs==null) {
- includeLogs=false;
- }
- GetProcessInstanceCommand command = new GetProcessInstanceCommand(0,true,includeLogs);
- Long id = Helper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
- if (null!=id)
- command.setProcessInstanceId(id);
- else
- {
- id = Helper.getLongValue(request, Constants.TOKEN_ID);
- if (null!=id)
- command.setTokenId(id);
- else
- {
- id = Helper.getLongValue(request, Constants.TASK_INSTANCE_ID);
- if (null!=id)
- command.setTaskInstanceId(id);
- else
- throw new Exception
- ("Either <"+Constants.PROCESS_INSTANCE_ID
- +"> or <"+Constants.TOKEN_ID
- +"> or <"+Constants.TASK_INSTANCE_ID
- +"> object must be specified in Message body to know what to retrieve");
-
- }
-
- }
- Boolean includeVars = Helper.getBooleanValue(request, Constants.INCLUDE_VARIABLES);
- if (null!=includeVars)
- command.setIncludeAllVariables(includeVars);
-
- Message response = CommandInterpreter.doTheJob(command);
-
- Body body = response.getBody();
- Object obj = body.get(Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof ProcessInstance)
- {
- ProcessInstance inst = (ProcessInstance)obj;
- Helper.setLongValue(response, Constants.PROCESS_INSTANCE_ID, inst.getId());
- Helper.setBooleanValue(response, Constants.HAS_ENDED, inst.hasEnded());
-
- Token token = inst.getRootToken();
- Helper.setLongValue(response, Constants.TOKEN_ID,token.getId());
- Helper.setStringValue(response, Constants.CURRENT_NODE_NAME, token.getNode().getName());
-
- ProcessDefinition def = inst.getProcessDefinition();
- Helper.setStringValue(response, Constants.PROCESS_DEFINITION_NAME,def.getName());
- Helper.setIntValue(response, Constants.PROCESS_DEFINITION_VERSION,def.getVersion());
- Helper.setLongValue(response, Constants.PROCESS_DEFINITION_ID,def.getId());
- }
- return response;
- } // _______________________________
- };
-
- protected static final CommandExecutor GET_TASK_INSTANCE_EXECUTOR=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- long taskId = Helper.getLongValue(request,Constants.TASK_INSTANCE_ID);
- Boolean includeLogs = Helper.getBooleanValue(request, Constants.INCLUDE_LOGS);
- if (includeLogs==null) {
- includeLogs=false;
- }
- GetTaskInstanceCommand command = new GetTaskInstanceCommand(taskId,true,includeLogs);
- String[] vars = (String[])Helper.getObjectValue(request,Constants.VARIABLE_NAMES_ARRAY);
- if (null!=vars)
- {
- if (vars.length < 1)
- command.setIncludeAllVariables(false);
- else
- command.setVariablesToInclude(vars);
- }
- else
- {
- Boolean includeVars = Helper.getBooleanValue(request, Constants.INCLUDE_VARIABLES);
- if (null!=includeVars)
- command.setIncludeAllVariables(includeVars);
- }
-
- Message response = CommandInterpreter.doTheJob(command);
-
- Object obj = Helper.getObjectValue(response, Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof TaskInstance)
- {
- TaskInstance inst = (TaskInstance)obj;
- Helper.setLongValue(response, Constants.PROCESS_INSTANCE_ID ,inst.getProcessInstance().getId());
- Helper.setLongValue(response, Constants.TOKEN_ID ,inst.getToken().getId());
- Helper.setLongValue(response, Constants.TASK_INSTANCE_ID ,inst.getId());
- }
-
- return response;
- } // _______________________________
- };
-
- protected static final CommandExecutor GET_TASK_LIST_PERFORMER=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- String[] actors = (String[])Helper.getObjectValue(request,Constants.ACTOR_NAMES_ARRAY);
- if (null==actors || actors.length<1)
- throw new Exception(Helper.argumentException(Constants.ACTOR_NAMES_ARRAY));
-
- GetTaskListCommand command = new GetTaskListCommand(actors);
-
- String[] vars = (String[])Helper.getObjectValue(request,Constants.VARIABLE_NAMES_ARRAY);
- if (null!=vars)
- {
- if (vars.length < 1)
- command.setIncludeAllVariables(false);
- else
- command.setVariablesToInclude(vars);
- }
- else
- {
- Boolean includeVars = Helper.getBooleanValue(request, Constants.INCLUDE_VARIABLES);
- if (null!=includeVars)
- command.setIncludeAllVariables(includeVars);
- }
-
- return CommandInterpreter.doTheJob(command);
- } // _______________________________
- };
-
- protected static final CommandExecutor SIGNAL_EXECUTOR=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- SignalCommand command = new SignalCommand();
- // try token id first
- Long tokenId = Helper.getLongValue(request,Constants.TOKEN_ID);
- if (null== tokenId)
- {
- // now try with the process id (use root token)
- Long processId = Helper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
- if (null== processId)
- throw new Exception("Either <"+Constants.TOKEN_ID+"> or <"+Constants.PROCESS_INSTANCE_ID
- +"> object must be specified in Message body to know who to signal");
- ProcessInstance inst = (ProcessInstance)CommandInterpreter.getJbpmCommandService()
- .execute(new GetProcessInstanceCommand(processId));
- tokenId = inst.getRootToken().getId();
- }
- command.setTokenId(tokenId);
-
- String transition = Helper.getStringValue(request, Constants.TRANSITION_NAME);
- if (null!=transition)
- command.setTransitionName(transition);
-
- Map map = (Map)Helper.getObjectValue(request, Constants.VARIABLE_VALUES);
- if (null!=map)
- command.setVariables(map);
-
- Message response = CommandInterpreter.doTheJob(command);
- Object obj = Helper.getObjectValue(response, Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof Token)
- {
- Token token = (Token)obj;
- Helper.setLongValue(response, Constants.TOKEN_ID ,token.getId());
- Helper.setLongValue(response, Constants.PROCESS_INSTANCE_ID, token.getProcessInstance().getId());
- Helper.setBooleanValue(response, Constants.HAS_ENDED ,token.hasEnded());
- }
- return response;
- } // _______________________________
- };
-
- protected static final CommandExecutor START_WORK_ON_TASK_EXECUTOR=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- StartWorkOnTaskCommand command = new StartWorkOnTaskCommand();
- Long taskId = Helper.getLongValue(request, Constants.TASK_INSTANCE_ID);
- if (null!=taskId)
- command.setTaskInstanceId(taskId);
- Boolean overwrite = Helper.getBooleanValue(request, Constants.OVERWRITE_SWIMLANE);
- if (null!=overwrite)
- command.setOverwriteSwimlane(overwrite);
- return CommandInterpreter.doTheJob(command);
- } // _______________________________
- };
-
- protected static final CommandExecutor TASK_INSTANCE_END_EXECUTOR=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- TaskInstanceEndCommand command = new TaskInstanceEndCommand();
- Long taskId = Helper.getLongValue(request,Constants.TASK_INSTANCE_ID);
- if (null!=taskId)
- command.setTaskInstanceId(taskId);
- Map<String, Object> variables = Helper.getVariablesMap(request, Constants.VARIABLE_VALUES);
- if (null!=variables)
- command.setVariables(variables);
-
- String transition = Helper.getStringValue(request, Constants.TRANSITION_NAME);
- if (null!=transition)
- command.setTransitionName(transition);
-
- Message response = CommandInterpreter.doTheJob(command);
- Object obj = Helper.getObjectValue(response, Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof TaskInstance)
- {
- TaskInstance inst = (TaskInstance)obj;
- Helper.setLongValue(response, Constants.PROCESS_INSTANCE_ID ,inst.getProcessInstance().getId());
- Helper.setLongValue(response, Constants.TOKEN_ID ,inst.getToken().getId());
- Helper.setLongValue(response, Constants.TASK_INSTANCE_ID ,inst.getId());
- }
- return response;
- } // _______________________________
- };
-
- protected static final CommandExecutor VARIABLES_EXECUTOR=new CommandExecutor()
- {
- public Message execute(Message request) throws Exception
- {
- VariablesCommand command = new VariablesCommand();
- Long id = Helper.getLongValue(request, Constants.TOKEN_ID);
- if (null!=id)
- command.setTokenId(id);
- else
- {
- id = Helper.getLongValue(request, Constants.TASK_INSTANCE_ID);
- if (null!=id)
- command.setTaskInstanceId(id);
- else
- throw new Exception
- ("Either <"+Constants.TOKEN_ID
- +"> or <"+Constants.TASK_INSTANCE_ID
- +"> object must be specified in Message body to know what to retrieve");
-
- }
-
- Map<String, Object> variables = Helper.getVariablesMap(request, Constants.VARIABLE_VALUES);
- if (null!=variables)
- command.setVariables(variables);
-
- return CommandInterpreter.doTheJob(command);
- } // _______________________________
- };
-
-
- protected static Map<Constants.OpCode,CommandExecutor> _values = new HashMap<Constants.OpCode,CommandExecutor>();
- static
- {
- _values.put(Constants.OpCode.DeployProcessDefinition ,DEPLOY_PROCESS_DEF_EXECUTOR);
- _values.put(Constants.OpCode.CancelProcessInstanceCommand,CANCEL_PROCESS_INSTANCE_EXECUTOR);
- _values.put(Constants.OpCode.CancelTokenCommand ,CANCEL_TOKEN_EXECUTOR);
- _values.put(Constants.OpCode.CancelWorkOnTaskCommand ,CANCEL_WORK_ON_TASK_EXECUTOR);
- _values.put(Constants.OpCode.GetProcessInstanceCommand ,GET_PROCESS_INSTANCE_EXECUTOR);
- _values.put(Constants.OpCode.GetTaskInstanceCommand ,GET_TASK_INSTANCE_EXECUTOR);
-// _values.put(Constants.OpCode.GetTaskListCommand ,???);
- _values.put(Constants.OpCode.NewProcessInstanceCommand
- ,new DefaultCommandExecutorFactoryImpl.NewProcessInstancePerformer(false));
- _values.put(Constants.OpCode.SignalCommand ,SIGNAL_EXECUTOR);
- _values.put(Constants.OpCode.StartProcessInstanceCommand
- ,new DefaultCommandExecutorFactoryImpl.NewProcessInstancePerformer(true));
- _values.put(Constants.OpCode.StartWorkOnTaskCommand ,START_WORK_ON_TASK_EXECUTOR);
- _values.put(Constants.OpCode.TaskInstanceEndCommand ,TASK_INSTANCE_END_EXECUTOR);
- _values.put(Constants.OpCode.VariablesCommand ,VARIABLES_EXECUTOR);
- }
-
- // this class will be used both for NewProcessInstance and for StartProcessInstance
- protected static final class NewProcessInstancePerformer implements CommandInterpreter.CommandExecutor
- {
- private boolean _start;
- public NewProcessInstancePerformer(boolean start) { _start = start; }
- public Message execute(Message request) throws Exception
- {
- return perform(request,_start);
- }
-
- private Message perform(Message request, boolean start) throws Exception
- {
- ObjectMapper objectMapper = new ObjectMapper();
- String processName = Helper.getStringValue(request,Constants.PROCESS_DEFINITION_NAME);
- Long processDefId = Helper.getLongValue (request,Constants.PROCESS_DEFINITION_ID);
- if (null==processName && null==processDefId)
- throw new Exception("At least one of "+Constants.PROCESS_DEFINITION_NAME
- +" or "+Constants.PROCESS_DEFINITION_ID+" must have a valid value");
-
- NewProcessInstanceCommand command = null;
- if (start)
- {
- StartProcessInstanceCommand startCmd = new StartProcessInstanceCommand();
- String transition = Helper.getStringValue(request, Constants.TRANSITION_NAME);
- if (null!=transition)
- startCmd.setStartTransitionName(transition);
- command = startCmd;
- }
- else
- command = new NewProcessInstanceCommand();
-
- if (null!=processDefId)
- command.setProcessId(processDefId);
- if (null!=processName)
- command.setProcessName(processName);
-
- String keyPath = Helper.getStringValue(request, Constants.KEYPATH);
- if (null!=keyPath) {
- String key = String.valueOf(objectMapper.getObjectFromMessage(request, keyPath));
- command.setKey(key);
- }
- String actorId = Helper.getStringValue(request, Constants.ACTOR_ID);
- if (null!=actorId)
- command.setActorId(actorId);
- Boolean createStartTask = Helper.getBooleanValue(request, Constants.CREATE_START_TASK);
- if (null!=createStartTask)
- command.setCreateStartTask(createStartTask);
- Map<String, Object> variables = Helper.getVariablesMap(request, Constants.VARIABLE_VALUES);
- if (null!=variables)
- command.setVariables(variables);
-
- Message response = CommandInterpreter.doTheJob(command);
-
- String retCode = Helper.getStringValue(response, Constants.RETURN_CODE);
- if (Constants.RETCODE_OK.equals(retCode))
- {
- Object obj = Helper.getObjectValue(response, Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof TaskInstance)
- {
- TaskInstance tInst = (TaskInstance)obj;
- Helper.setLongValue(response, Constants.PROCESS_INSTANCE_ID ,tInst.getProcessInstance().getId());
- Helper.setLongValue(response, Constants.TOKEN_ID ,tInst.getToken().getId());
- Helper.setLongValue(response, Constants.TASK_INSTANCE_ID ,tInst.getId());
- }
- else if (obj instanceof ProcessInstance)
- {
- ProcessInstance pInst = (ProcessInstance)obj;
- Helper.setLongValue(response, Constants.PROCESS_INSTANCE_ID, pInst.getId());
- Helper.setLongValue(response, Constants.TOKEN_ID ,pInst.getRootToken().getId());
- }
- }
- return response;
- } // _______________________________
- }
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/DefaultMessageFacadeFactoryImpl.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,104 +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.impl;
-
-import org.jboss.soa.esb.ConfigurationException;
-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.BpmProcessor;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor.MessageFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.DeployProcessDefinitionFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.GetProcessInstanceFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.GetTaskInstanceFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.GetTaskListFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.NewProcessInstanceFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.SignalFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.StartWorkOnTaskFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.TaskInstanceEndFacade;
-import org.jboss.soa.esb.services.jbpm.actions.impl.facades.VariablesFacade;
-
-/**
- * Default implementation of a message preprocessor factory
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public class DefaultMessageFacadeFactoryImpl extends MessageFacadeFactory
-{
- // This is a dummy message preprocessor that does nothing but implement the interface
- static class PassThrough implements MessageFacade
- {
- private OpCode _opCode;
- PassThrough(OpCode opCode) { _opCode = opCode; }
- public OpCode getOpCode() { return _opCode; }
- public void preFormat(Message message) { }
- public Message postFormat(Message response) { return response; }
- };
-
- @Override
- public BpmProcessor.MessageFacade getPreProcessor(ConfigTree config)
- throws ConfigurationException
- {
- Constants.OpCode opCode = null;
- String sAux = config.getRequiredAttribute(BpmProcessor.COMMAND_ATTRIBUTE_TAG);
- try { opCode = Constants.OpCode.valueOf(sAux); }
- catch (IllegalArgumentException e)
- {
- throw new ConfigurationException("Attribute '"+BpmProcessor.COMMAND_ATTRIBUTE_TAG+"' has an invalid value"
- +"- see CommandVehicle.Operation enum for possible values");
- }
-
- if (Constants.OpCode.CancelProcessInstanceCommand .equals(opCode))
- return new PassThrough(opCode);
- if (Constants.OpCode.CancelTokenCommand .equals(opCode))
- return new PassThrough(opCode);
- if (Constants.OpCode.CancelWorkOnTaskCommand .equals(opCode))
- return new PassThrough(opCode);
- if (Constants.OpCode.DeployProcessDefinition .equals(opCode))
- return new DeployProcessDefinitionFacade(config);
- if (Constants.OpCode.GetProcessInstanceCommand .equals(opCode))
- return new GetProcessInstanceFacade (config);
- if (Constants.OpCode.GetTaskInstanceCommand .equals(opCode))
- return new GetTaskInstanceFacade (config);
- if (Constants.OpCode.GetTaskListCommand .equals(opCode))
- return new GetTaskListFacade (config);
- if (Constants.OpCode.NewProcessInstanceCommand .equals(opCode))
- return new NewProcessInstanceFacade (config, false);
- if (Constants.OpCode.SignalCommand .equals(opCode))
- return new SignalFacade (config);
- if (Constants.OpCode.StartProcessInstanceCommand .equals(opCode))
- return new NewProcessInstanceFacade (config, true);
- if (Constants.OpCode.StartWorkOnTaskCommand .equals(opCode))
- return new StartWorkOnTaskFacade (config);
- if (Constants.OpCode.TaskInstanceEndCommand .equals(opCode))
- return new TaskInstanceEndFacade (config);
- if (Constants.OpCode.VariablesCommand .equals(opCode))
- return new VariablesFacade (config);
-
- throw new ConfigurationException(opCode.toString()+" not implemented");
- } // _______________________________
-
-}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/Command.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/Command.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/Command.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package org.jboss.soa.esb.services.jbpm.cmd;
+
+import org.jboss.soa.esb.message.Message;
+import org.jbpm.JbpmException;
+
+/**
+ * @author kstam
+ *
+ */
+public interface Command
+{
+ public void execute (Message message) throws JbpmException;
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/Command.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.services.jbpm.cmd;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.mapping.MessageHelper;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
+import org.jbpm.command.CancelProcessInstanceCommand;
+import org.jbpm.command.CommandService;
+import org.jbpm.command.GetProcessInstanceCommand;
+import org.jbpm.command.NewProcessInstanceCommand;
+import org.jbpm.command.SignalCommand;
+import org.jbpm.command.StartProcessInstanceCommand;
+import org.jbpm.command.impl.CommandServiceImpl;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * Executes jBPM commands.
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @author <a href="mailto:kurt.stam at jboss.com">Kurt Stam</a>
+ *
+ */
+public class CommandExecutor
+{
+ static CommandExecutor commandExecutor;
+
+ private static Logger _logger = Logger.getLogger(CommandExecutor.class);
+ private static JbpmConfiguration s_jbpmConfig;
+ private static CommandService s_jbpmService;
+
+ public static CommandExecutor getInstance()
+ {
+ if (commandExecutor==null) {
+ commandExecutor =new CommandExecutor();
+ }
+ return commandExecutor;
+ }
+
+ public Command getCommand(String commandString) throws Exception
+ {
+ Constants.OpCode opCode = Constants.OpCode.valueOf(commandString);
+ Command command = _values.get(opCode);
+ if (null==command)
+ throw new Exception(opCode.toString()+" not implemented,");
+ return command;
+ }
+
+ protected static final Command DEPLOY_PROCESS_DEF_EXECUTOR = new Command()
+ {
+ public void execute(Message request) throws JbpmException
+ {
+ Object obj = MessageHelper.getObjectValue(request, Constants.PROCESS_DEFINITION);
+ if (null==obj)
+ {
+ obj = ProcessDefinition.parseXmlString
+ ((String)MessageHelper.getObjectValue(request,Constants.PROCESS_DEFINITION_XML));
+ }
+ final ProcessDefinition def = (ProcessDefinition)obj;
+ _logger.debug("Deploying new process definition " + def.getName());
+ executeJbpmCommand(new org.jbpm.command.Command()
+ {
+ private static final long serialVersionUID = 1L;
+ ProcessDefinition _def = def;
+
+ public Object execute(JbpmContext jbpmCtx) throws Exception
+ {
+ jbpmCtx.deployProcessDefinition(_def);
+ _logger.info("Process Definition '" + def.getName() + "' is deployed.");
+ return null;
+ }
+ });
+ }
+ };
+
+
+ protected static final Command CANCEL_PROCESS_INSTANCE_EXECUTOR = new Command()
+ {
+ public void execute(Message request) throws JbpmException
+ {
+ long processId = MessageHelper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
+ _logger.debug("Cancel Process Instance Command for ProcessId=" + processId);
+ executeJbpmCommand(new CancelProcessInstanceCommand(processId));
+ }
+ };
+
+ protected static final Command SIGNAL_EXECUTOR=new Command()
+ {
+ public void execute(Message request) throws JbpmException
+ {
+ SignalCommand command = new SignalCommand();
+ Long tokenId = MessageHelper.getLongValue(request,Constants.TOKEN_ID);
+ if (null== tokenId)
+ {
+ Long processId = MessageHelper.getLongValue(request,Constants.PROCESS_INSTANCE_ID);
+ _logger.debug("TokenId was not found, so try to obtain the root token from this process definition, " +
+ " with ProcessId=" + processId);
+ // now try with the process id (use root token)
+ if (processId==null) {
+ throw new JbpmException("Either <"+Constants.TOKEN_ID+"> or <"+Constants.PROCESS_INSTANCE_ID
+ +"> object must be specified in Message body to know who to signal");
+ }
+ ProcessInstance inst = (ProcessInstance)getJbpmCommandService()
+ .execute(new GetProcessInstanceCommand(processId));
+ tokenId = inst.getRootToken().getId();
+ }
+ command.setTokenId(tokenId);
+
+ String transition = MessageHelper.getStringValue(request, Constants.TRANSITION_NAME);
+ if (null!=transition)
+ command.setTransitionName(transition);
+
+ Map map = (Map)MessageHelper.getObjectValue(request, Constants.VARIABLE_VALUES);
+ if (null!=map) command.setVariables(map);
+
+ _logger.debug("Signaling Process with TokenId=" + tokenId + ", Transition=" + transition + ", VariableMap=" + map);
+ executeJbpmCommand(command);
+ }
+ };
+
+
+ protected static Map<Constants.OpCode,Command> _values = new HashMap<Constants.OpCode,Command>();
+ static
+ {
+ _values.put(Constants.OpCode.CancelProcessInstanceCommand,CANCEL_PROCESS_INSTANCE_EXECUTOR);
+ _values.put(Constants.OpCode.SignalCommand ,SIGNAL_EXECUTOR);
+ _values.put(Constants.OpCode.DeployProcessDefinition ,DEPLOY_PROCESS_DEF_EXECUTOR);
+ _values.put(Constants.OpCode.NewProcessInstanceCommand
+ ,new CommandExecutor.NewProcessInstancePerformer(false));
+ _values.put(Constants.OpCode.StartProcessInstanceCommand
+ ,new CommandExecutor.NewProcessInstancePerformer(true));
+ }
+
+ // this class is used both for NewProcessInstance and for StartProcessInstance
+ protected static final class NewProcessInstancePerformer implements Command
+ {
+ private boolean _start;
+ public NewProcessInstancePerformer(boolean start) { _start = start; }
+
+ public void execute(Message request) throws JbpmException
+ {
+ perform(request,_start);
+ }
+
+ private void perform(Message request, boolean start) throws JbpmException
+ {
+ ObjectMapper objectMapper = new ObjectMapper();
+ NewProcessInstanceCommand command = null;
+ if (start) {
+ StartProcessInstanceCommand startCmd = new StartProcessInstanceCommand();
+ String transition = MessageHelper.getStringValue(request, Constants.TRANSITION_NAME);
+ if (null!=transition)
+ startCmd.setStartTransitionName(transition);
+ command = startCmd;
+ } else {
+ command = new NewProcessInstanceCommand();
+ }
+ Long processDefId = MessageHelper.getLongValue(request,Constants.PROCESS_DEFINITION_ID);
+ if (null!=processDefId) {
+ command.setProcessId(processDefId);
+ } else {
+ String processName = MessageHelper.getStringValue(request,Constants.PROCESS_DEFINITION_NAME);
+ if (null!=processName) {
+ command.setProcessName(processName);
+ } else {
+ throw new JbpmException("At least one of "+Constants.PROCESS_DEFINITION_NAME
+ +" or "+Constants.PROCESS_DEFINITION_ID+" must have a valid value");
+ }
+ }
+ String keyPath = MessageHelper.getStringValue(request, Constants.KEYPATH);
+ if (keyPath!=null) {
+ try {
+ String key = String.valueOf(objectMapper.getObjectFromMessage(request, keyPath));
+ command.setKey(key);
+ } catch (ObjectMappingException e) {
+ _logger.error("Could not locate key " + e.getMessage(), e);
+ }
+ }
+ String actorId=MessageHelper.getStringValue(request, Constants.ACTOR_ID);
+ 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);
+ if (null!=variables) command.setVariables(variables);
+
+ _logger.debug("New process instance with command=" + command);
+ executeJbpmCommand(command);
+ }
+ }
+
+ private static void executeJbpmCommand(org.jbpm.command.Command command) throws JbpmException
+ {
+ if (_logger.isDebugEnabled()) {
+ _logger.debug(command);
+ }
+ getJbpmCommandService().execute(command);
+ }
+
+ /**
+ * Encapsulate obtention of jBPM CommandService here
+ * <br/>If it can't be cached, we only need to change this method.
+ * @return CommandService
+ */
+ public static CommandService getJbpmCommandService()
+ {
+ if (null== s_jbpmService) {
+ s_jbpmConfig = JbpmConfiguration.getInstance();
+ s_jbpmService = new CommandServiceImpl(s_jbpmConfig);
+ }
+ return s_jbpmService;
+ }
+
+
+
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/CommandExecutor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping (from rev 16630, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades)
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/CancelProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/CancelProcessInstanceFacade.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/CancelProcessInstanceFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,49 @@
+/*
+ * 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.mapping;
+
+import org.jboss.soa.esb.ConfigurationException;
+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.Constants.OpCode;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a process instance
+ * from the action configuration XML
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class CancelProcessInstanceFacade extends MessageFacade
+{
+ public OpCode getOpCode() { return Constants.OpCode.CancelProcessInstanceCommand; }
+
+ public CancelProcessInstanceFacade(ConfigTree config) throws ConfigurationException
+ {
+ }
+
+ public void setJBPMContextParameters(Message message)
+ {
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/CancelProcessInstanceFacade.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/DeployProcessDefinitionFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,121 +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.impl.facades;
-
-import java.io.InputStream;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-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.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-import org.jboss.soa.esb.util.ClassUtil;
-import org.jboss.soa.esb.util.Util;
-import org.jbpm.graph.def.ProcessDefinition;
-
-/**
- *
- * Implementation of a message preprocessor that obtains the process definition
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class DeployProcessDefinitionFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.DeployProcessDefinition; }
-
- public DeployProcessDefinitionFacade(ConfigTree config) throws ConfigurationException
- {
- _fileName=config.getAttribute(Constants.PROCESS_DEFINITION_FILE_TAG);
- ConfigTree[] childs = config.getChildren(Constants.PROCESS_DEFINITION_XML_TAG);
-
- if (null!=_fileName)
- {
- if (childs.length>0)
- throw new ConfigurationException
- ("You can specify ither '"+Constants.PROCESS_DEFINITION_FILE_TAG+"' attribute OR "
- +Constants.PROCESS_DEFINITION_XML_TAG+"> element, but not both");
-
- InputStream stream = ClassUtil.getResourceAsStream(_fileName, BpmProcessor.class);
- _validProcessDef = ProcessDefinition.parseXmlInputStream(stream);
- return;
- }
-
- if (childs.length<1)
- throw new ConfigurationException("Missing or invalid <"+Constants.PROCESS_DEFINITION_XML_TAG+"> element");
- if (childs.length>1)
- throw new ConfigurationException("Only one <"+Constants.PROCESS_DEFINITION_XML_TAG+"> element can be specified");
-
- String version = childs[0].getAttribute("version");
- String encoding = childs[0].getAttribute("encoding");
- if (Util.isNullString(version) || Util.isNullString(encoding))
- throw new ConfigurationException("Wrong 'version' or 'encoding' attribute in <"+Constants.PROCESS_DEFINITION_XML_TAG+">");
- StringBuilder sb = new StringBuilder("<?xml version='").append(version)
- .append("' encoding='").append(encoding).append("' ?>\n")
- ;
-
- ConfigTree[] def = childs[0].getChildren("process-definition");
- if (null==def || def.length<1)
- throw new ConfigurationException("Missing or invalid <process-definition> element");
- if (def.length>1)
- throw new ConfigurationException("Only one <process-definition> element can be specified");
-
- final String xmlString = sb.append(def[0].toString()).toString();
- try
- {
- _validProcessDef = ProcessDefinition.parseXmlString(xmlString);
- }
- catch (Exception e)
- {
- throw new ConfigurationException(e);
- }
- } // ________________________________
-
- public void preFormat(Message message)
- {
- if (null!= _fileName)
- try
- {
- InputStream stream = ClassUtil.getResourceAsStream(_fileName, BpmProcessor.class);
- _validProcessDef = ProcessDefinition.parseXmlInputStream(stream);
- }
- catch (Exception e)
- {
- _logger.info("Keeping previous process definition");
- _logger.error("Invalid process definition file <"+_fileName+">",e);
- }
- message.getBody().add(Constants.PROCESS_DEFINITION, _validProcessDef);
- } // ________________________________
-
- public Message postFormat(Message message)
- {
-
- return message;
- } // ________________________________
-
- protected String _fileName;
- protected ProcessDefinition _validProcessDef;
- private static final Logger _logger = Logger.getLogger(DeployProcessDefinitionFacade.class);
-}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java (from rev 16701, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/DeployProcessDefinitionFacade.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/DeployProcessDefinitionFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,115 @@
+/*
+ * 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.mapping;
+
+import java.io.InputStream;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+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.Constants.OpCode;
+import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.util.Util;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ *
+ * Implementation of a message preprocessor that obtains the process definition
+ * from the action configuration XML
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class DeployProcessDefinitionFacade extends MessageFacade
+{
+ public OpCode getOpCode() { return Constants.OpCode.DeployProcessDefinition; }
+
+ public DeployProcessDefinitionFacade(ConfigTree config) throws ConfigurationException
+ {
+ _fileName=config.getAttribute(Constants.PROCESS_DEFINITION_FILE_TAG);
+ ConfigTree[] childs = config.getChildren(Constants.PROCESS_DEFINITION_XML_TAG);
+
+ if (null!=_fileName)
+ {
+ if (childs.length>0)
+ throw new ConfigurationException
+ ("You can specify either '"+Constants.PROCESS_DEFINITION_FILE_TAG+"' attribute OR "
+ +Constants.PROCESS_DEFINITION_XML_TAG+"> element, but not both");
+
+ InputStream stream = ClassUtil.getResourceAsStream(_fileName, BpmProcessor.class);
+ _validProcessDef = ProcessDefinition.parseXmlInputStream(stream);
+ return;
+ }
+
+ if (childs.length<1)
+ throw new ConfigurationException("Missing or invalid <"+Constants.PROCESS_DEFINITION_XML_TAG+"> element");
+ if (childs.length>1)
+ throw new ConfigurationException("Only one <"+Constants.PROCESS_DEFINITION_XML_TAG+"> element can be specified");
+
+ String version = childs[0].getAttribute("version");
+ String encoding = childs[0].getAttribute("encoding");
+ if (Util.isNullString(version) || Util.isNullString(encoding))
+ throw new ConfigurationException("Wrong 'version' or 'encoding' attribute in <"+Constants.PROCESS_DEFINITION_XML_TAG+">");
+ StringBuilder sb = new StringBuilder("<?xml version='").append(version)
+ .append("' encoding='").append(encoding).append("' ?>\n")
+ ;
+
+ ConfigTree[] def = childs[0].getChildren("process-definition");
+ if (null==def || def.length<1)
+ throw new ConfigurationException("Missing or invalid <process-definition> element");
+ if (def.length>1)
+ throw new ConfigurationException("Only one <process-definition> element can be specified");
+
+ final String xmlString = sb.append(def[0].toString()).toString();
+ try
+ {
+ _validProcessDef = ProcessDefinition.parseXmlString(xmlString);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException(e);
+ }
+ }
+
+ public void setJBPMContextParameters(Message message)
+ {
+ if (null!= _fileName)
+ try
+ {
+ InputStream stream = ClassUtil.getResourceAsStream(_fileName, BpmProcessor.class);
+ _validProcessDef = ProcessDefinition.parseXmlInputStream(stream);
+ }
+ catch (Exception e)
+ {
+ _logger.info("Keeping previous process definition");
+ _logger.error("Invalid process definition file <"+_fileName+">",e);
+ }
+ message.getBody().add(Constants.PROCESS_DEFINITION, _validProcessDef);
+ }
+
+ protected String _fileName;
+ protected ProcessDefinition _validProcessDef;
+ private static final Logger _logger = Logger.getLogger(DeployProcessDefinitionFacade.class);
+}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/FacadeUtil.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,197 +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.impl.facades;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.mapping.ObjectMapper;
-import org.jboss.soa.esb.message.mapping.ObjectMappingException;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jbpm.context.exe.VariableContainer;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.jbpm.taskmgmt.exe.TaskInstance;
-
-public class FacadeUtil
-{
- static Boolean booleanFromConfig(ConfigTree tree, String tag)
- throws ConfigurationException
- {
- ConfigTree[] childs = tree.getChildren(tag);
- if (null==childs || childs.length<1)
- return null;
- if (childs.length>1)
- throw new ConfigurationException("Only one <"+tag
- +"> element allowed in configuration");
- try
- {
- return Boolean.parseBoolean(childs[0].getAttribute("value"));
- }
- catch (Exception e)
- {
- throw new ConfigurationException("<"+tag
- +"> must have a 'value' attribute containing 'true' or 'false'");
- }
- } //________________________________
-
- static VariableMapping variablesFromConfig(ConfigTree tree, boolean acceptValue)
- throws ConfigurationException
- {
- VariableMapping ret = new VariableMapping();
- ConfigTree[] objectList = tree.getChildren(Constants.OBJECT_PATH_TAG);
- if (objectList != null) {
- for (ConfigTree curr : objectList) {
- String esbName = curr.getAttribute(Constants.ESB_VARNAME_TAG);
- String jbpmName = curr.getAttribute(Constants.JBPM_VARNAME_TAG);
- String value = curr.getAttribute("value");
- ret.setVariable(esbName, jbpmName, value);
- }
- }
- return ret;
- }
-
- static String[] actorsFromConfig(ConfigTree tree, boolean acceptValue)
- throws ConfigurationException
- {
- String tag = Constants.ACTORS_TAG;
- ConfigTree[] childs = tree.getChildren(tag);
- if (null==childs || childs.length<1)
- return null;
- if (childs.length>1)
- throw new ConfigurationException("Only one <"+tag
- +"> element allowed in configuration");
-
- tag = Constants.ONE_ACTOR_TAG;
- childs = childs[0].getChildren(tag);
- if (null==childs || childs.length<1)
- throw new ConfigurationException("At least one <"+tag
- +"> child element required for <"+Constants.VARIABLES_TAG+">");
- String[] ret = new String[childs.length];
- int i1=0;
- for (ConfigTree curr: childs)
- {
- String name = curr.getAttribute("name");
- if (null==name)
- {
- throw new ConfigurationException
- ("You must specifi the 'name' attribute for all <"
- +tag+"> element");
- }
- ret[i1++] = name;
- }
- return ret;
- }
-
- /**
- * Maps variables in the jBPM variable map to an ESB message using a
- * mapping which may contain MVEL expressions
- *
- * @param message
- * @param mapping
- */
- static void jbpmVarsToMessage(Message message, VariableMapping mapping)
- {
- Body body = message.getBody();
- Object obj = body.get(Constants.JBPM_RETURN_OBJECT);
- if (null==obj)
- return;
-
- //First lets get the variable map
- Map map = null;
- if (obj instanceof ProcessInstance)
- map= ((ProcessInstance)obj).getContextInstance().getVariables();
- else if (obj instanceof Token)
- map = ((Token)obj).getProcessInstance().getContextInstance().getVariables();
- else if (obj instanceof TaskInstance)
- map = ((TaskInstance)obj).getContextInstance().getVariables();
- else if (obj instanceof VariableContainer)
- map = ((VariableContainer)obj).getContextInstance().getVariables();
- else
- throw new IllegalArgumentException("Unknown return jbpmObject in message");
-
- if (map != null) // legal in jBPM see JBESB-1060
- {
- //now for all entries in the map, lets see if we have the jbpm key name in the mapping
- for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();)
- {
- Map.Entry variable = (Map.Entry)iterator.next();
- String keyInMsg = null;
- if (mapping == null) {
- keyInMsg = (String)variable.getKey();
- } else {
- keyInMsg = mapping.getEsbName((String)variable.getKey());
- }
- Object value = variable.getValue();
- if (null!=keyInMsg && null!=value)
- {
- //set the object on the message
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- objectMapper.setObjectOnMessage(message, keyInMsg, value);
- } catch (ObjectMappingException ome) {
- throw new IllegalArgumentException(ome.getMessage(), ome);
- }
- }
- }
- }
-
- //now remove the jBPM object from the message
- body.remove(Constants.JBPM_RETURN_OBJECT);
- } // _______________________________
-
- static void populateVariableValues (Message message, VariableMapping mapping)
- {
- if (null==mapping || mapping.size()<1)
- return;
-
- Body body = message.getBody();
- HashMap<String,Object> map = new HashMap<String, Object>();
- for (Map.Entry<String, Object> curr: mapping.esbVariables().entrySet())
- {
- String esbName = curr.getKey();
- String jbpmName = mapping.getJbpmName(esbName);
-
- ObjectMapper objectMapper = new ObjectMapper();
- Object value = null;
- try {
- value = objectMapper.getObjectFromMessage(message, esbName);
- } catch (ObjectMappingException ome) {
- throw new IllegalArgumentException(ome.getMessage(), ome);
- }
- // if object not found in body, use default value (from config)
- if (null==value)
- value = curr.getValue();
- // only put it in the map if it's not null
- if (null!=value)
- map.put(jbpmName, value);
- }
- body.add(Constants.VARIABLE_VALUES, map);
- }
-
-}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java (from rev 16701, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/FacadeUtil.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/FacadeUtil.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,136 @@
+/*
+ * 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.mapping;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.services.jbpm.Constants;
+
+public class FacadeUtil
+{
+ static Boolean booleanFromConfig(ConfigTree tree, String tag)
+ throws ConfigurationException
+ {
+ ConfigTree[] childs = tree.getChildren(tag);
+ if (null==childs || childs.length<1)
+ return null;
+ if (childs.length>1)
+ throw new ConfigurationException("Only one <"+tag
+ +"> element allowed in configuration");
+ try
+ {
+ return Boolean.parseBoolean(childs[0].getAttribute("value"));
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("<"+tag
+ +"> must have a 'value' attribute containing 'true' or 'false'");
+ }
+ } //________________________________
+
+ static VariableMapping variablesFromConfig(ConfigTree tree, boolean acceptValue)
+ throws ConfigurationException
+ {
+ VariableMapping ret = new VariableMapping();
+ ConfigTree[] objectList = tree.getChildren(Constants.OBJECT_PATH_TAG);
+ if (objectList != null) {
+ for (ConfigTree curr : objectList) {
+ String esbName = curr.getAttribute(Constants.ESB_VARNAME_TAG);
+ String jbpmName = curr.getAttribute(Constants.JBPM_VARNAME_TAG);
+ String value = curr.getAttribute("value");
+ ret.setVariable(esbName, jbpmName, value);
+ }
+ }
+ return ret;
+ }
+
+ static String[] actorsFromConfig(ConfigTree tree, boolean acceptValue)
+ throws ConfigurationException
+ {
+ String tag = Constants.ACTORS_TAG;
+ ConfigTree[] childs = tree.getChildren(tag);
+ if (null==childs || childs.length<1)
+ return null;
+ if (childs.length>1)
+ throw new ConfigurationException("Only one <"+tag
+ +"> element allowed in configuration");
+
+ tag = Constants.ONE_ACTOR_TAG;
+ childs = childs[0].getChildren(tag);
+ if (null==childs || childs.length<1)
+ throw new ConfigurationException("At least one <"+tag
+ +"> child element required for <"+Constants.VARIABLES_TAG+">");
+ String[] ret = new String[childs.length];
+ int i1=0;
+ for (ConfigTree curr: childs)
+ {
+ String name = curr.getAttribute("name");
+ if (null==name)
+ {
+ throw new ConfigurationException
+ ("You must specify the 'name' attribute for all <"
+ +tag+"> element");
+ }
+ ret[i1++] = name;
+ }
+ return ret;
+ }
+
+
+ static void populateVariableValues (Message message, VariableMapping mapping)
+ {
+ if (null==mapping || mapping.size()<1)
+ return;
+
+ Body body = message.getBody();
+ HashMap<String,Object> map = new HashMap<String, Object>();
+ for (Map.Entry<String, Object> curr: mapping.esbVariables().entrySet())
+ {
+ String esbName = curr.getKey();
+ String jbpmName = mapping.getJbpmName(esbName);
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ Object value = null;
+ try {
+ value = objectMapper.getObjectFromMessage(message, esbName);
+ } catch (ObjectMappingException ome) {
+ throw new IllegalArgumentException(ome.getMessage(), ome);
+ }
+ // if object not found in body, use default value (from config)
+ if (null==value)
+ value = curr.getValue();
+ // only put it in the map if it's not null
+ if (null!=value)
+ map.put(jbpmName, value);
+ }
+ body.add(Constants.VARIABLE_VALUES, map);
+ }
+
+}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/GetProcessInstanceFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetProcessInstanceFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,78 +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.impl.facades;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-
-/**
- *
- * Implementation of a message preprocessor to obtain data from a process instance
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class GetProcessInstanceFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.GetProcessInstanceCommand; }
-
- public GetProcessInstanceFacade(ConfigTree config) throws ConfigurationException
- {
- _includeAllVars = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_ALL_VARS_TAG);
- _includeLogs = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_LOGS_TAG);
- _variables = FacadeUtil.variablesFromConfig(config, false);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_includeLogs)
- body.add(Constants.INCLUDE_LOGS ,_includeLogs);
-
- String key = Constants.INCLUDE_ALL_VARS_TAG;
- // Currently, the jbpm GetProcessInstanceCommand does not accept a list of variables
- // so, if configuration has a list of variables, we must bring'em all
- if (null!=_variables)
- body.add(key, true);
- else if (null!=_includeAllVars)
- body.add(key,_includeAllVars);
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- if (null!=_variables)
- FacadeUtil.jbpmVarsToMessage(response,_variables);
- else if (null!=_includeAllVars && _includeAllVars)
- FacadeUtil.jbpmVarsToMessage(response,null);
- return response;
- } // ________________________________
-
- Boolean _includeLogs;
- Boolean _includeAllVars;
- VariableMapping _variables;
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetTaskInstanceFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/GetTaskInstanceFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetTaskInstanceFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,84 +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.impl.facades;
-
-import java.util.Map;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-
-/**
- *
- * Implementation of a message preprocessor to obtain data from a token instance
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class GetTaskInstanceFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.GetTaskInstanceCommand; }
-
- public GetTaskInstanceFacade(ConfigTree config) throws ConfigurationException
- {
- _includeAllVars = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_ALL_VARS_TAG);
- _includeLogs = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_LOGS_TAG);
- _variables = FacadeUtil.variablesFromConfig(config, false);
- _actors = FacadeUtil.actorsFromConfig(config, false);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_includeLogs)
- body.add(Constants.INCLUDE_LOGS ,_includeLogs);
- if (null!=_includeAllVars)
- body.add(Constants.INCLUDE_ALL_VARS_TAG ,_includeAllVars);
- if (null!=_variables)
- {
- String[] sa = new String[_variables.size()];
- int i1=0;
- for(Map.Entry<String,Object> curr:_variables.esbVariables().entrySet())
- sa[i1++] = _variables.getJbpmName(curr.getKey());
- body.add(Constants.VARIABLE_NAMES_ARRAY, sa);
- }
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- if (null!=_variables)
- FacadeUtil.jbpmVarsToMessage(response,_variables);
- else if (null!=_includeAllVars && _includeAllVars)
- FacadeUtil.jbpmVarsToMessage(response,null);
- return response;
- } // ________________________________
-
- Boolean _includeLogs;
- Boolean _includeAllVars;
- VariableMapping _variables;
- String[] _actors;
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetTaskListFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/GetTaskListFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/GetTaskListFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,94 +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.impl.facades;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-import org.jbpm.taskmgmt.exe.TaskInstance;
-
-/**
- *
- * Implementation of a message preprocessor to obtain data from a token instance
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class GetTaskListFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.GetTaskListCommand; }
-
- public GetTaskListFacade(ConfigTree config) throws ConfigurationException
- {
- _includeAllVars = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_ALL_VARS_TAG);
- _includeLogs = FacadeUtil.booleanFromConfig(config,Constants.INCLUDE_LOGS_TAG);
- _variables = FacadeUtil.variablesFromConfig(config, false);
- _actors = FacadeUtil.actorsFromConfig(config, false);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_includeLogs)
- body.add(Constants.INCLUDE_LOGS ,_includeLogs);
- if (null!=_includeAllVars)
- body.add(Constants.INCLUDE_ALL_VARS_TAG ,_includeAllVars);
- if (null!=_variables)
- {
- String[] sa = new String[_variables.size()];
- int i1=0;
- for(Map.Entry<String,Object> curr:_variables.esbVariables().entrySet())
- sa[i1++] = _variables.getJbpmName(curr.getKey());
- body.add(Constants.VARIABLE_NAMES_ARRAY, sa);
- }
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- Body body = response.getBody();
- Object obj = body.get(Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof List)
- {
- List<Long>taskIdList = new ArrayList<Long>();
- for (Object curr: (List)obj)
- if (curr instanceof TaskInstance)
- taskIdList.add(((TaskInstance)curr).getId());
- if (taskIdList.size() > 0)
- body.add(Constants.TASK_ID_LIST, taskIdList);
- }
- return response;
- } // ________________________________
-
- Boolean _includeLogs;
- Boolean _includeAllVars;
- VariableMapping _variables;
- String[] _actors;
-}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageFacade.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,60 @@
+/**
+ *
+ */
+package org.jboss.soa.esb.services.jbpm.mapping;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
+
+/**
+ * @author kstam
+ *
+ */
+public abstract class MessageFacade
+{
+ /**
+ * Obtain the operation code that this preprocessor will force into the command message
+ * @return Constants.OpCode
+ */
+ public abstract Constants.OpCode getOpCode();
+ /**
+ * Some message values are fixed at action configuration time (from the jboss-esb.xml).
+ * <br/>This method is responsible of stuffing these static values into every Message
+ * before passing it to the generic CommandInterpreter process(Message) method
+ * <br/>Some of the Message content will thus come from configuration XML, and some will
+ * be the users' responsibility (e.g. processId, tokenId, etc)
+ * <br/>Variable name mapping between esb and jBPM is also handled by this interface
+ * @param message Message - Into which the static values will be added
+ */
+ public abstract void setJBPMContextParameters(Message request);
+
+
+ public static MessageFacade getFacade(ConfigTree config)
+ throws ConfigurationException, UnsupportedOperationException
+ {
+ Constants.OpCode opCode = null;
+ String sAux = config.getRequiredAttribute(BpmProcessor.COMMAND_ATTRIBUTE_TAG);
+ try { opCode = Constants.OpCode.valueOf(sAux); }
+ catch (IllegalArgumentException e)
+ {
+ throw new ConfigurationException("Attribute '"+BpmProcessor.COMMAND_ATTRIBUTE_TAG+"' has an invalid value"
+ +"- see CommandVehicle.Operation enum for possible values");
+ }
+
+ if (Constants.OpCode.CancelProcessInstanceCommand.equals(opCode))
+ return new CancelProcessInstanceFacade(config);
+ if (Constants.OpCode.NewProcessInstanceCommand.equals(opCode))
+ return new NewProcessInstanceFacade(config, false);
+ if (Constants.OpCode.SignalCommand.equals(opCode))
+ return new SignalFacade(config);
+ if (Constants.OpCode.StartProcessInstanceCommand.equals(opCode))
+ return new NewProcessInstanceFacade(config, true);
+ if (Constants.OpCode.DeployProcessDefinition.equals(opCode))
+ return new DeployProcessDefinitionFacade(config);
+
+ throw new UnsupportedOperationException(opCode.toString()+" not implemented");
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageFacade.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageHelper.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageHelper.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,148 @@
+package org.jboss.soa.esb.services.jbpm.mapping;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+/**
+ * Convient Helper to set or set parameters on an EsbMessage.
+ * @author kstam
+ *
+ */
+public class MessageHelper
+{
+ private static Logger _logger = Logger.getLogger(MessageHelper.class);
+
+ public static String argumentException(String str)
+ {
+ return new String("Missing or invalid <"+str+"> object in Message body");
+ }
+
+ public static Message commandMessageTemplate()
+ {
+ Message template = MessageFactory.getInstance().getMessage();
+ URI uri = null;
+ try { uri = new URI(UUID.randomUUID().toString()); }
+ catch (URISyntaxException e)
+ {
+ _logger.fatal("Problem with UUID.randomUUID() - This should not happen");
+ return null;
+ }
+ template.getHeader().getCall().setMessageID(uri);
+
+ return template;
+ }
+
+ public static void setLongValue(Message message, String key, Long value)
+ {
+ setObjectValue(message, key, value);
+ }
+ public static void setIntValue(Message message, String key, Integer value)
+ {
+ setObjectValue(message, key, value);
+ }
+ public static void setBooleanValue(Message message, String key, Boolean value)
+ {
+ setObjectValue(message, key, value);
+ }
+ public static void setObjectValue(Message message, String key, Object value)
+ {
+ message.getBody().add(key, value);
+ }
+
+ public static void setStringValue(Message msg,String key,Object obj)
+ {
+ setStringValue(msg, key, obj.toString());
+ }
+
+ public static void setStringValue(Message msg,String key,String str)
+ {
+ setObjectValue(msg, key, str);
+ }
+
+ public static void setStringListValue(Message msg,String key,String[] list)
+ {
+ boolean addComma = false;
+ StringBuilder sb = new StringBuilder();
+ for (String curr : list)
+ {
+ sb.append((addComma)?",":"").append(curr);
+ addComma = true;
+ }
+ setObjectValue(msg,key, sb.toString());
+ }
+
+ public static void setVariablesMap(Message msg,String key,Map<String,Object> value)
+ {
+ msg.getBody().add(key, value);
+ }
+
+ public static Integer getIntValue(Message msg,String key)
+ {
+ Object obj = msg.getBody().get(key);
+ if (obj instanceof Integer) return (Integer)obj;
+ if (obj instanceof String) return Integer.parseInt((String)obj);
+ _logger.error(argumentException(key));
+ return null;
+ }
+
+ public static Long getLongValue(Message msg,String key)
+ {
+ Object obj = msg.getBody().get(key);
+ if (null==obj) return null;
+ if (obj instanceof Long) return (Long)obj;
+ if (obj instanceof String) return Long.parseLong((String)obj);
+ if (obj instanceof Integer) return new Long(obj.toString());
+ _logger.error(argumentException(key));
+ return null;
+ }
+
+ public static Boolean getBooleanValue(Message msg,String key)
+ {
+ return getBooleanValue(msg, key, null);
+ }
+
+ public static Boolean getBooleanValue(Message msg,String key, Boolean dflt)
+ {
+ Object obj = msg.getBody().get(key);
+ if (null==obj) return dflt;
+ if (obj instanceof Boolean) return (Boolean)obj;
+ if (obj instanceof String) return Boolean.parseBoolean((String)obj);
+ _logger.error(argumentException(key));
+ return null;
+ }
+
+ public static String getStringValue(Message msg,String key)
+ {
+ return getStringValue(msg, key, null);
+ }
+
+ public static String getStringValue(Message msg,String key, String dflt)
+ {
+ Object obj = msg.getBody().get(key);
+ if (null==obj) return dflt;
+ if (obj instanceof String) return (String)obj;
+ _logger.error(argumentException(key));
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String,Object>getVariablesMap(Message msg,String key)
+ {
+ Object obj = msg.getBody().get(key);
+ if (null==obj) return null;
+ if (obj instanceof Map) return (Map<String,Object>)obj;
+ _logger.error(argumentException(key));
+ return null;
+ }
+
+ public static Object getObjectValue(Message msg,String key)
+ {
+ return msg.getBody().get(key);
+ }
+
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/MessageHelper.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/NewProcessInstanceFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,98 +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.impl.facades;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-
-/**
- *
- * Implementation of a message preprocessor to obtain data from a process instance
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class NewProcessInstanceFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode()
- {
- return (_start)
- ?Constants.OpCode.StartProcessInstanceCommand
- :Constants.OpCode.NewProcessInstanceCommand;
- }
-
- public NewProcessInstanceFacade(ConfigTree config, boolean start) throws ConfigurationException
- {
- _start = start;
- _actor = config.getAttribute(Constants.ONE_ACTOR_TAG);
- _processName= config.getAttribute(Constants.PROCESS_DEFINITION_NAME_TAG);
- _keyPath = config.getAttribute(Constants.KEY_TAG);
- String aux = config.getAttribute(Constants.PROCESS_DEFINITION_ID_TAG);
- if (null!=aux)
- try {_processId = Long.parseLong(aux); }
- catch(NumberFormatException e)
- {
- throw new ConfigurationException("Invalid value for '"+Constants.PROCESS_DEFINITION_ID_TAG+"'");
- }
- _variables = FacadeUtil.variablesFromConfig(config, true);
-
- if (_start)
- _transitionName = config.getAttribute(Constants.TRANSITION_NAME_TAG);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_keyPath)
- body.add(Constants.KEYPATH, _keyPath);
- if (null!=_actor)
- body.add(Constants.ACTOR_ID ,_actor);
- if (null!=_processName)
- body.add(Constants.PROCESS_DEFINITION_NAME ,_processName);
- if (null!=_processId)
- body.add(Constants.PROCESS_DEFINITION_ID ,_processId);
- if (null!=_transitionName)
- body.add(Constants.TRANSITION_NAME, _transitionName);
-
- FacadeUtil.populateVariableValues(message,_variables);
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- FacadeUtil.jbpmVarsToMessage(response, _variables);
- return response;
- } // ________________________________
-
- boolean _start;
- String _keyPath;
- String _actor;
- String _processName;
- String _transitionName;
- Long _processId;
- VariableMapping _variables;
-}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java (from rev 16701, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/NewProcessInstanceFacade.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/NewProcessInstanceFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,91 @@
+/*
+ * 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.mapping;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a process instance
+ * from the action configuration XML
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class NewProcessInstanceFacade extends MessageFacade
+{
+ public OpCode getOpCode()
+ {
+ return (_start)
+ ?Constants.OpCode.StartProcessInstanceCommand
+ :Constants.OpCode.NewProcessInstanceCommand;
+ }
+
+ public NewProcessInstanceFacade(ConfigTree config, boolean start) throws ConfigurationException
+ {
+ _start = start;
+ _actor = config.getAttribute(Constants.ONE_ACTOR_TAG);
+ _processName= config.getAttribute(Constants.PROCESS_DEFINITION_NAME_TAG);
+ _keyPath = config.getAttribute(Constants.KEY_TAG);
+ String aux = config.getAttribute(Constants.PROCESS_DEFINITION_ID_TAG);
+ if (null!=aux)
+ try {_processId = Long.parseLong(aux); }
+ catch(NumberFormatException e)
+ {
+ throw new ConfigurationException("Invalid value for '"+Constants.PROCESS_DEFINITION_ID_TAG+"'");
+ }
+ _variables = FacadeUtil.variablesFromConfig(config, true);
+
+ if (_start)
+ _transitionName = config.getAttribute(Constants.TRANSITION_NAME_TAG);
+ }
+
+ public void setJBPMContextParameters(Message message)
+ {
+ Body body = message.getBody();
+ if (null!=_keyPath)
+ body.add(Constants.KEYPATH, _keyPath);
+ if (null!=_actor)
+ body.add(Constants.ACTOR_ID ,_actor);
+ if (null!=_processName)
+ body.add(Constants.PROCESS_DEFINITION_NAME ,_processName);
+ if (null!=_processId)
+ body.add(Constants.PROCESS_DEFINITION_ID ,_processId);
+ if (null!=_transitionName)
+ body.add(Constants.TRANSITION_NAME, _transitionName);
+
+ FacadeUtil.populateVariableValues(message,_variables);
+ }
+
+ boolean _start;
+ String _keyPath;
+ String _actor;
+ String _processName;
+ String _transitionName;
+ Long _processId;
+ VariableMapping _variables;
+}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/SignalFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,71 +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.impl.facades;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-import org.jbpm.graph.exe.Token;
-
-/**
- *
- * Implementation of a message preprocessor to obtain data from a process instance
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class SignalFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.SignalCommand; }
-
- public SignalFacade(ConfigTree config) throws ConfigurationException
- {
- _transition = config.getAttribute(Constants.TRANSITION_NAME_TAG);
- _variables = FacadeUtil.variablesFromConfig(config, false);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_transition)
- body.add(Constants.TRANSITION_NAME, _transition);
- FacadeUtil.populateVariableValues(message, _variables);
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- Body body = response.getBody();
- Object obj = body.get(Constants.JBPM_RETURN_OBJECT);
- if (obj instanceof Token)
- body.add(Constants.CURRENT_NODE_NAME,((Token)obj).getNode().getName());
- FacadeUtil.jbpmVarsToMessage(response, _variables);
- return response;
- } // ________________________________
-
- String _transition;
- VariableMapping _variables;
-}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java (from rev 16701, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/SignalFacade.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/SignalFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,59 @@
+/*
+ * 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.mapping;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
+
+/**
+ *
+ * Implementation of a message preprocessor to obtain data from a process instance
+ * from the action configuration XML
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class SignalFacade extends MessageFacade
+{
+ public OpCode getOpCode() { return Constants.OpCode.SignalCommand; }
+
+ public SignalFacade(ConfigTree config) throws ConfigurationException
+ {
+ _transition = config.getAttribute(Constants.TRANSITION_NAME_TAG);
+ _variables = FacadeUtil.variablesFromConfig(config, false);
+ }
+
+ public void setJBPMContextParameters(Message message)
+ {
+ Body body = message.getBody();
+ if (null!=_transition)
+ body.add(Constants.TRANSITION_NAME, _transition);
+ FacadeUtil.populateVariableValues(message, _variables);
+ }
+
+ String _transition;
+ VariableMapping _variables;
+}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/StartWorkOnTaskFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/StartWorkOnTaskFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/StartWorkOnTaskFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,59 +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.impl.facades;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-
-/**
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class StartWorkOnTaskFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.StartWorkOnTaskCommand; }
-
- public StartWorkOnTaskFacade(ConfigTree config) throws ConfigurationException
- {
- _overwriteSwim = FacadeUtil.booleanFromConfig(config,Constants.OVERWRITE_SWIMLANE_TAG);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_overwriteSwim)
- body.add(Constants.OVERWRITE_SWIMLANE,_overwriteSwim);
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- return response;
- } // ________________________________
-
- Boolean _overwriteSwim;
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/TaskInstanceEndFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/TaskInstanceEndFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/TaskInstanceEndFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,63 +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.impl.facades;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-
-/**
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class TaskInstanceEndFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.TaskInstanceEndCommand; }
-
- public TaskInstanceEndFacade(ConfigTree config) throws ConfigurationException
- {
- _variables = FacadeUtil.variablesFromConfig(config, false);
- _transitionName = config.getAttribute(Constants.TRANSITION_NAME_TAG);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- Body body = message.getBody();
- if (null!=_transitionName)
- body.add(Constants.TRANSITION_NAME, _transitionName);
- FacadeUtil.populateVariableValues(message, _variables);
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- FacadeUtil.jbpmVarsToMessage(response, _variables);
- return response;
- } // ________________________________
-
- String _transitionName;
- VariableMapping _variables;
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/VariableMapping.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,66 +0,0 @@
-package org.jboss.soa.esb.services.jbpm.actions.impl.facades;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.soa.esb.util.Util;
-
-/**
- * A container for variable names and values with access both by esb name and jbpm name.
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- *
- */
-public class VariableMapping
-{
- // internal key is always esb name
- private Map<String,Object> _values = new HashMap<String, Object>();
- // map jbpm names to esb names
- private Map<String,String> _jbpmNames = new HashMap<String, String>();
- // map esb names to jbpm names
- private Map<String,String> _esbNames = new HashMap<String, String>();
-
- public int size() { return _values.size(); }
-
- private String setMapping(String esbName, String jbpmName)
- {
- if (Util.isNullString(esbName) && Util.isNullString(jbpmName))
- throw new IllegalArgumentException("You must specify at least one valid variable name (esb or bpm)");
- if (Util.isNullString(jbpmName))
- jbpmName = getName(esbName);
- if (Util.isNullString(esbName))
- esbName = getName(jbpmName);
- String oldMapping = _esbNames.get(jbpmName);
- if (null!=oldMapping && !oldMapping.equals(jbpmName))
- throw new IllegalArgumentException
- ("Illegal mapping esb=<"+esbName+"> was mapped to bpm=<"+oldMapping+ "> cannot remap to "+jbpmName);
-
- _esbNames .put(esbName, jbpmName);
- _jbpmNames .put(jbpmName, esbName);
- // Internally, esbName is the key to the variable values
- return esbName;
- }
-
- protected String getName(String path)
- {
- String name = path;
- int index = path.lastIndexOf(".");
- if (index > 0) {
- name = path.substring(index+1);
- }
- return name;
- }
-
- public void setVariable(String esbName, String jbpmName, Object value)
- {
- _values .put(setMapping(esbName, jbpmName), value);
- }
-
- public String getEsbName (String key) { return _jbpmNames.get(key); }
- public String getJbpmName (String key) { return _esbNames.get(key); }
-
- public Object getEsbVariable (String key) { return _values.get(key); }
- public Object getJbpmVariable(String key) { return _values.get(_jbpmNames.get(key)); }
-
- public Map<String,Object> esbVariables() { return _values; }
-}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java (from rev 16701, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/VariableMapping.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMapping.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,66 @@
+package org.jboss.soa.esb.services.jbpm.mapping;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * A container for variable names and values with access both by esb name and jbpm name.
+ *
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ *
+ */
+public class VariableMapping
+{
+ // internal key is always esb name
+ private Map<String,Object> _values = new HashMap<String, Object>();
+ // map jbpm names to esb names
+ private Map<String,String> _jbpmNames = new HashMap<String, String>();
+ // map esb names to jbpm names
+ private Map<String,String> _esbNames = new HashMap<String, String>();
+
+ public int size() { return _values.size(); }
+
+ private String setMapping(String esbName, String jbpmName)
+ {
+ if (Util.isNullString(esbName) && Util.isNullString(jbpmName))
+ throw new IllegalArgumentException("You must specify at least one valid variable name (esb or bpm)");
+ if (Util.isNullString(jbpmName))
+ jbpmName = getName(esbName);
+ if (Util.isNullString(esbName))
+ esbName = getName(jbpmName);
+ String oldMapping = _esbNames.get(jbpmName);
+ if (null!=oldMapping && !oldMapping.equals(jbpmName))
+ throw new IllegalArgumentException
+ ("Illegal mapping esb=<"+esbName+"> was mapped to bpm=<"+oldMapping+ "> cannot remap to "+jbpmName);
+
+ _esbNames .put(esbName, jbpmName);
+ _jbpmNames .put(jbpmName, esbName);
+ // Internally, esbName is the key to the variable values
+ return esbName;
+ }
+
+ protected String getName(String path)
+ {
+ String name = path;
+ int index = path.lastIndexOf(".");
+ if (index > 0) {
+ name = path.substring(index+1);
+ }
+ return name;
+ }
+
+ public void setVariable(String esbName, String jbpmName, Object value)
+ {
+ _values .put(setMapping(esbName, jbpmName), value);
+ }
+
+ public String getEsbName (String key) { return _jbpmNames.get(key); }
+ public String getJbpmName (String key) { return _esbNames.get(key); }
+
+ public Object getEsbVariable (String key) { return _values.get(key); }
+ public Object getJbpmVariable(String key) { return _values.get(_jbpmNames.get(key)); }
+
+ public Map<String,Object> esbVariables() { return _values; }
+}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariablesFacade.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/VariablesFacade.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/mapping/VariablesFacade.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,60 +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.impl.facades;
-
-import org.jboss.soa.esb.ConfigurationException;
-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.Constants.OpCode;
-import org.jboss.soa.esb.services.jbpm.actions.BpmProcessor;
-
-/**
- *
- * Implementation of a message preprocessor to obtain data from a process instance
- * from the action configuration XML
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class VariablesFacade implements BpmProcessor.MessageFacade
-{
- public OpCode getOpCode() { return Constants.OpCode.VariablesCommand; }
-
- public VariablesFacade(ConfigTree config) throws ConfigurationException
- {
- _variables = FacadeUtil.variablesFromConfig(config, false);
- } // ________________________________
-
- public void preFormat(Message message)
- {
- FacadeUtil.populateVariableValues(message, _variables);
- } // _______________________________
-
- public Message postFormat(Message response)
- {
- FacadeUtil.jbpmVarsToMessage(response, _variables);
- return response;
- } // ________________________________
-
- VariableMapping _variables;
-}
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/util/Helper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/util/Helper.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/util/Helper.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,138 +0,0 @@
-package org.jboss.soa.esb.services.jbpm.util;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-
-public class Helper
-{
- private static Logger _logger = Logger.getLogger(Helper.class);
-
- public static String argumentException(String str) throws Exception
- {
- throw new Exception("Missing or invalid <"+str+"> object in Message body");
- } //________________________________
-
- public static Message commandMessageTemplate()
- {
- Message template = MessageFactory.getInstance().getMessage();
- URI uri = null;
- try { uri = new URI(UUID.randomUUID().toString()); }
- catch (URISyntaxException e)
- {
- _logger.fatal("Problem with UUID.randomUUID() - This should not happen");
- return null;
- }
- template.getHeader().getCall().setMessageID(uri);
-
- return template;
- } //________________________________
-
- public static void setLongValue(Message message, String key, Long value)
- {
- setObjectValue(message, key, value);
- }
- public static void setIntValue(Message message, String key, Integer value)
- {
- setObjectValue(message, key, value);
- }
- public static void setBooleanValue(Message message, String key, Boolean value)
- {
- setObjectValue(message, key, value);
- }
- public static void setObjectValue(Message message, String key, Object value)
- {
- message.getBody().add(key, value);
- }
-
- public static void setStringValue(Message msg,String key,Object obj)
- {
- setStringValue(msg, key, obj.toString());
- } //________________________________
-
- public static void setStringValue(Message msg,String key,String str)
- {
- setObjectValue(msg, key, str);
- } //________________________________
-
- public static void setStringListValue(Message msg,String key,String[] list)
- {
- boolean addComma = false;
- StringBuilder sb = new StringBuilder();
- for (String curr : list)
- {
- sb.append((addComma)?",":"").append(curr);
- addComma = true;
- }
- setObjectValue(msg,key, sb.toString());
- } //________________________________
-
- public static void setVariablesMap(Message msg,String key,Map<String,Object> value) throws Exception
- {
- msg.getBody().add(key, value);
- } //________________________________
-
- public static Integer getIntValue(Message msg,String key) throws Exception
- {
- Object obj = msg.getBody().get(key);
- if (obj instanceof Integer) return (Integer)obj;
- if (obj instanceof String) return Integer.parseInt((String)obj);
- throw new Exception(argumentException(key));
- } //________________________________
-
- public static Long getLongValue(Message msg,String key) throws Exception
- {
- Object obj = msg.getBody().get(key);
- if (null==obj) return null;
- if (obj instanceof Long) return (Long)obj;
- if (obj instanceof String) return Long.parseLong((String)obj);
- if (obj instanceof Integer) return new Long(obj.toString());
- throw new Exception(argumentException(key));
- } //________________________________
-
- public static Boolean getBooleanValue(Message msg,String key) throws Exception
- {
- return getBooleanValue(msg, key, null);
- } //________________________________
-
- public static Boolean getBooleanValue(Message msg,String key, Boolean dflt) throws Exception
- {
- Object obj = msg.getBody().get(key);
- if (null==obj) return dflt;
- if (obj instanceof Boolean) return (Boolean)obj;
- if (obj instanceof String) return Boolean.parseBoolean((String)obj);
- throw new Exception(argumentException(key));
- } //________________________________
-
- public static String getStringValue(Message msg,String key) throws Exception
- {
- return getStringValue(msg, key, null);
- } //________________________________
- public static String getStringValue(Message msg,String key, String dflt) throws Exception
- {
- Object obj = msg.getBody().get(key);
- if (null==obj) return dflt;
- if (obj instanceof String) return (String)obj;
- throw new Exception(argumentException(key));
- } //________________________________
-
- @SuppressWarnings("unchecked")
- public static Map<String,Object>getVariablesMap(Message msg,String key) throws Exception
- {
- Object obj = msg.getBody().get(key);
- if (null==obj) return null;
- if (obj instanceof Map) return (Map<String,Object>)obj;
- throw new Exception(argumentException(key));
- } //________________________________
-
- public static Object getObjectValue(Message msg,String key)
- {
- return msg.getBody().get(key);
- } //________________________________
-
-}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandlerUnitTest.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -34,7 +34,6 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.jboss.soa.esb.message.MessagePayloadProxy;
public class EsbActionHandlerUnitTest extends TestCase
{
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -30,14 +30,9 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.util.Helper;
+import org.jboss.soa.esb.services.jbpm.mapping.MessageHelper;
import org.jbpm.JbpmConfiguration;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -49,7 +44,7 @@
public class BpmProcessorUnitTest
{
-
+ static BpmProcessor processor;
private static Class thisClass = BpmProcessorUnitTest.class;
static Logger _logger = Logger.getLogger(thisClass);
@@ -60,21 +55,6 @@
return new JUnit4TestAdapter(thisClass);
}
- @BeforeClass
- public static void runBeforeAllTests()
- {
- _logger.info("@BeforeClass invoked");
- try
- {
- }
- catch (Exception e)
- {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
-
@AfterClass
public static void runAfterAllTests() throws Exception
{
@@ -86,112 +66,35 @@
_hibernateConfFile.delete();
}
}
-
@Test
- public void mockTest()
+ public void testDeployFromFile()
{
- // place holder so test will run even with no other @Test
- _logger.info("Mock test invoked");
- assertTrue(true);
- }
-
- @Test
- public void testDeployFromFile()
- {
- Message response;
- BpmProcessor command;
- String ret;
- try
- {
- String xml = JbpmTestUtil.stringFromFile("testDeployFromFile.xml");
- ConfigTree[] actions = ConfigTree.fromXml(xml).getChildren("action");
+ try
+ {
+ String xml = JbpmTestUtil.stringFromFile("testDeployFromFile.xml");
+ ConfigTree[] actions = ConfigTree.fromXml(xml).getChildren("action");
- command = new BpmProcessor(actions[0]);
- response = command.process(Helper.commandMessageTemplate());
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- _logger.error(e);
- assertTrue(false);
- }
+ BpmProcessor command = new BpmProcessor(actions[0]);
+ command.process(MessageHelper.commandMessageTemplate());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ _logger.error(e);
+ assertTrue(false);
+ }
}
@Test
public void testBpmProcessor()
{
- Message request, response;
- BpmProcessor command;
- String ret;
try
{
String xml = JbpmTestUtil.stringFromFile("testSingleCommands.xml");
ConfigTree[] actions = ConfigTree.fromXml(xml).getChildren("action");
int index = 0;
-
- command = new BpmProcessor(actions[index++]);
- response = command.process(Helper.commandMessageTemplate());
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
- // Keep the variables for comparison in future steps
- ConfigTree[] vars = actions[index].getChildren(Constants.OBJECT_PATH_TAG);
-
- command = new BpmProcessor(actions[index++]);
- request = Helper.commandMessageTemplate();
- response = command.process(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
- Long tokenId = (Long)response.getBody().get(Constants.TOKEN_ID);
- Long processId = (Long)response.getBody().get(Constants.PROCESS_INSTANCE_ID);
-
- command = new BpmProcessor(actions[index++]);
- request = Helper.commandMessageTemplate();
- Helper.setLongValue(request, Constants.TOKEN_ID, tokenId);
- response = command.process(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
- // we've mapped differently, so check if mapping worked both ways
- Body body = response.getBody();
- assertTrue(vars[1].getAttribute("value").equals(body.get("xxx")));
- assertTrue(vars[2].getAttribute("value").equals(body.get("yyy")));
- assertTrue(vars[3].getAttribute("value").equals(body.get("newVar")));
-
- command = new BpmProcessor(actions[index++]);
- request = Helper.commandMessageTemplate();
- Helper.setLongValue(request, Constants.TOKEN_ID, tokenId);
- String myContent = "My content travels in the message";
- request.getBody().add(myContent.getBytes());
- response = command.process(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
- command = new BpmProcessor(actions[index++]);
- request = Helper.commandMessageTemplate();
- Helper.setLongValue(request, Constants.PROCESS_INSTANCE_ID, processId);
- response = command.process(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
- command = new BpmProcessor(actions[index++]);
- request = Helper.commandMessageTemplate();
- Helper.setLongValue(request, Constants.PROCESS_INSTANCE_ID, processId);
- response = command.process(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, command.getOpCode()));
- ret = Helper.getStringValue(response, Constants.RETURN_CODE);
- assertTrue(Constants.RETCODE_OK.equals(ret));
-
+ BpmProcessor command = new BpmProcessor(actions[index++]);
+ command.process(MessageHelper.commandMessageTemplate());
}
catch (Exception e)
{
@@ -199,5 +102,7 @@
_logger.error(e);
assertTrue(false);
}
- } //________________________________
+ }
+
+
}
\ No newline at end of file
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreterUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreterUnitTest.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/CommandInterpreterUnitTest.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,167 +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 static org.junit.Assert.assertTrue;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-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.util.Helper;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.graph.exe.Token;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Test the jBPM command interpreter class
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
- */
-
-
-public class CommandInterpreterUnitTest
-{
-
- private static Class thisClass = CommandInterpreterUnitTest.class;
- static Logger _logger = Logger.getLogger(thisClass);
- static CommandInterpreter _interp;
- private static final String TEST_PROCESS_NAME = "simple";
-
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(thisClass);
- }
-
- @BeforeClass
- public static void runBeforeAllTests()
- {
- _logger.info("@BeforeClass invoked");
- try
- {
- }
- catch (Exception e)
- {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
-
- @AfterClass
- public static void runAfterAllTests() throws Exception
- {
- _logger.info("@AfterClass invoked");
- JbpmConfiguration.getInstance().dropSchema();
- }
-
- @Test
- public void mockTest()
- {
- // place holder so test will run even with no other @Test
- _logger.info("Mock test invoked");
- assertTrue(true);
- }
-
- @Test
- public void testFullProcessLifecycle()
- {
- long instanceId=0 , tokenId=0;
- Constants.OpCode opCode = null;
- Message request, response;
-
- _logger.info("testFullProcessLifecycle() invoked");
- try
- {
- opCode = Constants.OpCode.DeployProcessDefinition;
- request = Helper.commandMessageTemplate();
- Helper.setStringValue(request, Constants.COMMAND_CODE, opCode);
- Helper.setStringValue(request, Constants.PROCESS_DEFINITION_XML
- , JbpmTestUtil.stringFromFile("simpleProcessDefinition.xml"));
-
- response = invokeJbpm(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, opCode));
- assertTrue(Constants.RETCODE_OK.equals(Helper.getStringValue(response, Constants.RETURN_CODE)));
-
- opCode = Constants.OpCode.NewProcessInstanceCommand;
- request = Helper.commandMessageTemplate();
- request.getBody().add("key","some-order-id-key");
- Helper.setStringValue(request, Constants.COMMAND_CODE, opCode);
- Helper.setStringValue(request, Constants.PROCESS_DEFINITION_NAME, TEST_PROCESS_NAME);
- Helper.setStringValue(request, Constants.KEYPATH, "body.key");
- response = invokeJbpm(request);
- _logger.info(JbpmTestUtil.dumpResponse(response, opCode));
- assertTrue(Constants.RETCODE_OK.equals(Helper.getStringValue(response, Constants.RETURN_CODE)));
-
- instanceId = Helper.getLongValue(response,Constants.PROCESS_INSTANCE_ID);
- tokenId = Helper.getLongValue(response,Constants.TOKEN_ID);
- boolean signalToken = true;
- for (boolean continueLooping = true; continueLooping;)
- {
- opCode = Constants.OpCode.SignalCommand;
- // for this test, alternatively signal: token - process - token ...
-
- request = Helper.commandMessageTemplate();
- Helper.setStringValue(request, Constants.COMMAND_CODE, opCode);
- if (signalToken)
- Helper.setLongValue(request, Constants.TOKEN_ID, tokenId);
- else
- Helper.setLongValue(request, Constants.PROCESS_INSTANCE_ID, instanceId);
- response = invokeJbpm(request);
- signalToken = ! signalToken;
-
- if (null!=response)
- _logger.info(JbpmTestUtil.dumpResponse(response, opCode));
- else
- _logger.info("Response was not received");
- assertTrue(Constants.RETCODE_OK.equals(Helper.getObjectValue(response, Constants.RETURN_CODE)));
-
- Token token = (Token)Helper.getObjectValue(response, Constants.JBPM_RETURN_OBJECT);
- if (token.hasEnded())
- break;
- instanceId = Helper.getLongValue(response,Constants.PROCESS_INSTANCE_ID);
- tokenId = Helper.getLongValue(response,Constants.TOKEN_ID);
- }
-
- }
- catch (Exception _ex)
- {
- _ex.printStackTrace();
- assertTrue(false);
- }
-
- } //________________________________
-
- protected Message invokeJbpm(Message request) throws Exception
- {
- if (null==_interp)
- _interp = new CommandInterpreter(new ConfigTree("empty"));
- return _interp.process(request);
- }
-
-}
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/JbpmTestUtil.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -30,7 +30,6 @@
import java.io.PrintStream;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.services.jbpm.Constants;
import org.jboss.soa.esb.util.ClassUtil;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml 2007-11-20 16:13:58 UTC (rev 16703)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/testSingleCommands.xml 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,26 +1,4 @@
<testActions>
- <action name="TestEmbeddedDeploy"
- class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor"
- command="DeployProcessDefinition">
- <process-definition-xml version="1.0" encoding="UTF-8">
- <process-definition
- xmlns="urn:jbpm.org:jpdl-3.1"
- name="simple"
- >
- <start-state name="start">
- <transition name="to_state" to="first">
-
- </transition>
- </start-state>
- <state name="first">
- <transition name="to_end" to="end">
-
- </transition>
- </state>
- <end-state name="end"></end-state>
- </process-definition>
- </process-definition-xml>
- </action>
<action name="aNewInstance"
class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor"
@@ -35,38 +13,5 @@
<object-path esb="body.newVar" value="123" />
</action>
- <action name="nowGetItBack"
- class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor"
- command="GetProcessInstanceCommand"
- >
- <include-logs value="true"/>
- <include-all-variables value="true"/>
- <object-path esb="BODY_CONTENT" bpm="theBody" />
- <object-path esb="yyy" bpm="vJ22" />
- <object-path esb="xxx" bpm="j1" />
- <object-path bpm="newVar" />
- </action>
-
- <action name="testBodyContent"
- class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor"
- command="VariablesCommand"
- >
- <include-logs value="true"/>
- <object-path esb="BODY_CONTENT" bpm="theBody" />
- </action>
-
- <action name="nowCancelIt"
- class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor"
- command="CancelProcessInstanceCommand"
- >
- </action>
-
- <action name="getItAgain"
- class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor"
- command="GetProcessInstanceCommand"
- >
- <object-path esb="BODY_CONTENT" bpm="theBody" />
- </action>
-
</testActions>
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping (from rev 16630, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades)
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/VariableMappingUnitTest.java 2007-11-15 17:00:20 UTC (rev 16630)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -1,54 +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.impl.facades;
-
-import static org.junit.Assert.assertEquals;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.junit.Test;
-
-
-/**
- * @author kstam
- *
- */
-public class VariableMappingUnitTest
-{
-
- @Test
- public void testGetName()
- {
- VariableMapping mapper = new VariableMapping();
- String path = "body.someobjectname";
- String name = mapper.getName(path);
- assertEquals("someobjectname",name);
- }
-
-
-
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(VariableMappingUnitTest.class);
- }
-}
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java (from rev 16701, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/impl/facades/VariableMappingUnitTest.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/mapping/VariableMappingUnitTest.java 2007-11-20 16:14:49 UTC (rev 16704)
@@ -0,0 +1,55 @@
+/*
+ * 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.mapping;
+
+import static org.junit.Assert.assertEquals;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.services.jbpm.mapping.VariableMapping;
+import org.junit.Test;
+
+
+/**
+ * @author kstam
+ *
+ */
+public class VariableMappingUnitTest
+{
+
+ @Test
+ public void testGetName()
+ {
+ VariableMapping mapper = new VariableMapping();
+ String path = "body.someobjectname";
+ String name = mapper.getName(path);
+ assertEquals("someobjectname",name);
+ }
+
+
+
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(VariableMappingUnitTest.class);
+ }
+}
More information about the jboss-svn-commits
mailing list