[jbpm-commits] JBoss JBPM SVN: r3297 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl and 10 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 9 16:02:48 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-09 16:02:47 -0500 (Tue, 09 Dec 2008)
New Revision: 3297
Added:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java
Removed:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/DecisionHandler.java
Modified:
jbpm4/trunk/modules/distro/pom.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
Log:
exclusive handler
Modified: jbpm4/trunk/modules/distro/pom.xml
===================================================================
--- jbpm4/trunk/modules/distro/pom.xml 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/distro/pom.xml 2008-12-09 21:02:47 UTC (rev 3297)
@@ -39,7 +39,7 @@
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-gpd</artifactId>
<type>zip</type>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/DecisionHandler.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/DecisionHandler.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/DecisionHandler.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.jpdl;
-
-import org.jbpm.model.OpenExecution;
-
-
-/**
- * @author Tom Baeyens
- */
-public interface DecisionHandler {
-
- /** the name of the selected outgoing transition */
- String decide(OpenExecution execution);
-}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl;
+
+import org.jbpm.model.OpenExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface ExclusiveHandler {
+
+ /** the name of the selected outgoing transition */
+ String select(OpenExecution execution);
+}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -24,7 +24,7 @@
import org.jbpm.JbpmException;
import org.jbpm.activity.ActivityExecution;
import org.jbpm.env.Environment;
-import org.jbpm.jpdl.DecisionHandler;
+import org.jbpm.jpdl.ExclusiveHandler;
import org.jbpm.jpdl.JpdlException;
import org.jbpm.model.Node;
import org.jbpm.model.Transition;
@@ -38,29 +38,29 @@
private static final long serialVersionUID = 1L;
- protected String decisionHandlerName;
- protected Descriptor decisionHandlerDescriptor;
+ protected String exclusiveHandlerName;
+ protected Descriptor exclusiveHandlerDescriptor;
public void execute(ActivityExecution execution) throws Exception {
Node node = execution.getNode();
String transitionName = null;
Object object = null;
- if (decisionHandlerDescriptor!=null) {
- object = WireContext.create(decisionHandlerDescriptor);
- } else if (decisionHandlerName!=null) {
+ if (exclusiveHandlerDescriptor!=null) {
+ object = WireContext.create(exclusiveHandlerDescriptor);
+ } else if (exclusiveHandlerName!=null) {
Environment environment = Environment.getCurrent();
- object = environment.get(decisionHandlerName);
+ object = environment.get(exclusiveHandlerName);
}
if (object==null) {
throw new JpdlException("decision handler for "+node+" is null");
}
- if (! (object instanceof DecisionHandler)) {
- throw new JpdlException("handler for exclusive is not a "+DecisionHandler.class.getName()+": "+object.getClass().getName());
+ if (! (object instanceof ExclusiveHandler)) {
+ throw new JpdlException("handler for exclusive is not a "+ExclusiveHandler.class.getName()+": "+object.getClass().getName());
}
- DecisionHandler decisionHandler = (DecisionHandler) object;
- transitionName = decisionHandler.decide(execution);
+ ExclusiveHandler exclusiveHandler = (ExclusiveHandler) object;
+ transitionName = exclusiveHandler.select(execution);
Transition transition = node.getOutgoingTransition(transitionName);
if (transition==null) {
@@ -70,10 +70,10 @@
execution.take(transition);
}
- public void setDecisionHandlerName(String decisionHandlerName) {
- this.decisionHandlerName = decisionHandlerName;
+ public void setExclusiveHandlerName(String exclusiveHandlerName) {
+ this.exclusiveHandlerName = exclusiveHandlerName;
}
- public void setDecisionHandlerDescriptor(Descriptor decisionHandlerDescriptor) {
- this.decisionHandlerDescriptor = decisionHandlerDescriptor;
+ public void setExclusiveHandlerDescriptor(Descriptor exclusiveHandlerDescriptor) {
+ this.exclusiveHandlerDescriptor = exclusiveHandlerDescriptor;
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -57,18 +57,18 @@
}
if (element.hasAttribute("handler-ref")) {
- String decisionHandlerName = element.getAttribute("handler-ref");
+ String exclusiveHandlerName = element.getAttribute("handler-ref");
ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
- exclusiveHandlerActivity.setDecisionHandlerName(decisionHandlerName);
+ exclusiveHandlerActivity.setExclusiveHandlerName(exclusiveHandlerName);
return exclusiveHandlerActivity;
}
Element handlerElement = XmlUtil.element(element, "handler");
if (handlerElement!=null) {
ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
- ObjectDescriptor decisionHandlerDescriptor = (ObjectDescriptor)
+ ObjectDescriptor exclusiveHandlerDescriptor = (ObjectDescriptor)
objectBinding.parse(handlerElement, parse, parser);
- exclusiveHandlerActivity.setDecisionHandlerDescriptor(decisionHandlerDescriptor);
+ exclusiveHandlerActivity.setExclusiveHandlerDescriptor(exclusiveHandlerDescriptor);
return exclusiveHandlerActivity;
}
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml 2008-12-09 21:02:47 UTC (rev 3297)
@@ -22,7 +22,15 @@
<property name="expr" column="EXPR_" />
<property name="lang" column="LANG_" />
</subclass>
- <subclass name="org.jbpm.jpdl.activity.ExclusiveHandlerActivity" discriminator-value="excl-handler" />
+ <subclass name="org.jbpm.jpdl.activity.ExclusiveHandlerActivity" discriminator-value="excl-handler">
+ <property name="exclusiveHandlerName" column="EXCLNAME_" />
+ <many-to-one name="exclusiveHandlerDescriptor"
+ column="EXCLDESCR_"
+ cascade="all"
+ class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+ foreign-key="FK_ACT_EXCLDESCR"
+ index="IDX_ACT_EXCLDESCR" />
+ </subclass>
<subclass name="org.jbpm.jpdl.activity.StateActivity" discriminator-value="state" />
<subclass name="org.jbpm.jpdl.activity.EndActivity" discriminator-value="end" />
</class>
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -23,7 +23,7 @@
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.jpdl.DecisionHandler;
+import org.jbpm.jpdl.ExclusiveHandler;
import org.jbpm.jpdl.JpdlTestCase;
import org.jbpm.model.OpenExecution;
@@ -33,9 +33,9 @@
*/
public class DecisionHandlerTest extends JpdlTestCase {
- public static class GpsDecisionHandler implements DecisionHandler {
+ public static class GpsDecisionHandler implements ExclusiveHandler {
String theWayToGo;
- public String decide(OpenExecution execution) {
+ public String select(OpenExecution execution) {
return theWayToGo;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -22,6 +22,8 @@
package org.jbpm.pvm.internal.deploy;
import org.jbpm.JbpmException;
+import org.jbpm.Problem;
+import org.jbpm.log.Log;
import org.jbpm.pvm.internal.svc.DeploymentImpl;
@@ -29,9 +31,17 @@
* @author Tom Baeyens
*/
public class CheckProblemsDeployer implements Deployer {
+
+ private static final Log log = Log.getLog(CheckProblemsDeployer.class.getName());
public void deploy(DeploymentImpl deployment) {
if (deployment.hasProblems()) {
+ for (Problem problem: deployment.getProblems()) {
+ Throwable cause = problem.getCause();
+ if (cause!=null) {
+ log.debug("deployment exception", cause);
+ }
+ }
throw new JbpmException("problems during deployment: "+deployment.getProblemsText());
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -46,8 +46,8 @@
private static final long serialVersionUID = 1L;
- WireParser environmentFactoryXmlParser = new WireParser();
- WireParser environmentXmlParser = new WireParser();
+ Parser environmentFactoryXmlParser = new WireParser();
+ Parser environmentXmlParser = new WireParser();
protected static PvmEnvironmentFactoryParser INSTANCE = new PvmEnvironmentFactoryParser();
@@ -109,16 +109,16 @@
return null;
}
- public WireParser getEnvironmentFactoryXmlParser() {
+ public Parser getEnvironmentFactoryXmlParser() {
return environmentFactoryXmlParser;
}
- public void setEnvironmentFactoryXmlParser(WireParser applicationWireXmlParser) {
+ public void setEnvironmentFactoryXmlParser(Parser applicationWireXmlParser) {
this.environmentFactoryXmlParser = applicationWireXmlParser;
}
- public WireParser getEnvironmentXmlParser() {
+ public Parser getEnvironmentXmlParser() {
return environmentXmlParser;
}
- public void setEnvironmentXmlParser(WireParser blockWireXmlParser) {
+ public void setEnvironmentXmlParser(Parser blockWireXmlParser) {
this.environmentXmlParser = blockWireXmlParser;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -26,7 +26,6 @@
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -52,7 +51,7 @@
parse.addProblem("invoke must have method : "+XmlUtil.toString(element));
}
List<Element> argElements = XmlUtil.elements(element, "arg");
- WireParser wireParser = (WireParser) parser;
+ Parser wireParser = (Parser) parser;
List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
invokeOperation.setArgDescriptors(argDescriptors);
return invokeOperation;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -64,7 +64,7 @@
public Object parse(Element element, Parse parse, Parser parser) {
ObjectDescriptor descriptor = new ObjectDescriptor();
- WireParser wireParser = (WireParser) parser;
+ Parser wireParser = (Parser) parser;
String className = XmlUtil.attribute(element, "class");
String factoryObjectName = XmlUtil.attribute(element, "factory");
Element factoryElement = XmlUtil.element(element, "factory");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -26,7 +26,6 @@
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
import org.jbpm.pvm.internal.wire.operation.SubscribeOperation;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -74,7 +73,7 @@
String methodName = XmlUtil.attribute(element, "method");
subscribeOperation.setMethodName(methodName);
List<Element> argElements = XmlUtil.elements(element, "arg");
- WireParser wireParser = (WireParser) parser;
+ Parser wireParser = (Parser) parser;
List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
subscribeOperation.setArgDescriptors(argDescriptors);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -1,7 +1,6 @@
package org.jbpm.pvm.internal.wire.xml;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
@@ -25,7 +24,6 @@
import org.jbpm.pvm.internal.wire.binding.SetBinding;
import org.jbpm.pvm.internal.wire.binding.StringBinding;
import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.xml.Bindings;
import org.jbpm.pvm.internal.xml.Parse;
@@ -261,36 +259,6 @@
// other methods ////////////////////////////////////////////////////////////
- /**
- * Parses the list of arguments of a method.
- * This method creates a list of {@link ArgDescriptor} from the given list of DOM elements
- * @param argElements the list of argument DOM elements
- * @param parse Parse object that contains all information for the current parse operation.
- * @return the list of ArgDescriptor created from the DOM elements
- * @see ArgDescriptor
- */
- public List<ArgDescriptor> parseArgs(List<Element> argElements, Parse parse) {
- List<ArgDescriptor> args = null;
- if (argElements!=null) {
- if (argElements.size()>0) {
- args = new ArrayList<ArgDescriptor>(argElements.size());
- }
- for (Element argElement: argElements) {
- ArgDescriptor argDescriptor = new ArgDescriptor();
- argDescriptor.setTypeName(XmlUtil.attribute(argElement, "type"));
- Element descriptorElement = XmlUtil.element(argElement);
- if (descriptorElement==null) {
- parse.addProblem("arg must contain exactly one descriptor element out of "+bindings.getTagNames(CATEGORY_DESCRIPTOR)+" as contents:"+XmlUtil.toString((Element) argElement.getParentNode()));
- } else {
- Descriptor descriptor = (Descriptor) parseElement(descriptorElement, parse, CATEGORY_DESCRIPTOR);
- argDescriptor.setDescriptor(descriptor);
- }
- args.add(argDescriptor);
- }
- }
- return args;
- }
-
static {
// default descriptor parsers ///////////////////////////////////////////////
defaultBindings = new Bindings();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -35,6 +35,9 @@
import org.jbpm.pvm.internal.stream.StreamInput;
import org.jbpm.pvm.internal.util.UrlEntity;
import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.EntityResolver;
@@ -512,4 +515,30 @@
return object;
}
+
+ public List<ArgDescriptor> parseArgs(List<Element> argElements, Parse parse) {
+ return parseArgs(argElements, parse, WireParser.CATEGORY_DESCRIPTOR);
+ }
+
+ public List<ArgDescriptor> parseArgs(List<Element> argElements, Parse parse, String category) {
+ List<ArgDescriptor> args = null;
+ if (argElements!=null) {
+ if (argElements.size()>0) {
+ args = new ArrayList<ArgDescriptor>(argElements.size());
+ }
+ for (Element argElement: argElements) {
+ ArgDescriptor argDescriptor = new ArgDescriptor();
+ argDescriptor.setTypeName(XmlUtil.attribute(argElement, "type"));
+ Element descriptorElement = XmlUtil.element(argElement);
+ if (descriptorElement==null) {
+ parse.addProblem("arg must contain exactly one descriptor element out of "+bindings.getTagNames(category)+" as contents:"+XmlUtil.toString((Element) argElement.getParentNode()));
+ } else {
+ Descriptor descriptor = (Descriptor) parseElement(descriptorElement, parse, category);
+ argDescriptor.setDescriptor(descriptor);
+ }
+ args.add(argDescriptor);
+ }
+ }
+ return args;
+ }
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-09 16:17:05 UTC (rev 3296)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-09 21:02:47 UTC (rev 3297)
@@ -21,10 +21,13 @@
*/
package org.jbpm.test.activities;
+import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Map;
import org.jbpm.Execution;
+import org.jbpm.jpdl.ExclusiveHandler;
+import org.jbpm.model.OpenExecution;
import org.jbpm.test.DbTestCase;
@@ -33,7 +36,7 @@
*/
public class ExclusiveTest extends DbTestCase {
- public void testWaitStatesSequence() {
+ public void testExclusiveExpression() {
deployJpdlXmlString(
"<process name='Poolcar'>" +
" <start>" +
@@ -57,4 +60,40 @@
execution = executionService.startExecutionByKey("Poolcar", variables);
assertEquals("Small car", execution.getNodeName());
}
+
+ public static class DistanceHandler implements ExclusiveHandler {
+ public String select(OpenExecution execution) {
+ String distance = (String) execution.getVariable("distance");
+ if (new Integer(distance) < 10) {
+ return "nearby";
+ }
+ return "far";
+ }
+ }
+
+ public void testExclusiveHandler() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <flow to='How far?' />" +
+ " </start>" +
+ " <exclusive name='How far?'>" +
+ " <handler class='"+DistanceHandler.class.getName()+"' />" +
+ " <flow name='far' to='Big car' />" +
+ " <flow name='nearby' to='Small car' />" +
+ " </exclusive>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", "69");
+ Execution execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Big car", execution.getNodeName());
+
+ variables.put("distance", "3");
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Small car", execution.getNodeName());
+ }
}
More information about the jbpm-commits
mailing list