[jbpm-commits] JBoss JBPM SVN: r3106 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/deploy and 12 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Nov 26 13:01:58 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-11-26 13:01:57 -0500 (Wed, 26 Nov 2008)
New Revision: 3106
Added:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/Problem.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblems.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Problem.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/Deployment.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/deploy/ParseJpdlDeployer.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/NodeParsingTest.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ParsingTestCase.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckVersion.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateProcess.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveProcess.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckVersionBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateProcessBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveProcessBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
jbpm4/trunk/modules/pvm/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/XmlParsingTest.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/ProcessTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/StateTest.java
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
Log:
deployment parsing error collection
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/Deployment.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/Deployment.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/Deployment.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -57,4 +57,6 @@
ProcessDefinition deploy();
List<ProcessDefinition> deployAll();
+
+ List<Problem> getProblems();
}
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/Problem.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/Problem.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/Problem.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Problem {
+
+ public abstract Throwable getCause();
+
+ public abstract int getColumn();
+
+ public abstract int getLine();
+
+ public abstract String getMsg();
+
+ public abstract String getResource();
+
+ public abstract String getSeverity();
+
+}
\ No newline at end of file
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/deploy/ParseJpdlDeployer.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/deploy/ParseJpdlDeployer.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/deploy/ParseJpdlDeployer.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -41,6 +41,7 @@
// parse them
Parse parse = jpdlParser.createParse();
+ parse.setProblems(deployment.getProblems());
parse.setInputStream(deployment.getFile(fileName));
parse.execute();
@@ -51,8 +52,6 @@
// add the parsed process definition to the objects
// this is where the save process deployer will find it
deployment.addObject(fileName, parse.getDocumentObject());
- // add the parse for error logging
- deployment.addParse(fileName, parse);
}
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -21,7 +21,15 @@
*/
package org.jbpm.jpdl.xml;
+import java.util.List;
+
+import org.jbpm.jpdl.xml.JpdlParser.UnresolvedTransitions;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.TagBinding;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
/**
@@ -32,5 +40,36 @@
public JpdlActivityBinding(String tagName) {
super(tagName, "http://jbpm.org/jpdl4", "activity");
}
+
+ public void parseName(Element element, NodeImpl node, Parse parse) {
+ String name = XmlUtil.attribute(element, "name", isNameRequired(), parse);
+
+ if (name!=null) {
+ // basic name validation
+ if ("".equals(name)) {
+ parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "is empty"));
+ } else if (name.indexOf('/')!=-1) {
+ parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "contains slash (/)"));
+ }
+ node.setName(name);
+ }
+ }
+
+ public boolean isNameRequired() {
+ return true;
+ }
+
+ public void parseFlows(Element element, NodeImpl node, Parse parse) {
+ List<Element> transitionElements = XmlUtil.elements(element, "flow");
+ if (transitionElements!=null) {
+ UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
+ for (Element transitionElement: transitionElements) {
+ String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+ TransitionImpl transition = node.createOutgoingTransition(transitionName);
+ unresolvedTransitions.add(transition, transitionElement);
+ }
+ }
+ }
+
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -77,6 +77,11 @@
processDefinition.setVersion(version);
}
+ String key = XmlUtil.attribute(documentElement, "key", false, parse);
+ if (key!=null) {
+ processDefinition.setKey(key);
+ }
+
Element descriptionElement = XmlUtil.element(documentElement, "description");
if (descriptionElement!=null) {
String description = XmlUtil.getContentText(descriptionElement);
@@ -89,12 +94,13 @@
List<Element> elements = XmlUtil.elements(documentElement);
if (elements!=null) {
for (Element element: elements) {
- Binding activityBinding = getBinding(element, "activity");
+ JpdlActivityBinding activityBinding = (JpdlActivityBinding) getBinding(element, "activity");
if (activityBinding!=null) {
NodeImpl node = (NodeImpl) processDefinition.createNode();
- parseNodeInformation(element, node, parse);
parse.pushObject(node);
try {
+ activityBinding.parseName(element, node, parse);
+ activityBinding.parseFlows(element, node, parse);
Activity activity = (Activity) activityBinding.parse(element, parse, this);
node.setBehaviour(activity);
} finally {
@@ -109,7 +115,7 @@
}
// TODO remove the initial attribute parsing
- String initialNodeName = XmlUtil.attribute(documentElement, "initial", true, parse);
+ String initialNodeName = XmlUtil.attribute(documentElement, "initial", false, parse);
if (initialNodeName!=null) {
NodeImpl initial = processDefinition.getNode(initialNodeName);
if (initial==null) {
@@ -137,30 +143,6 @@
return processDefinition;
}
- public void parseNodeInformation(Element element, NodeImpl node, Parse parse) {
- String name = XmlUtil.attribute(element, "name", true, parse);
-
- if (name!=null) {
- // basic name validation
- if ("".equals(name)) {
- parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "is empty"));
- } else if (name.indexOf('/')!=-1) {
- parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "contains slash (/)"));
- }
- node.setName(name);
- }
-
- List<Element> transitionElements = XmlUtil.elements(element, "flow");
- if (transitionElements!=null) {
- UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
- for (Element transitionElement: transitionElements) {
- String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
- TransitionImpl transition = node.createOutgoingTransition(transitionName);
- unresolvedTransitions.add(transition, transitionElement);
- }
- }
- }
-
static class UnresolvedTransitions {
List<UnresolvedTransition> list = new ArrayList<UnresolvedTransition>();
public void add(TransitionImpl transition, Element transitionElement) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -44,4 +44,7 @@
return new StartActivity();
}
+ public boolean isNameRequired() {
+ return false;
+ }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StateBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -22,6 +22,8 @@
package org.jbpm.jpdl.xml;
import org.jbpm.jpdl.activity.StateActivity;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,7 +23,7 @@
import java.util.List;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/NodeParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/NodeParsingTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/NodeParsingTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,7 +23,7 @@
import java.util.List;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ParsingTestCase.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ParsingTestCase.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ParsingTestCase.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,9 +23,9 @@
import java.util.List;
+import org.jbpm.Problem;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.jpdl.xml.JpdlParser;
-import org.jbpm.pvm.internal.xml.Problem;
import org.jbpm.test.JbpmTestCase;
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,8 +23,8 @@
import java.util.List;
+import org.jbpm.Problem;
import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.internal.xml.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,10 +23,10 @@
import java.util.List;
+import org.jbpm.Problem;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.model.Node;
import org.jbpm.model.Transition;
-import org.jbpm.pvm.internal.xml.Problem;
/**
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblems.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblems.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblems.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -0,0 +1,39 @@
+/*
+ * 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.pvm.internal.deploy;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckProblems implements Deployer {
+
+ public void deploy(DeploymentImpl deployment) {
+ if (deployment.hasProblems()) {
+ throw new JbpmException("problems during deployment: "+deployment.getProblemsText());
+ }
+ }
+
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckVersion.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckVersion.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckVersion.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.deploy;
-import org.jbpm.JbpmException;
import org.jbpm.ProcessDefinition;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.env.Environment;
@@ -43,32 +42,34 @@
for (String objectName : deployment.getObjectNames()) {
Object object = deployment.getObject(objectName);
if (object instanceof ProcessDefinition) {
- checkProcessDefinition((ProcessDefinitionImpl)object);
+ checkProcessDefinition((ProcessDefinitionImpl)object, deployment);
}
}
}
- public void checkProcessDefinition(ProcessDefinitionImpl processDefinition) {
+ public void checkProcessDefinition(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
String name = processDefinition.getName();
if (name == null) {
- throw new JbpmException("process must have a name to deploy it");
+ deployment.addProblem("process must have a name to deploy it");
}
int version = processDefinition.getVersion();
if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
&& ! assign
) {
- throw new JbpmException("no version specified in process definition "+name);
+ deployment.addProblem("no version specified in process definition "+name);
}
Environment environment = Environment.getCurrent();
if (environment==null) {
- throw new JbpmException("environment is required by deployer check-version");
+ deployment.addProblem("environment is required by deployer check-version");
+ return;
}
PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
if (pvmDbSession==null) {
- throw new JbpmException(PvmDbSession.class.getName()+" is required in the environment by "+getClass().getName());
+ deployment.addProblem(PvmDbSession.class.getName()+" is required in the environment by "+getClass().getName());
+ return;
}
if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
@@ -85,8 +86,12 @@
} else {
if (pvmDbSession.findProcessDefinitionByName(name, version) != null) {
- throw new JbpmException("process '" + name + "' version " + version + " already exists");
+ deployment.addProblem("process '" + name + "' version " + version + " already exists");
}
}
}
+
+ public void setAssign(boolean assign) {
+ this.assign = assign;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.deploy;
-import org.jbpm.JbpmException;
import org.jbpm.ProcessDefinition;
import org.jbpm.log.Log;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
@@ -39,12 +38,12 @@
for (String objectName : deployment.getObjectNames()) {
Object object = deployment.getObject(objectName);
if (object instanceof ProcessDefinition) {
- createId((ProcessDefinitionImpl)object);
+ createId((ProcessDefinitionImpl)object, deployment);
}
}
}
- private void createId(ProcessDefinitionImpl processDefinition) {
+ private void createId(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
if (processDefinition.getId()==null) {
String key = processDefinition.getKey();
if (key==null) {
@@ -52,7 +51,7 @@
}
if ("".equals(key)) {
- throw new JbpmException("empty string is not a valid key");
+ deployment.addProblem("empty string is not a valid key");
}
// replace any non-word character with an underscore
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateProcess.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateProcess.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CreateProcess.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -37,12 +37,13 @@
protected Class<?> processDefinitionClass;
- public void deploy(DeploymentImpl deploymentImpl) {
- ProcessDefinition processDefinition = deploymentImpl.getProcessDefinition();
+ public void deploy(DeploymentImpl deployment) {
+ ProcessDefinition processDefinition = deployment.getProcessDefinition();
if (processDefinition==null) {
if (processDefinitionClass==null) {
- throw new JbpmException("create-process deployer improperly configured: no class specified");
+ deployment.addProblem("create-process deployer improperly configured: no class specified");
+ return;
}
// instantiate
@@ -50,14 +51,19 @@
log.trace("creating new "+processDefinitionClass.getName());
processDefinition = (ProcessDefinition) processDefinitionClass.newInstance();
} catch (Exception e) {
- throw new JbpmException("couldn't instantiate process definition with class "+processDefinitionClass);
+ deployment.addProblem("couldn't instantiate process definition with class "+processDefinitionClass+": "+e.toString());
}
// make the process definition available in the deployment
- deploymentImpl.setProcessDefinition(processDefinition);
+ deployment.setProcessDefinition(processDefinition);
} else {
log.trace("using process definition provided in deployment");
}
}
+
+ public void setProcessDefinitionClass(Class< ? > processDefinitionClass) {
+ this.processDefinitionClass = processDefinitionClass;
+ }
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveProcess.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveProcess.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveProcess.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -39,14 +39,16 @@
public void deploy(DeploymentImpl deployment) {
Environment environment = Environment.getCurrent();
if (environment==null) {
- throw new JbpmException("environment is required by "+getClass().getName());
+ deployment.addProblem("environment is required by "+getClass().getName());
+ return;
}
PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
if (pvmDbSession==null) {
- throw new JbpmException(PvmDbSession.class.getName()+" is required in the environment by "+getClass().getName());
+ deployment.addProblem(PvmDbSession.class.getName()+" is required in the environment by "+getClass().getName());
+ return;
}
-
+
boolean deployedProcess = false;
for (String objectName : deployment.getObjectNames()) {
Object object = deployment.getObject(objectName);
@@ -60,7 +62,6 @@
if (!deployedProcess) {
log.info("no process definition in "+deployment);
}
-
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -36,8 +36,9 @@
import java.util.zip.ZipInputStream;
import org.jbpm.Deployment;
-import org.jbpm.ProcessDefinition;
import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.log.Log;
import org.jbpm.pvm.internal.stream.ByteArrayStreamSource;
import org.jbpm.pvm.internal.stream.FileStreamSource;
import org.jbpm.pvm.internal.stream.InputStreamSource;
@@ -48,6 +49,8 @@
import org.jbpm.pvm.internal.util.IoUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.pvm.internal.xml.ProblemImpl;
+import org.jbpm.pvm.internal.xml.ProblemList;
import org.w3c.dom.Document;
@@ -57,9 +60,11 @@
*
* @author Tom Baeyens
*/
-public class DeploymentImpl implements Deployment, Serializable {
+public class DeploymentImpl extends ProblemList implements Deployment, Serializable {
private static final long serialVersionUID = 1L;
+
+ private static final Log log = Log.getLog(DeploymentImpl.class.getName());
private static final Parser parser = new Parser();
@@ -72,20 +77,21 @@
protected Map<String, Document> documents;
protected Map<String, Object> objects;
- protected List<DeploymentParse> deploymentParses;
-
protected ProcessDefinition processDefinition;
-
+
public DeploymentImpl(ProcessServiceImpl processServiceImpl) {
this.processServiceImpl = processServiceImpl;
+ this.problems = new ArrayList<ProblemImpl>();
}
// TODO REMOVE
public DeploymentImpl() {
+ this.problems = new ArrayList<ProblemImpl>();
}
// TODO REMOVE replace with addObject
public DeploymentImpl(ProcessDefinition processDefinition) {
+ this.problems = new ArrayList<ProblemImpl>();
setProcessDefinition(processDefinition);
}
@@ -316,7 +322,7 @@
return processServiceImpl.deploy(this);
}
- // error logging
+ // error logging ////////////////////////////////////////////////////////////
public class DeploymentParse {
String name;
@@ -327,33 +333,6 @@
}
}
- public void addParse(String name, Parse parse) {
- if (deploymentParses==null) {
- deploymentParses = new ArrayList<DeploymentParse>();
- }
- deploymentParses.add(new DeploymentParse(name, parse));
- }
-
- public void checkProblems() {
- StringBuffer errorMsg = null;
- if (deploymentParses!=null) {
- boolean hasProblems = false;
- for (DeploymentParse deploymentParse: deploymentParses) {
- if (deploymentParse.parse.hasProblems()) {
- hasProblems = true;
- if (errorMsg==null) {
- errorMsg = new StringBuffer();
- }
- errorMsg.append("problems during parse of "+deploymentParse.name+":");
- errorMsg.append(deploymentParse.parse.logProblems());
- }
- }
- }
- if (errorMsg!=null) {
- throw new JbpmException("errors during parsing of "+this+": "+errorMsg);
- }
- }
-
public String toString() {
if (name!=null) {
return "deployment("+name+")";
@@ -367,4 +346,20 @@
}
documents.put(name, document);
}
+
+ /** throws an exception with appropriate message in case the parse contains
+ * errors or fatal errors. This method also logs the problems with severity
+ * 'warning'. */
+ public Deployment checkProblems() {
+ if (hasProblems()) {
+ String problemsText = getProblemsText();
+ if (problemsText!=null) {
+ String errorMsg = "problems during deployment of "+this+":"+problemsText;
+ log.info(errorMsg);
+ throw new JbpmException(errorMsg);
+ }
+ }
+ return this;
+ }
+
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -0,0 +1,45 @@
+/*
+ * 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.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.deploy.CheckProblems;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckProblemsBinding extends WireDescriptorBinding {
+
+ public CheckProblemsBinding() {
+ super("check-problems");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ CheckProblems checkProblems = new CheckProblems();
+ return new ProvidedObjectDescriptor(checkProblems);
+ }
+
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckVersionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckVersionBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckVersionBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -26,6 +26,7 @@
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -45,19 +46,13 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- ObjectDescriptor objectDescriptor = new ObjectDescriptor(CheckVersion.class.getName());
+ CheckVersion checkVersion = new CheckVersion();
Boolean assign = XmlUtil.attributeBoolean(element, "assign", false, parse, null);
if (assign!=null) {
- Descriptor valueDescriptor = null;
- if (assign) {
- valueDescriptor = new TrueDescriptor();
- } else {
- valueDescriptor = new FalseDescriptor();
- }
- objectDescriptor.addInjection("assign", valueDescriptor);
+ checkVersion.setAssign(assign);
}
- return objectDescriptor;
+ return new ProvidedObjectDescriptor(checkVersion);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.pvm.internal.deploy.CreateId;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -38,7 +38,8 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- return new ObjectDescriptor(CreateId.class);
+ CreateId createId = new CreateId();
+ return new ProvidedObjectDescriptor(createId);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateProcessBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateProcessBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateProcessBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -22,9 +22,11 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.pvm.internal.deploy.CreateProcess;
+import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ClassDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -43,20 +45,17 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- ObjectDescriptor descriptor = new ObjectDescriptor(CreateProcess.class);
+ CreateProcess createProcess = new CreateProcess();
if (element.hasAttribute("class")) {
- ClassDescriptor classDescriptor = new ClassDescriptor();
String className = element.getAttribute("class");
- classDescriptor.setClassName(className);
-
- descriptor.addInjection("processDefinitionClass", classDescriptor);
-
+ Class<?> processDefinitionClass = ReflectUtil.loadClass(parse.getClassLoader(), className);
+ createProcess.setProcessDefinitionClass(processDefinitionClass);
} else {
parse.addProblem("class is a required attribute in "+XmlUtil.toString(element));
}
- return descriptor;
+ return new ProvidedObjectDescriptor(createProcess);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveProcessBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveProcessBinding.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveProcessBinding.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.pvm.internal.deploy.SaveProcess;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -41,6 +41,7 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- return new ObjectDescriptor(SaveProcess.class);
+ SaveProcess saveProcess = new SaveProcess();
+ return new ProvidedObjectDescriptor(saveProcess);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -26,8 +26,6 @@
import java.io.InputStream;
import java.io.Serializable;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
import java.util.ListIterator;
import java.util.Stack;
@@ -51,11 +49,10 @@
*
* @author Tom Baeyens
*/
-public class Parse implements Serializable, ErrorHandler {
+public class Parse extends ProblemList implements Serializable, ErrorHandler {
private static Log log = Log.getLog(Parse.class.getName());
private static final long serialVersionUID = 1L;
- private static final String NEWLINE = System.getProperty("line.separator");
protected Parser parser;
@@ -68,7 +65,6 @@
protected Document document = null;
protected Stack<Object> objectStack;
- protected List<Problem> problems = null;
protected Object documentObject;
protected Parse(Parser parser) {
@@ -148,69 +144,17 @@
// problems /////////////////////////////////////////////////////////////////
- /** all problems encountered */
- public List<Problem> getProblems() {
- return problems;
- }
-
- /** to add parsing problems during XML parsing and DOM walking. */
- public void addProblem(Problem problem) {
- if (problems==null) {
- problems = new ArrayList<Problem>();
- }
- problems.add(problem);
- }
-
- /** add a problem with {@link Problem#SEVERITY_ERROR the default severity}.*/
- public void addProblem(String msg) {
- addProblem(msg, null);
- }
-
- /** add a problem with an exception cause and
- * {@link Problem#SEVERITY_ERROR the default severity}.*/
- public void addProblem(String msg, Exception e) {
- addProblem(msg, e, Problem.SEVERITY_ERROR);
- }
-
- /** adds a problem with {@link Problem#SEVERITY_WARNING severity warning}.*/
- public void addWarning(String msg) {
- addWarning(msg, null);
- }
-
- /** adds a problem with {@link Problem#SEVERITY_WARNING severity warning}
- * and an exception as the cause.*/
- public void addWarning(String msg, Exception e) {
- addProblem(msg, e, Problem.SEVERITY_WARNING);
- }
-
- /** adds a problem given message, exception cause and severity */
- public void addProblem(String msg, Exception e, String severity) {
- addProblem(new Problem(msg, e, severity));
- }
-
- /** indicates presence of problems */
- public boolean hasProblems() {
- return ((problems != null) && (problems.size() > 0));
- }
-
- /** allows to provide the list object that should be used to
- * capture the parsing problems. */
- public Parse setProblems(List<Problem> problems) {
- this.problems = problems;
- return this;
- }
-
/** part of {@link ErrorHandler} to capture XML parsing problems. */
public void error(SAXParseException e) {
- addProblem(e.getMessage(), e, Problem.SEVERITY_ERROR);
+ addProblem(e.getMessage(), e, ProblemImpl.SEVERITY_ERROR);
}
/** part of {@link ErrorHandler} to capture XML parsing problems. */
public void fatalError(SAXParseException e) {
- addProblem(e.getMessage(), e, Problem.SEVERITY_FATALERROR);
+ addProblem(e.getMessage(), e, ProblemImpl.SEVERITY_FATALERROR);
}
/** part of {@link ErrorHandler} to capture XML parsing problems. */
public void warning(SAXParseException e) {
- addProblem(e.getMessage(), e, Problem.SEVERITY_WARNING);
+ addProblem(e.getMessage(), e, ProblemImpl.SEVERITY_WARNING);
}
// contextual objects ///////////////////////////////////////////////////////
@@ -264,41 +208,15 @@
* 'warning'. */
public Parse checkProblems(String description) {
if (hasProblems()) {
- log.info("problems during parse of "+description+":");
- String errorMsg = logProblems();
+ String errorMsg = "problems during parse of "+description+":"+getProblemsText();
+ log.info(errorMsg);
if (errorMsg!=null) {
- throw new JbpmException("errors during parsing of "+description+": "+errorMsg);
+ throw new JbpmException(errorMsg);
}
}
return this;
}
- public String logProblems() {
- String errorMsg = null;
- if (problems!=null) {
- StringBuffer errorMsgBuffer = null;
- for (Problem p : getProblems()) {
- if (p.getSeverity().equals(Problem.SEVERITY_ERROR) || p.getSeverity().equals(Problem.SEVERITY_FATALERROR)) {
- if (errorMsgBuffer==null) {
- errorMsgBuffer = new StringBuffer();
- }
- errorMsgBuffer.append(NEWLINE);
- errorMsgBuffer.append(" ");
- errorMsgBuffer.append(p.toString());
- if (p.getCause()!=null) {
- log.error(p.toString(), p.getCause());
- } else {
- log.error(p.toString());
- }
- } else {
- log.info("WARNING: "+p.toString());
- }
- }
- errorMsg = (errorMsgBuffer!=null ? errorMsgBuffer.toString() : null);
- }
- return errorMsg;
- }
-
// getters and setters //////////////////////////////////////////////////////
/** the result of this parse operation. */
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Problem.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Problem.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Problem.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -1,127 +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.pvm.internal.xml;
-
-import java.io.Serializable;
-
-import org.xml.sax.SAXParseException;
-
-/**
- * a unification for an XML parsing errors and DOM interpretation problems, see also {@link Parser}.
- *
- * See also <a href="./Parser.html#problems">'Problems'</a>
- * @author Tom Baeyens
- */
-public class Problem implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String SEVERITY_WARNING = "warning";
- public static final String SEVERITY_ERROR = "error";
- public static final String SEVERITY_FATALERROR = "fatal-error";
-
- String resource;
- String severity;
- Integer line = -1;
- Integer column = -1;
- String msg;
- Throwable cause;
-
- public Problem(String msg, Exception e, String severity) {
- this.severity = severity;
- this.msg = msg;
- this.cause = e;
- if (e instanceof SAXParseException) {
- SAXParseException spe = (SAXParseException) e;
- this.resource = spe.getPublicId();
- this.line = spe.getLineNumber();
- this.column = spe.getColumnNumber();
- }
- }
-
- public Throwable getCause() {
- return cause;
- }
- public void setCause(Throwable cause) {
- this.cause = cause;
- }
- public int getColumn() {
- return column;
- }
- public void setColumn(int columnNumber) {
- this.column = columnNumber;
- }
- public int getLine() {
- return line;
- }
- public void setLine(int lineNumber) {
- this.line = lineNumber;
- }
- public String getMsg() {
- return msg;
- }
- public void setMsg(String msg) {
- this.msg = msg;
- }
- public String getResource() {
- return resource;
- }
- public void setResource(String resource) {
- this.resource = resource;
- }
- public String getSeverity() {
- return severity;
- }
- public void setSeverity(String severity) {
- this.severity = severity;
- }
-
- public String toString() {
- StringBuffer text = new StringBuffer();
- text.append(severity);
- text.append(" : ");
- text.append(msg);
- text.append(" ");
-
- if ((line!=-1) || (column!=-1) || (resource!=null)) {
- text.append("[");
- if (line!=-1) {
- text.append("line="+line+" ");
- }
-
- if (column!=-1) {
- text.append("column="+column+" ");
- }
-
- if (resource!=null) {
- text.append("resource="+resource+" ");
- }
- text.append("]");
- }
-
- if (cause!=null) {
- text.append(": " + cause.toString());
- }
-
- return text.toString();
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -0,0 +1,128 @@
+/*
+ * 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.pvm.internal.xml;
+
+import java.io.Serializable;
+
+import org.jbpm.Problem;
+import org.xml.sax.SAXParseException;
+
+/**
+ * a unification for an XML parsing errors and DOM interpretation problems, see also {@link Parser}.
+ *
+ * See also <a href="./Parser.html#problems">'Problems'</a>
+ * @author Tom Baeyens
+ */
+public class ProblemImpl implements Serializable, Problem {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String SEVERITY_WARNING = "warning";
+ public static final String SEVERITY_ERROR = "error";
+ public static final String SEVERITY_FATALERROR = "fatal-error";
+
+ String resource;
+ String severity;
+ Integer line = -1;
+ Integer column = -1;
+ String msg;
+ Throwable cause;
+
+ public ProblemImpl(String msg, Exception e, String severity) {
+ this.severity = severity;
+ this.msg = msg;
+ this.cause = e;
+ if (e instanceof SAXParseException) {
+ SAXParseException spe = (SAXParseException) e;
+ this.resource = spe.getPublicId();
+ this.line = spe.getLineNumber();
+ this.column = spe.getColumnNumber();
+ }
+ }
+
+ public Throwable getCause() {
+ return cause;
+ }
+ public void setCause(Throwable cause) {
+ this.cause = cause;
+ }
+ public int getColumn() {
+ return column;
+ }
+ public void setColumn(int columnNumber) {
+ this.column = columnNumber;
+ }
+ public int getLine() {
+ return line;
+ }
+ public void setLine(int lineNumber) {
+ this.line = lineNumber;
+ }
+ public String getMsg() {
+ return msg;
+ }
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+ public String getResource() {
+ return resource;
+ }
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+ public String getSeverity() {
+ return severity;
+ }
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ public String toString() {
+ StringBuffer text = new StringBuffer();
+ text.append(severity);
+ text.append(" : ");
+ text.append(msg);
+ text.append(" ");
+
+ if ((line!=-1) || (column!=-1) || (resource!=null)) {
+ text.append("[");
+ if (line!=-1) {
+ text.append("line="+line+" ");
+ }
+
+ if (column!=-1) {
+ text.append("column="+column+" ");
+ }
+
+ if (resource!=null) {
+ text.append("resource="+resource+" ");
+ }
+ text.append("]");
+ }
+
+ if (cause!=null) {
+ text.append(": " + cause.toString());
+ }
+
+ return text.toString();
+ }
+}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -0,0 +1,125 @@
+/*
+ * 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.pvm.internal.xml;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+
+/** list of problems. Base class for {@link Parse}
+ * and {@link DeploymentImpl}.
+ *
+ * @author Tom Baeyens
+ */
+public class ProblemList implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String NEWLINE = System.getProperty("line.separator");
+
+ private static final Log log = Log.getLog(ProblemList.class.getName());
+
+ protected List<ProblemImpl> problems = null;
+
+ /** all problems encountered */
+ public List<Problem> getProblems() {
+ return (List) problems;
+ }
+
+ /** to add parsing problems during XML parsing and DOM walking. */
+ public void addProblem(ProblemImpl problem) {
+ if (problems==null) {
+ problems = new ArrayList<ProblemImpl>();
+ }
+ problems.add(problem);
+ }
+
+ /** add a problem with {@link ProblemImpl#SEVERITY_ERROR the default severity}.*/
+ public void addProblem(String msg) {
+ addProblem(msg, null);
+ }
+
+ /** add a problem with an exception cause and
+ * {@link ProblemImpl#SEVERITY_ERROR the default severity}.*/
+ public void addProblem(String msg, Exception e) {
+ addProblem(msg, e, ProblemImpl.SEVERITY_ERROR);
+ }
+
+ /** adds a problem with {@link ProblemImpl#SEVERITY_WARNING severity warning}.*/
+ public void addWarning(String msg) {
+ addWarning(msg, null);
+ }
+
+ /** adds a problem with {@link ProblemImpl#SEVERITY_WARNING severity warning}
+ * and an exception as the cause.*/
+ public void addWarning(String msg, Exception e) {
+ addProblem(msg, e, ProblemImpl.SEVERITY_WARNING);
+ }
+
+ /** adds a problem given message, exception cause and severity */
+ public void addProblem(String msg, Exception e, String severity) {
+ addProblem(new ProblemImpl(msg, e, severity));
+ }
+
+ /** indicates presence of problems */
+ public boolean hasProblems() {
+ return ((problems != null) && (problems.size() > 0));
+ }
+
+ /** allows to provide the list object that should be used to
+ * capture the parsing problems. */
+ public void setProblems(List<Problem> problems) {
+ this.problems = (List)problems;
+ }
+
+
+ public String getProblemsText() {
+ String errorMsg = null;
+ if (problems!=null) {
+ StringBuffer errorMsgBuffer = null;
+ for (Problem p : getProblems()) {
+ if (p.getSeverity().equals(ProblemImpl.SEVERITY_ERROR) || p.getSeverity().equals(ProblemImpl.SEVERITY_FATALERROR)) {
+ if (errorMsgBuffer==null) {
+ errorMsgBuffer = new StringBuffer();
+ }
+ errorMsgBuffer.append(NEWLINE);
+ errorMsgBuffer.append(" ");
+ errorMsgBuffer.append(p.toString());
+ if (p.getCause()!=null) {
+ log.error(p.toString(), p.getCause());
+ } else {
+ log.error(p.toString());
+ }
+ } else {
+ log.info("WARNING: "+p.toString());
+ }
+ }
+ errorMsg = (errorMsgBuffer!=null ? errorMsgBuffer.toString() : null);
+ }
+ return errorMsg;
+ }
+}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml 2008-11-26 18:01:57 UTC (rev 3106)
@@ -62,6 +62,7 @@
<binding class="org.jbpm.pvm.internal.wire.binding.CheckVersionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.SaveProcessBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.CreateIdBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.CheckProblemsBinding" />
<!-- ############################ -->
<!-- ### Interceptor bindings ### -->
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,8 +23,7 @@
import java.util.List;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,8 +23,7 @@
import java.util.List;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -2,8 +2,8 @@
import java.util.List;
+import org.jbpm.Problem;
import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.xml.Problem;
/**
* Tests for the ClassDescriptor
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -25,8 +25,7 @@
import java.util.HashSet;
import java.util.List;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -4,8 +4,7 @@
import java.util.Map;
import java.util.TreeMap;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -24,9 +24,7 @@
import java.util.List;
import org.jbpm.JbpmException;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireException;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -21,16 +21,11 @@
*/
package org.jbpm.pvm.internal.wire;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.List;
import java.util.Properties;
+import org.jbpm.Problem;
import org.jbpm.pvm.internal.util.FileUtil;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireException;
-import org.jbpm.pvm.internal.xml.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -25,8 +25,7 @@
import java.util.Map;
import java.util.Set;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -3,8 +3,7 @@
import java.util.List;
import java.util.Set;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.Problem;
public class SetWireTest extends WireTestCase {
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -23,10 +23,8 @@
import java.util.List;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.Problem;
import org.jbpm.pvm.internal.wire.xml.WireParser;
-import org.jbpm.pvm.internal.xml.Problem;
import org.jbpm.test.JbpmTestCase;
/**
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/XmlParsingTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/XmlParsingTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/XmlParsingTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -4,12 +4,13 @@
import java.util.List;
import org.jbpm.JbpmException;
+import org.jbpm.Problem;
import org.jbpm.pvm.internal.util.TagBinding;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Bindings;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
-import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.pvm.internal.xml.ProblemImpl;
import org.jbpm.test.JbpmTestCase;
import org.w3c.dom.Element;
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -84,7 +84,7 @@
super.tearDown();
}
- public void deployJpdlXmlString(String jpdlXmlString) {
+ public ProcessDefinition deployJpdlXmlString(String jpdlXmlString) {
ProcessDefinition deployedProcessDefinition =
processService.createDeployment()
.setLanguage("jpdl")
@@ -96,5 +96,7 @@
}
processDefinitions.add(deployedProcessDefinition);
+
+ return deployedProcessDefinition;
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/ProcessTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/ProcessTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/ProcessTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -22,6 +22,7 @@
package org.jbpm.test.basicfeatures;
import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
import org.jbpm.test.DbTestCase;
@@ -61,4 +62,32 @@
assertTrue(execution.isFinished());
assertFalse(execution.isActive());
}
+
+ public void testGivenKey() {
+ deployJpdlXmlString(
+ "<process name='minimal' key='M'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinition("minimal");
+
+ assertEquals("M", processDefinition.getKey());
+ assertEquals("M:1", processDefinition.getId());
+ assertEquals(1, processDefinition.getVersion());
+ }
+
+ public void testGivenVersion() {
+ deployJpdlXmlString(
+ "<process name='minimal' version='23'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinition("minimal");
+
+
+ assertEquals(23, processDefinition.getVersion());
+ assertEquals("minimal:23", processDefinition.getId());
+ }
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/StateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/StateTest.java 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/basicfeatures/StateTest.java 2008-11-26 18:01:57 UTC (rev 3106)
@@ -22,6 +22,7 @@
package org.jbpm.test.basicfeatures;
import org.jbpm.Execution;
+import org.jbpm.JbpmException;
import org.jbpm.test.DbTestCase;
/**
@@ -57,14 +58,16 @@
assertTrue(execution.isEnded());
}
- /*
public void testExternalDecision() {
- ClientProcessDefinition processDefinition = parseJpdl(
- "<process initial='a' name='p'>" +
- " <state name='a'>" +
- " <transition name='left' to='b' />" +
- " <transition name='middle' to='c' />" +
- " <transition name='right' to='d' />" +
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='ed' />" +
+ " </start>" +
+ " <state name='ed'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
" </state>" +
" <state name='b' />" +
" <state name='c' />" +
@@ -72,26 +75,30 @@
"</process>"
);
- ClientExecution execution = processDefinition.startProcessInstance();
- execution.signal("left");
- assertEquals("b", execution.getNode().getName());
-
- execution = processDefinition.startProcessInstance();
- execution.signal("middle");
- assertEquals("c", execution.getNode().getName());
+ Execution execution = executionService.startExecution("p:1", "one");
+ assertEquals("ed", execution.getNodeName());
+ execution = executionService.signalExecution("p:1/one", "left");
+ assertEquals("b", execution.getNodeName());
- execution = processDefinition.startProcessInstance();
- execution.signal("right");
- assertEquals("d", execution.getNode().getName());
+ executionService.startExecution("p:1", "two");
+ execution = executionService.signalExecution("p:1/two", "middle");
+ assertEquals("c", execution.getNodeName());
+
+ executionService.startExecution("p:1", "three");
+ execution = executionService.signalExecution("p:1/three", "right");
+ assertEquals("d", execution.getNodeName());
}
public void testDefaultSignalWithNamedTransitions() {
- ClientProcessDefinition processDefinition = parseJpdl(
- "<process initial='a' name='p'>" +
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
" <state name='a'>" +
- " <transition name='left' to='b' />" +
- " <transition name='middle' to='c' />" +
- " <transition name='right' to='d' />" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
" </state>" +
" <state name='b' />" +
" <state name='c' />" +
@@ -99,14 +106,15 @@
"</process>"
);
- ClientExecution execution = processDefinition.startProcessInstance();
+ executionService.startExecution("p:1", "one");
try {
- execution.signal();
- } catch (PvmException e) {
+ executionService.signalExecution("p:1/one", "left");
+ } catch (JbpmException e) {
assertTextPresent("no matching transition or event for default signal in state(a)", e.getMessage());
}
}
+ /*
public void testNamedSignalWithoutMatchingTransition() {
ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-11-26 17:08:16 UTC (rev 3105)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-11-26 18:01:57 UTC (rev 3106)
@@ -9,6 +9,7 @@
<parse-jpdl />
<check-version />
<create-id />
+ <check-problems />
<save-process />
</language>
</deployer-manager>
More information about the jbpm-commits
mailing list