[jbpm-commits] JBoss JBPM SVN: r3275 - in jbpm4/trunk/modules: jpdl/src/main/resources and 11 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Dec 8 17:35:29 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-08 17:35:29 -0500 (Mon, 08 Dec 2008)
New Revision: 3275
Added:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/Activities.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivitiesParser.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartNodes.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java
Removed:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivityParser.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartEvents.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamSource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamSource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamSource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamSource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamSource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamSource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamSource.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/WireParserTest.java
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/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/resources/jbpm.jpdl.activities.xml
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/cfg/JbpmConfiguration.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/svc/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.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/PropertiesBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/VariableTypesBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.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/Parse.java
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/ProblemImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java
Log:
xml validation
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/Activities.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/Activities.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/Activities.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,38 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.xml.Bindings;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Activities {
+
+ List<String> schemaResources = new ArrayList<String>();
+ Bindings bindings = new Bindings();
+
+}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivitiesParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivitiesParser.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivitiesParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,74 @@
+/*
+ * 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.xml;
+
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Binding;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivitiesParser extends Parser {
+
+ private static final Log log = Log.getLog(ActivitiesParser.class.getName());
+
+ public Object parseDocumentElement(Element documentElement, Parse parse) {
+ Activities activities = parse.findObject(Activities.class);
+ if (activities==null) {
+ activities = new Activities();
+ }
+ parse.setDocumentObject(activities);
+
+ for (Element bindingElement : XmlUtil.elements(documentElement, "activity")) {
+ Binding binding = instantiateBinding(bindingElement, parse);
+ activities.bindings.addBinding(binding);
+ }
+
+ for (Element schemaElement : XmlUtil.elements(documentElement, "schema")) {
+ String schemaResource = XmlUtil.attribute(schemaElement, "resource", true, parse);
+ activities.schemaResources.add(schemaResource);
+ }
+
+ return activities;
+ }
+
+ protected Binding instantiateBinding(Element bindingElement, Parse parse) {
+ String bindingClassName = XmlUtil.attribute(bindingElement, "binding", true, parse);
+
+ log.trace("adding activity binding "+bindingClassName);
+
+ if (bindingClassName!=null) {
+ try {
+ Class<?> bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
+ return (Binding) bindingClass.newInstance();
+ } catch (Exception e) {
+ parse.addProblem("couldn't instantiate activity binding "+bindingClassName, e);
+ }
+ }
+ return null;
+ }
+}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivityParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivityParser.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ActivityParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,69 +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.xml;
-
-import java.util.List;
-
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.xml.Binding;
-import org.jbpm.pvm.internal.xml.Bindings;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-/**
- * @author Tom Baeyens
- */
-public class ActivityParser extends Parser {
-
- private static final Log log = Log.getLog(ActivityParser.class.getName());
-
- public Object parseDocumentElement(Element documentElement, Parse parse) {
- List<Element> elements = XmlUtil.elements(documentElement, "activity");
- if (elements!=null) {
- for (Element bindingElement : elements) {
- String bindingClassName = XmlUtil.attribute(bindingElement, "binding", true, parse);
-
- log.trace("adding activity binding "+bindingClassName);
-
- Binding binding = null;
- if (bindingClassName!=null) {
- try {
- Class<?> bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
- binding = (Binding) bindingClass.newInstance();
- } catch (Exception e) {
- parse.addProblem("couldn't instantiate activity binding "+bindingClassName, e);
- }
- }
-
- if (binding!=null) {
- Bindings bindings = parse.findObject(Bindings.class);
- bindings.addBinding(binding);
- }
- }
- }
-
- return null;
- }
-}
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-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/ExclusiveBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -74,36 +74,34 @@
boolean hasConditions = false;
List<Element> transitionElements = XmlUtil.elements(element, "transition");
- if (transitionElements!=null) {
- NodeImpl node = parse.findObject(NodeImpl.class);
- List<TransitionImpl> transitions = (List) node.getOutgoingTransitions();
-
- for (int i=0; i<transitionElements.size(); i++) {
- TransitionImpl transition = transitions.get(i);
- Element transitionElement = transitionElements.get(i);
+ NodeImpl node = parse.findObject(NodeImpl.class);
+ List<TransitionImpl> transitions = (List) node.getOutgoingTransitions();
+
+ for (int i=0; i<transitionElements.size(); i++) {
+ TransitionImpl transition = transitions.get(i);
+ Element transitionElement = transitionElements.get(i);
- Element conditionElement = XmlUtil.element(transitionElement, "condition");
- if (conditionElement!=null) {
- hasConditions = true;
- }
+ Element conditionElement = XmlUtil.element(transitionElement, "condition");
+ if (conditionElement!=null) {
+ hasConditions = true;
+ }
+
+ if (conditionElement.hasAttribute("expr")) {
+ String expr = conditionElement.getAttribute("expr");
+ ExpressionDescriptor expressionDescriptor = new ExpressionDescriptor(expr);
+ transition.setConditionDescriptor(expressionDescriptor);
- if (conditionElement.hasAttribute("expr")) {
- String expr = conditionElement.getAttribute("expr");
- ExpressionDescriptor expressionDescriptor = new ExpressionDescriptor(expr);
- transition.setConditionDescriptor(expressionDescriptor);
-
- } else if (conditionElement.hasAttribute("ref")) {
- String expr = conditionElement.getAttribute("ref");
- ReferenceDescriptor refDescriptor = new ReferenceDescriptor(expr);
- transition.setConditionDescriptor(refDescriptor);
-
- } else if (ObjectBinding.isObjectDescriptor(conditionElement)) {
- ObjectDescriptor conditionDescriptor = (ObjectDescriptor) objectBinding.parse(conditionElement, parse, parser);
- transition.setConditionDescriptor(conditionDescriptor);
+ } else if (conditionElement.hasAttribute("ref")) {
+ String expr = conditionElement.getAttribute("ref");
+ ReferenceDescriptor refDescriptor = new ReferenceDescriptor(expr);
+ transition.setConditionDescriptor(refDescriptor);
+
+ } else if (ObjectBinding.isObjectDescriptor(conditionElement)) {
+ ObjectDescriptor conditionDescriptor = (ObjectDescriptor) objectBinding.parse(conditionElement, parse, parser);
+ transition.setConditionDescriptor(conditionDescriptor);
- } else {
- parse.addProblem("decision must have one of {expr attribute, handler-ref attribute, handler element or transition conditions}: "+XmlUtil.toString(element));
- }
+ } else {
+ parse.addProblem("decision must have one of {expr attribute, handler-ref attribute, handler element or transition conditions}: "+XmlUtil.toString(element));
}
}
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-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlActivityBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -38,7 +38,7 @@
public abstract class JpdlActivityBinding extends TagBinding {
public JpdlActivityBinding(String tagName) {
- super(tagName, "http://jbpm.org/jpdl4", "activity");
+ super(tagName, "http://jbpm.org/4/jpdl", "activity");
}
public void parseName(Element element, NodeImpl node, Parse parse) {
@@ -61,13 +61,11 @@
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);
- }
+ 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-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -33,9 +33,7 @@
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.pvm.internal.util.UrlEntity;
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.w3c.dom.Element;
@@ -52,24 +50,46 @@
"jbpm.user.activities.xml"
};
-
- private static Bindings defaultBindings; // initialized at the bottom of this file
-
+ static ActivitiesParser activityParser = new ActivitiesParser();
+
public JpdlParser() {
- super(defaultBindings);
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- this.addEntity("http://jbpm.org/jpdl4", new UrlEntity("jpdl.xsd", classLoader));
+ Activities activitiesConfiguration = parseActivitiesConfiguration();
+ setBindings(activitiesConfiguration.bindings);
+ // setSchemaResources(activitiesConfiguration.schemaResources);
}
-
+ protected Activities parseActivitiesConfiguration() {
+ Activities activities = new Activities();
+
+ for (String activityResource: DEFAULT_ACTIVITIES_RESOURCES) {
+ Enumeration<URL> resourceUrls = ReflectUtil.getResources(null, activityResource);
+ if (resourceUrls.hasMoreElements()) {
+ while (resourceUrls.hasMoreElements()) {
+ URL resourceUrl = resourceUrls.nextElement();
+ log.trace("loading jpdl activities from resource: "+resourceUrl);
+ activityParser.createParse()
+ .setUrl(resourceUrl)
+ .pushObject(activities)
+ .execute()
+ .checkProblems("jpdl activities from "+resourceUrl.toString());
+ }
+ } else {
+ log.trace("skipping unavailable jpdl activities resource: "+activityResource);
+ }
+ }
+
+ return activities;
+ }
+
+
public Object parseDocumentElement(Element documentElement, Parse parse) {
ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) parse.getDocumentObject();
if (processDefinition==null) {
processDefinition = new JpdlProcessDefinition();
}
- StartEvents startEvents = new StartEvents();
- parse.pushObject(startEvents);
+ StartNodes startNodes = new StartNodes();
+ parse.pushObject(startNodes);
try {
String name = XmlUtil.attribute(documentElement, "name", true, parse);
processDefinition.setName(name);
@@ -97,21 +117,21 @@
parse.pushObject(unresolvedTransitions);
List<Element> elements = XmlUtil.elements(documentElement);
- if (elements!=null) {
- for (Element element: elements) {
- JpdlActivityBinding activityBinding = (JpdlActivityBinding) getBinding(element, "activity");
- if (activityBinding!=null) {
- NodeImpl node = (NodeImpl) processDefinition.createNode();
- 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 {
- parse.popObject();
- }
+ for (Element element: elements) {
+ JpdlActivityBinding activityBinding = (JpdlActivityBinding) getBinding(element, "activity");
+ if (activityBinding!=null) {
+ NodeImpl node = (NodeImpl) processDefinition.createNode();
+ 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 {
+ parse.popObject();
}
+ } else {
+ log.debug("unrecognized activity: "+XmlUtil.getTagLocalName(element));
}
}
@@ -135,13 +155,13 @@
}
- if (startEvents.size()==0) {
+ if (startNodes.size()==0) {
parse.addProblem("no start event in process");
- } else if (startEvents.size()>1) {
+ } else if (startNodes.size()>1) {
parse.addProblem("multiple start events not yet supported");
// TODO verify that all start events have conditions
} else {
- NodeImpl uniqueStartEvent = startEvents.get(0);
+ NodeImpl uniqueStartEvent = startNodes.get(0);
processDefinition.setInitial(uniqueStartEvent);
}
@@ -174,29 +194,4 @@
}
}
}
-
- static {
- // default descriptor parsers ///////////////////////////////////////////////
- defaultBindings = new Bindings();
-
- ActivityParser activityParser = new ActivityParser();
-
- for (String activityResource: DEFAULT_ACTIVITIES_RESOURCES) {
- Enumeration<URL> resourceUrls = ReflectUtil.getResources(null, activityResource);
- if (resourceUrls.hasMoreElements()) {
- while (resourceUrls.hasMoreElements()) {
- URL resourceUrl = resourceUrls.nextElement();
- log.trace("loading jpdl activities from resource: "+resourceUrl);
- activityParser.createParse()
- .setUrl(resourceUrl)
- .pushObject(defaultBindings)
- .execute()
- .checkProblems("jpdl activities from "+resourceUrl.toString());
- }
- } else {
- log.trace("skipping unavailable jpdl activities resource: "+activityResource);
- }
-
- }
- }
}
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-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -38,9 +38,9 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- NodeImpl startEventNode = parse.findObject(NodeImpl.class);
- StartEvents startEvents = parse.findObject(StartEvents.class);
- startEvents.add(startEventNode);
+ NodeImpl startNode = parse.findObject(NodeImpl.class);
+ StartNodes startNodes = parse.findObject(StartNodes.class);
+ startNodes.add(startNode);
return new StartActivity();
}
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartEvents.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartEvents.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartEvents.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,50 +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.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.pvm.internal.model.NodeImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class StartEvents {
-
- List<NodeImpl> startEvents = new ArrayList<NodeImpl>();
-
-
- public void add(NodeImpl startEventNode) {
- startEvents.add(startEventNode);
- }
-
- public int size() {
- return startEvents.size();
- }
-
- public NodeImpl get(int i) {
- return startEvents.get(i);
- }
-
-}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartNodes.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartNodes.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/StartNodes.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,50 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.NodeImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartNodes {
+
+ List<NodeImpl> startEvents = new ArrayList<NodeImpl>();
+
+
+ public void add(NodeImpl startEventNode) {
+ startEvents.add(startEventNode);
+ }
+
+ public int size() {
+ return startEvents.size();
+ }
+
+ public NodeImpl get(int i) {
+ return startEvents.get(i);
+ }
+
+}
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,6 +1,7 @@
<activities>
+ <schema resource="jpdl.xsd" />
<activity binding="org.jbpm.jpdl.xml.StartBinding" />
<activity binding="org.jbpm.jpdl.xml.StateBinding" />
<activity binding="org.jbpm.jpdl.xml.ExclusiveBinding" />
<activity binding="org.jbpm.jpdl.xml.EndBinding" />
-</activities>
\ No newline at end of file
+</activities>
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -31,7 +31,7 @@
* @author Tom Baeyens
*/
public class JpdlXmlTest extends JbpmTestCase {
-
+
public void testValidXml() {
List<Problem> problems = new JpdlParser()
.createParse()
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/cfg/JbpmConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/cfg/JbpmConfiguration.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/cfg/JbpmConfiguration.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -39,12 +39,12 @@
import org.jbpm.log.Log;
import org.jbpm.pvm.internal.env.PvmEnvironment;
import org.jbpm.pvm.internal.env.PvmEnvironmentFactoryParser;
-import org.jbpm.pvm.internal.stream.FileStreamSource;
-import org.jbpm.pvm.internal.stream.InputStreamSource;
-import org.jbpm.pvm.internal.stream.ResourceStreamSource;
-import org.jbpm.pvm.internal.stream.StreamSource;
-import org.jbpm.pvm.internal.stream.StringStreamSource;
-import org.jbpm.pvm.internal.stream.UrlStreamSource;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
@@ -100,31 +100,31 @@
}
public Configuration setInputStream(InputStream inputStream) {
- parse(new InputStreamSource(inputStream));
+ parse(new InputStreamInput(inputStream));
return this;
}
public Configuration setResource(String resource) {
- parse(new ResourceStreamSource(resource, getClassLoader()));
+ parse(new ResourceStreamInput(resource, getClassLoader()));
return this;
}
public Configuration setUrl(URL url) {
- parse(new UrlStreamSource(url));
+ parse(new UrlStreamInput(url));
return this;
}
public Configuration setFile(File file) {
- parse(new FileStreamSource(file));
+ parse(new FileStreamInput(file));
return this;
}
public Configuration setXmlString(String xmlString) {
- parse(new StringStreamSource(xmlString));
+ parse(new StringStreamInput(xmlString));
return this;
}
- protected void parse(StreamSource streamSource) {
+ protected void parse(StreamInput streamSource) {
isConfigured = true;
PvmEnvironmentFactoryParser.getInstance()
.createParse()
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-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -24,7 +24,7 @@
import org.jbpm.cfg.JbpmConfiguration;
import org.jbpm.env.Context;
import org.jbpm.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.stream.StreamSource;
+import org.jbpm.pvm.internal.stream.StreamInput;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
@@ -56,7 +56,7 @@
}
/** parses the given stream source with {@link #getInstance() the current parser}. */
- static EnvironmentFactory parse(StreamSource streamSource) {
+ static EnvironmentFactory parse(StreamInput streamSource) {
EnvironmentFactory environmentFactory = (EnvironmentFactory) getInstance()
.createParse()
.setStreamSource(streamSource)
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,49 @@
+/*
+ * 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.stream;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ByteArrayStreamInput extends StreamInput {
+
+ protected byte[] bytes;
+
+ /** @throws JbpmException if bytes is null */
+ public ByteArrayStreamInput(byte[] bytes) {
+ if (bytes==null) {
+ throw new JbpmException("bytes is null");
+ }
+ this.name = "byte-array";
+ this.bytes = bytes;
+ }
+
+ public InputStream openStream() {
+ return new ByteArrayInputStream(bytes);
+ }
+
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,49 +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.stream;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.jbpm.JbpmException;
-
-/**
- * @author Tom Baeyens
- */
-public class ByteArrayStreamSource extends StreamSource {
-
- protected byte[] bytes;
-
- /** @throws JbpmException if bytes is null */
- public ByteArrayStreamSource(byte[] bytes) {
- if (bytes==null) {
- throw new JbpmException("bytes is null");
- }
- this.name = "byte-array";
- this.bytes = bytes;
- }
-
- public InputStream openStream() {
- return new ByteArrayInputStream(bytes);
- }
-
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,72 @@
+/*
+ * 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.stream;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FileStreamInput extends StreamInput {
+
+ protected File file;
+
+ /** @throws JbpmException if file is null */
+ public FileStreamInput(File file) {
+ if (file==null) {
+ throw new JbpmException("file is null");
+ }
+
+ try {
+ this.name = file.toURL().toString();
+ } catch (MalformedURLException e) {
+ this.name = file.toString();
+ }
+
+ this.file = file;
+ }
+
+ public InputStream openStream() {
+ InputStream stream = null;
+
+ try {
+ if (!file.exists()) {
+ throw new JbpmException("file "+file+" doesn't exist");
+ }
+ if (file.isDirectory()) {
+ throw new JbpmException("file "+file+" is a directory");
+ }
+ stream = new FileInputStream(file);
+
+ } catch (Exception e) {
+ throw new JbpmException("couldn't access file "+file+": "+e.getMessage(), e);
+ }
+
+ return stream;
+ }
+
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,72 +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.stream;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-
-import org.jbpm.JbpmException;
-
-/**
- * @author Tom Baeyens
- */
-public class FileStreamSource extends StreamSource {
-
- protected File file;
-
- /** @throws JbpmException if file is null */
- public FileStreamSource(File file) {
- if (file==null) {
- throw new JbpmException("file is null");
- }
-
- try {
- this.name = file.toURL().toString();
- } catch (MalformedURLException e) {
- this.name = file.toString();
- }
-
- this.file = file;
- }
-
- public InputStream openStream() {
- InputStream stream = null;
-
- try {
- if (!file.exists()) {
- throw new JbpmException("file "+file+" doesn't exist");
- }
- if (file.isDirectory()) {
- throw new JbpmException("file "+file+" is a directory");
- }
- stream = new FileInputStream(file);
-
- } catch (Exception e) {
- throw new JbpmException("couldn't access file "+file+": "+e.getMessage(), e);
- }
-
- return stream;
- }
-
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,46 @@
+/*
+ * 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.stream;
+
+import java.io.InputStream;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class InputStreamInput extends StreamInput {
+
+ protected InputStream inputStream;
+
+ public InputStreamInput(InputStream inputStream) {
+ if (inputStream==null) {
+ throw new JbpmException("inputStream is null");
+ }
+ this.name = "input-stream";
+ this.inputStream = inputStream;
+ }
+
+ public InputStream openStream() {
+ return inputStream;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,46 +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.stream;
-
-import java.io.InputStream;
-
-import org.jbpm.JbpmException;
-
-/**
- * @author Tom Baeyens
- */
-public class InputStreamSource extends StreamSource {
-
- protected InputStream inputStream;
-
- public InputStreamSource(InputStream inputStream) {
- if (inputStream==null) {
- throw new JbpmException("inputStream is null");
- }
- this.name = "input-stream";
- this.inputStream = inputStream;
- }
-
- public InputStream openStream() {
- return inputStream;
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,59 @@
+/*
+ * 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.stream;
+
+import java.io.InputStream;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ResourceStreamInput extends StreamInput {
+
+ protected ClassLoader classLoader;
+ protected String resource;
+
+ /** @throws JbpmException if resource is null */
+ public ResourceStreamInput(String resource) {
+ this(resource, null);
+ }
+
+ /** @throws JbpmException if resource is null */
+ public ResourceStreamInput(String resource, ClassLoader classLoader) {
+ if (resource==null) {
+ throw new JbpmException("resource is null");
+ }
+ this.name = "resource://"+resource;
+ this.resource = resource;
+ this.classLoader = classLoader;
+ }
+
+ public InputStream openStream() {
+ InputStream stream = ReflectUtil.getResourceAsStream(classLoader, resource);
+ if (stream==null) {
+ throw new JbpmException("resource "+resource+" does not exist");
+ }
+ return stream;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,59 +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.stream;
-
-import java.io.InputStream;
-
-import org.jbpm.JbpmException;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-
-/**
- * @author Tom Baeyens
- */
-public class ResourceStreamSource extends StreamSource {
-
- protected ClassLoader classLoader;
- protected String resource;
-
- /** @throws JbpmException if resource is null */
- public ResourceStreamSource(String resource) {
- this(resource, null);
- }
-
- /** @throws JbpmException if resource is null */
- public ResourceStreamSource(String resource, ClassLoader classLoader) {
- if (resource==null) {
- throw new JbpmException("resource is null");
- }
- this.name = "resource://"+resource;
- this.resource = resource;
- this.classLoader = classLoader;
- }
-
- public InputStream openStream() {
- InputStream stream = ReflectUtil.getResourceAsStream(classLoader, resource);
- if (stream==null) {
- throw new JbpmException("resource "+resource+" does not exist");
- }
- return stream;
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,46 @@
+/*
+ * 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.stream;
+
+import java.io.InputStream;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class StreamInput {
+
+ protected String name;
+
+ public abstract InputStream openStream();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,46 +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.stream;
-
-import java.io.InputStream;
-
-/**
- * @author Tom Baeyens
- */
-public abstract class StreamSource {
-
- protected String name;
-
- public abstract InputStream openStream();
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,44 @@
+/*
+ * 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.stream;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StringStreamInput extends StreamInput {
+
+ String string;
+
+ public StringStreamInput(String string) {
+ this.name = "string";
+ this.string = string;
+ }
+
+ public InputStream openStream() {
+ byte[] bytes = string.getBytes();
+ return new ByteArrayInputStream(bytes);
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,44 +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.stream;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-
-/**
- * @author Tom Baeyens
- */
-public class StringStreamSource extends StreamSource {
-
- String string;
-
- public StringStreamSource(String string) {
- this.name = "string";
- this.string = string;
- }
-
- public InputStream openStream() {
- byte[] bytes = string.getBytes();
- return new ByteArrayInputStream(bytes);
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -0,0 +1,55 @@
+/*
+ * 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.stream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class UrlStreamInput extends StreamInput {
+
+ protected URL url;
+
+ /** @throws JbpmException if url is null */
+ public UrlStreamInput(URL url) {
+ if (url==null) {
+ throw new JbpmException("url is null");
+ }
+ this.name = url.toString();
+ this.url = url;
+ }
+
+ public InputStream openStream() {
+ InputStream stream = null;
+ try {
+ stream = url.openStream();
+ } catch (IOException e) {
+ throw new JbpmException("couldn't open URL stream", e);
+ }
+ return stream;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamSource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamSource.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamSource.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,55 +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.stream;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.jbpm.JbpmException;
-
-/**
- * @author Tom Baeyens
- */
-public class UrlStreamSource extends StreamSource {
-
- protected URL url;
-
- /** @throws JbpmException if url is null */
- public UrlStreamSource(URL url) {
- if (url==null) {
- throw new JbpmException("url is null");
- }
- this.name = url.toString();
- this.url = url;
- }
-
- public InputStream openStream() {
- InputStream stream = null;
- try {
- stream = url.openStream();
- } catch (IOException e) {
- throw new JbpmException("couldn't open URL stream", e);
- }
- return stream;
- }
-}
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-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -39,13 +39,13 @@
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;
-import org.jbpm.pvm.internal.stream.ResourceStreamSource;
-import org.jbpm.pvm.internal.stream.StreamSource;
-import org.jbpm.pvm.internal.stream.StringStreamSource;
-import org.jbpm.pvm.internal.stream.UrlStreamSource;
+import org.jbpm.pvm.internal.stream.ByteArrayStreamInput;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
import org.jbpm.pvm.internal.util.IoUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -74,7 +74,7 @@
protected String name;
/** maps file names to stream source */
- protected Map<String, StreamSource> files;
+ protected Map<String, StreamInput> files;
/** maps file names to dom so that duplicate xml parsing can be avoided. */
protected Map<String, Document> fileDocuments;
/** maps file names to file types */
@@ -114,44 +114,44 @@
public Deployment addResource(String resource) {
- addStreamSource(resource, new ResourceStreamSource(resource));
+ addStreamSource(resource, new ResourceStreamInput(resource));
return this;
}
public Deployment addFile(File file) {
- addStreamSource(file.getAbsolutePath(), new FileStreamSource(file));
+ addStreamSource(file.getAbsolutePath(), new FileStreamInput(file));
return this;
}
public Deployment addUrl(URL url) {
- addStreamSource(url.toString(), new UrlStreamSource(url));
+ addStreamSource(url.toString(), new UrlStreamInput(url));
return this;
}
public Deployment addInputStream(String name, InputStream inputStream) {
- addStreamSource(name, new InputStreamSource(inputStream));
+ addStreamSource(name, new InputStreamInput(inputStream));
return this;
}
public Deployment addString(String name, String string) {
- addStreamSource(name, new StringStreamSource(string));
+ addStreamSource(name, new StringStreamInput(string));
return this;
}
public Deployment addArchiveResource(String resource) {
this.name = resource;
- ResourceStreamSource streamSource = new ResourceStreamSource(resource);
+ ResourceStreamInput streamSource = new ResourceStreamInput(resource);
addStreamSource(resource, streamSource);
return this;
}
public Deployment addArchiveFile(File file) {
- addStreamSource(file.getAbsolutePath(), new FileStreamSource(file));
+ addStreamSource(file.getAbsolutePath(), new FileStreamInput(file));
return this;
}
public Deployment addArchiveUrl(URL url) {
- addStreamSource(url.toString(), new UrlStreamSource(url));
+ addStreamSource(url.toString(), new UrlStreamInput(url));
return this;
}
@@ -162,7 +162,7 @@
String entryName = zipEntry.getName();
byte[] bytes = IoUtil.readBytes(zipInputStream);
if (bytes!=null) {
- addStreamSource(entryName, new ByteArrayStreamSource(bytes));
+ addStreamSource(entryName, new ByteArrayStreamInput(bytes));
}
zipEntry = zipInputStream.getNextEntry();
}
@@ -217,12 +217,12 @@
if (file.isFile()) {
if (canonicalPathNames) {
try {
- addStreamSource(file.getCanonicalPath(), new FileStreamSource(file));
+ addStreamSource(file.getCanonicalPath(), new FileStreamInput(file));
} catch (IOException e) {
throw new JbpmException("can't get canonical path name for "+file);
}
} else {
- addStreamSource(relativeFileName, new FileStreamSource(file));
+ addStreamSource(relativeFileName, new FileStreamInput(file));
}
} else if (file.isDirectory()) {
addDirectory(file, relativeFileName, canonicalPathNames);
@@ -232,12 +232,12 @@
return this;
}
- protected Deployment addStreamSource(String name, StreamSource streamSource) {
+ protected Deployment addStreamSource(String name, StreamInput streamSource) {
if (this.name==null) {
this.name = name;
}
if (files==null) {
- files = new HashMap<String, StreamSource>();
+ files = new HashMap<String, StreamInput>();
}
files.put(name, streamSource);
return this;
@@ -247,7 +247,7 @@
if (files==null) {
return null;
}
- StreamSource streamSource = files.get(name);
+ StreamInput streamSource = files.get(name);
return (streamSource!=null ? streamSource.openStream() : null);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -24,6 +24,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
@@ -57,20 +58,26 @@
private static Log log = Log.getLog(XmlUtil.class.getName());
public static List<Element> elements(Element element, String tagName) {
- List<Element> elements = null;
+ if (element==null) {
+ return Collections.EMPTY_LIST;
+ }
NodeList nodeList = element.getChildNodes();
- if (nodeList != null) {
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
- if (Element.class.isAssignableFrom(child.getClass())) {
- Element childElement = (Element) child;
- String childTagName = getTagLocalName(childElement);
- if (childTagName.equals(tagName)) {
- if (elements == null) {
- elements = new ArrayList<Element>();
- }
- elements.add(childElement);
+ if ( (nodeList == null)
+ || (nodeList.getLength()==0)
+ ) {
+ return Collections.EMPTY_LIST;
+ }
+ List<Element> elements = new ArrayList<Element>();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node child = nodeList.item(i);
+ if (Element.class.isAssignableFrom(child.getClass())) {
+ Element childElement = (Element) child;
+ String childTagName = getTagLocalName(childElement);
+ if (childTagName.equals(tagName)) {
+ if (elements == null) {
+ elements = new ArrayList<Element>();
}
+ elements.add(childElement);
}
}
}
@@ -78,20 +85,26 @@
}
public static List<Element> elements(Element element, Set<String> allowedTagNames) {
- List<Element> elements = null;
+ if (element==null) {
+ return Collections.EMPTY_LIST;
+ }
NodeList nodeList = element.getChildNodes();
- if (nodeList != null) {
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
- if (Element.class.isAssignableFrom(child.getClass())) {
- Element childElement = (Element) child;
- String childTagName = getTagLocalName(childElement);
- if (allowedTagNames.contains(childTagName)) {
- if (elements == null) {
- elements = new ArrayList<Element>();
- }
- elements.add(childElement);
+ if ( (nodeList == null)
+ || (nodeList.getLength()==0)
+ ) {
+ return Collections.EMPTY_LIST;
+ }
+ List<Element> elements = new ArrayList<Element>();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node child = nodeList.item(i);
+ if (Element.class.isAssignableFrom(child.getClass())) {
+ Element childElement = (Element) child;
+ String childTagName = getTagLocalName(childElement);
+ if (allowedTagNames.contains(childTagName)) {
+ if (elements == null) {
+ elements = new ArrayList<Element>();
}
+ elements.add(childElement);
}
}
}
@@ -99,49 +112,74 @@
}
public static Element element(Element element, String tagName) {
- Element childElement = null;
+ if (element==null) {
+ return null;
+ }
NodeList nodeList = element.getChildNodes();
- for (int i = 0; ((i < nodeList.getLength()) && (childElement == null)); i++) {
+ for (int i = 0; (i < nodeList.getLength()); i++) {
Node child = nodeList.item(i);
if ((Element.class.isAssignableFrom(child.getClass())) && (getTagLocalName((Element) child)).equals(tagName)) {
- childElement = (Element) child;
+ return (Element) child;
}
}
- return childElement;
+ return null;
}
public static List<Element> elements(Element element) {
- List<Element> elements = null;
- if (element!=null) {
- NodeList nodeList = element.getChildNodes();
- if ((nodeList != null) && (nodeList.getLength() > 0)) {
- elements = new ArrayList<Element>();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Element) {
- elements.add((Element) node);
- }
+ if (element==null) {
+ return Collections.EMPTY_LIST;
+ }
+ NodeList nodeList = element.getChildNodes();
+ if ( (nodeList == null)
+ || (nodeList.getLength()==0)
+ ) {
+ return Collections.EMPTY_LIST;
+ }
+ List<Element> elements = new ArrayList<Element>();
+ if ((nodeList != null) && (nodeList.getLength() > 0)) {
+ elements = new ArrayList<Element>();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if (node instanceof Element) {
+ elements.add((Element) node);
}
}
}
return elements;
}
- public static List<Element> elements(Element father, String ns, String localName) {
- List<Element> matchingElements = new ArrayList<Element>();
- NodeList nl = father.getChildNodes();
- for (int i=0;i<nl.getLength();i++) {
- Node n = nl.item(i);
- if (n instanceof Element && n.getLocalName() != null && n.getLocalName().equals(localName) && n.getNamespaceURI() != null && n.getNamespaceURI().equals(ns)) {
- matchingElements.add((Element)n);
- }
+ public static List<Element> elements(Element element, String ns, String localName) {
+ if (element==null) {
+ return Collections.EMPTY_LIST;
+ }
+ NodeList nodeList = element.getChildNodes();
+ if ( (nodeList == null)
+ || (nodeList.getLength()==0)
+ ) {
+ return Collections.EMPTY_LIST;
+ }
+ List<Element> matchingElements = new ArrayList<Element>();
+ NodeList nl = element.getChildNodes();
+ for (int i=0;i<nl.getLength();i++) {
+ Node n = nl.item(i);
+ if (n instanceof Element && n.getLocalName() != null && n.getLocalName().equals(localName) && n.getNamespaceURI() != null && n.getNamespaceURI().equals(ns)) {
+ matchingElements.add((Element)n);
}
- return matchingElements;
}
+ return matchingElements;
+ }
public static List<Element> elementsQName(Element element, Set<QName> allowedTagNames) {
- List<Element> elements = null;
+ if (element==null) {
+ return Collections.EMPTY_LIST;
+ }
NodeList nodeList = element.getChildNodes();
+ if ( (nodeList == null)
+ || (nodeList.getLength()==0)
+ ) {
+ return Collections.EMPTY_LIST;
+ }
+ List<Element> elements = new ArrayList<Element>();
if (nodeList != null) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node child = nodeList.item(i);
@@ -159,11 +197,12 @@
}
return elements;
}
+
public static Element element(Element element) {
Element onlyChild = null;
- List elements = elements(element);
- if (elements != null) {
- onlyChild = (Element) elements.get(0);
+ List<Element> elements = elements(element);
+ if (!elements.isEmpty()) {
+ onlyChild = elements.get(0);
}
return onlyChild;
}
@@ -220,7 +259,7 @@
public static List<Attr> attributes(Element element) {
NamedNodeMap attributeMap = element.getAttributes();
if ((attributeMap == null) || (attributeMap.getLength() == 0)) {
- return null;
+ return Collections.EMPTY_LIST;
}
List<Attr> attributes = new ArrayList<Attr>();
@@ -234,7 +273,7 @@
public static List<Node> contents(Element element) {
NodeList nodeList = element.getChildNodes();
if ((nodeList == null) && (nodeList.getLength() != 0)) {
- return null;
+ return Collections.EMPTY_LIST;
}
List<Node> contents = new ArrayList<Node>();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -36,12 +36,10 @@
List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
List<Element> elements = XmlUtil.elements(element);
- if (elements!=null) {
- for (Element valueElement: elements) {
- Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueElement, parse, WireParser.CATEGORY_DESCRIPTOR);
- if (valueDescriptor!=null) {
- valueDescriptors.add(valueDescriptor);
- }
+ for (Element valueElement: elements) {
+ Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+ if (valueDescriptor!=null) {
+ valueDescriptors.add(valueDescriptor);
}
}
descriptor.setValueDescriptors(valueDescriptors);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -46,7 +46,7 @@
AssignFileTypeDeployer assignFileTypeDeployer = new AssignFileTypeDeployer();
List<Element> fileElements = XmlUtil.elements(element, "file");
- if (fileElements==null) {
+ if (fileElements.isEmpty()) {
parse.addProblem("no files in "+ASSIGN_FILE_TYPE);
} else {
for(Element fileTypeElement : fileElements) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -87,7 +87,7 @@
Holiday[] holidays = null;
List<Element> holidayElements = XmlUtil.elements(element, "holiday");
- if (holidayElements!=null) {
+ if (!holidayElements.isEmpty()) {
holidays = new Holiday[holidayElements.size()];
for (int i=0; i<holidayElements.size(); i++) {
holidays[i] = parseHoliday(holidayElements.get(i), dayFormat, businessCalendar, parse);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -55,14 +55,12 @@
descriptor.setDeployerDescriptors(deployerDescriptors);
List<Element> deployerElements = XmlUtil.elements(element);
- if (deployerElements!=null) {
- for (Element deployerElement: deployerElements) {
- Descriptor deployerDescriptor = (Descriptor) parser
- .parseElement(deployerElement,
- parse,
- WireParser.CATEGORY_DESCRIPTOR);
- deployerDescriptors.add(deployerDescriptor);
- }
+ for (Element deployerElement: deployerElements) {
+ Descriptor deployerDescriptor = (Descriptor) parser
+ .parseElement(deployerElement,
+ parse,
+ WireParser.CATEGORY_DESCRIPTOR);
+ deployerDescriptors.add(deployerDescriptor);
}
if (deployerDescriptors.isEmpty()) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -29,10 +29,10 @@
import org.hibernate.cfg.Configuration;
import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.stream.FileStreamSource;
-import org.jbpm.pvm.internal.stream.ResourceStreamSource;
-import org.jbpm.pvm.internal.stream.StreamSource;
-import org.jbpm.pvm.internal.stream.UrlStreamSource;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.HibernateConfigurationDescriptor;
@@ -65,11 +65,9 @@
static class MappingParser extends Parser {
public Object parseDocumentElement(Element documentElement, Parse parse) {
List<Element> elements = XmlUtil.elements(documentElement, "mapping");
- if (elements!=null) {
- HibernateConfigurationDescriptor descriptor = parse.findObject(HibernateConfigurationDescriptor.class);
- for (Element element: elements) {
- parseMapping(element, descriptor, parse);
- }
+ HibernateConfigurationDescriptor descriptor = parse.findObject(HibernateConfigurationDescriptor.class);
+ for (Element element: elements) {
+ parseMapping(element, descriptor, parse);
}
return null;
}
@@ -124,109 +122,107 @@
}
List<Element> configElements = XmlUtil.elements(element);
- if (configElements!=null) {
- for (Element configElement: configElements) {
+ for (Element configElement: configElements) {
+
+ if ("mappings".equals(XmlUtil.getTagLocalName(configElement))) {
+ if (configElement.hasAttribute("resource")) {
+ String resources = configElement.getAttribute("resource");
+ try {
+ Enumeration<URL> enumeration = ReflectUtil.getResources(parse.getClassLoader(), resources);
+ if (enumeration!=null) {
+ while (enumeration.hasMoreElements()) {
+ URL url = enumeration.nextElement();
+ log.trace("importing mappings from "+url);
+ InputStream inputStream = url.openStream();
+ mappingParser.createParse()
+ .pushObject(descriptor)
+ .setInputStream(inputStream)
+ .execute();
+ }
+ }
+ } catch (Exception e) {
+ parse.addProblem("couldn't parse hibernate mapping resources '"+resources+"'", e);
+ }
+ }
+
+ } else if ("mapping".equals(XmlUtil.getTagLocalName(configElement))) {
- if ("mappings".equals(XmlUtil.getTagLocalName(configElement))) {
+ parseMapping(configElement, descriptor, parse);
+
+ } else if ("properties".equals(XmlUtil.getTagLocalName(configElement))) {
+ PropertiesDescriptor propertiesDescriptor = (PropertiesDescriptor) propertiesBinding.parse(configElement, parse, parser);
+ descriptor.setPropertiesDescriptor(propertiesDescriptor);
+
+ } else if ("cache-configuration".equals(XmlUtil.getTagLocalName(configElement))) {
+ StreamInput streamSource = null;
+
+ String cacheUsage = configElement.getAttribute("usage");
+ if (! ( ("read-only".equals(cacheUsage))
+ || ("nonstrict-read-write".equals(cacheUsage))
+ || ("read-write".equals(cacheUsage))
+ || ("transactional".equals(cacheUsage))
+ )
+ ){
+ parse.addProblem("problem in cache-configuration: no usage attribute or illegal value: "+cacheUsage+" Possible values are {read-only, nonstrict-read-write, read-write, transactional}");
+ } else {
+
+ if (configElement.hasAttribute("file")) {
+ String fileName = configElement.getAttribute("file");
+ File file = new File(fileName);
+ if (file.exists() && file.isFile()) {
+ streamSource = new FileStreamInput(file);
+ } else {
+ parse.addProblem("file "+fileName+" isn't a file");
+ }
+ }
+
if (configElement.hasAttribute("resource")) {
- String resources = configElement.getAttribute("resource");
+ String resource = configElement.getAttribute("resource");
+ streamSource = new ResourceStreamInput(resource, parse.getClassLoader());
+ }
+
+ if (configElement.hasAttribute("url")) {
+ String urlText = configElement.getAttribute("url");
try {
- Enumeration<URL> enumeration = ReflectUtil.getResources(parse.getClassLoader(), resources);
- if (enumeration!=null) {
- while (enumeration.hasMoreElements()) {
- URL url = enumeration.nextElement();
- log.trace("importing mappings from "+url);
- InputStream inputStream = url.openStream();
- mappingParser.createParse()
- .pushObject(descriptor)
- .setInputStream(inputStream)
- .execute();
- }
- }
+ URL url = new URL(urlText);
+ streamSource = new UrlStreamInput(url);
} catch (Exception e) {
- parse.addProblem("couldn't parse hibernate mapping resources '"+resources+"'", e);
+ parse.addProblem("couldn't open url "+urlText, e);
}
}
-
- } else if ("mapping".equals(XmlUtil.getTagLocalName(configElement))) {
- parseMapping(configElement, descriptor, parse);
+ if (streamSource != null) {
+ parser.importStream(streamSource, configElement, parse);
+ }
- } else if ("properties".equals(XmlUtil.getTagLocalName(configElement))) {
- PropertiesDescriptor propertiesDescriptor = (PropertiesDescriptor) propertiesBinding.parse(configElement, parse, parser);
- descriptor.setPropertiesDescriptor(propertiesDescriptor);
-
- } else if ("cache-configuration".equals(XmlUtil.getTagLocalName(configElement))) {
- StreamSource streamSource = null;
-
- String cacheUsage = configElement.getAttribute("usage");
- if (! ( ("read-only".equals(cacheUsage))
- || ("nonstrict-read-write".equals(cacheUsage))
- || ("read-write".equals(cacheUsage))
- || ("transactional".equals(cacheUsage))
- )
- ){
- parse.addProblem("problem in cache-configuration: no usage attribute or illegal value: "+cacheUsage+" Possible values are {read-only, nonstrict-read-write, read-write, transactional}");
- } else {
-
- if (configElement.hasAttribute("file")) {
- String fileName = configElement.getAttribute("file");
- File file = new File(fileName);
- if (file.exists() && file.isFile()) {
- streamSource = new FileStreamSource(file);
- } else {
- parse.addProblem("file "+fileName+" isn't a file");
- }
- }
-
- if (configElement.hasAttribute("resource")) {
- String resource = configElement.getAttribute("resource");
- streamSource = new ResourceStreamSource(resource, parse.getClassLoader());
- }
-
- if (configElement.hasAttribute("url")) {
- String urlText = configElement.getAttribute("url");
- try {
- URL url = new URL(urlText);
- streamSource = new UrlStreamSource(url);
- } catch (Exception e) {
- parse.addProblem("couldn't open url "+urlText, e);
- }
- }
-
- if (streamSource != null) {
- parser.importStream(streamSource, configElement, parse);
- }
-
- // parse the cache configurations in the same way as the hibernate cfg schema
- // translate the contents of the file into invoke operations for methods
- // Configuration.setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region)
- // Configuration.setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
- // <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
- // <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
- // <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
- List<Element> cacheElements = XmlUtil.elements(configElement);
- if (cacheElements!=null) {
- for (Element cacheElement : cacheElements) {
-
- if ("class-cache".equals(XmlUtil.getTagLocalName(cacheElement))) {
- String className = cacheElement.getAttribute("class");
- descriptor.addCacheOperation(new HibernateConfigurationDescriptor.SetCacheConcurrencyStrategy(className, cacheUsage));
+ // parse the cache configurations in the same way as the hibernate cfg schema
+ // translate the contents of the file into invoke operations for methods
+ // Configuration.setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region)
+ // Configuration.setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
+ // <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
+ // <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
+ // <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
+ List<Element> cacheElements = XmlUtil.elements(configElement);
+ if (cacheElements!=null) {
+ for (Element cacheElement : cacheElements) {
+
+ if ("class-cache".equals(XmlUtil.getTagLocalName(cacheElement))) {
+ String className = cacheElement.getAttribute("class");
+ descriptor.addCacheOperation(new HibernateConfigurationDescriptor.SetCacheConcurrencyStrategy(className, cacheUsage));
- } else if ("collection-cache".equals(XmlUtil.getTagLocalName(cacheElement))) {
- String collection = cacheElement.getAttribute("collection");
- descriptor.addCacheOperation(new HibernateConfigurationDescriptor.SetCollectionCacheConcurrencyStrategy(collection, cacheUsage));
+ } else if ("collection-cache".equals(XmlUtil.getTagLocalName(cacheElement))) {
+ String collection = cacheElement.getAttribute("collection");
+ descriptor.addCacheOperation(new HibernateConfigurationDescriptor.SetCollectionCacheConcurrencyStrategy(collection, cacheUsage));
- } else {
- parse.addProblem("unknown hibernate cache configuration element "+XmlUtil.toString(configElement));
- }
+ } else {
+ parse.addProblem("unknown hibernate cache configuration element "+XmlUtil.toString(configElement));
}
}
}
-
- } else {
- parse.addProblem("unknown hibernate configuration element "+XmlUtil.toString(configElement));
}
+
+ } else {
+ parse.addProblem("unknown hibernate configuration element "+XmlUtil.toString(configElement));
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -48,7 +48,7 @@
// if hibernate session factory binding has sub elements, we assume that
// it is an inline configuration declaration
- } else if (XmlUtil.elements(element)!=null) {
+ } else if (!XmlUtil.elements(element).isEmpty()) {
Descriptor configurationDescriptor = (Descriptor) super.parse(element, parse, parser);
descriptor.setConfigurationDescriptor(configurationDescriptor);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -61,32 +61,30 @@
List<Descriptor> keyDescriptors = new ArrayList<Descriptor>();
List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
List<Element> elements = XmlUtil.elements(element);
- if (elements!=null) {
- for (Element entryElement: elements) {
- if ("entry".equals(XmlUtil.getTagLocalName(entryElement))) {
- // key
- Element keyElement = XmlUtil.element(entryElement, "key");
- Element keyDescriptorElement = (keyElement!=null ? XmlUtil.element(keyElement) : null);
- Descriptor keyDescriptor = (Descriptor) parser.parseElement(keyDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
- // value
- Element valueElement = XmlUtil.element(entryElement, "value");
- Element valueDescriptorElement = (valueElement!=null ? XmlUtil.element(valueElement) : null);
- Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+ for (Element entryElement: elements) {
+ if ("entry".equals(XmlUtil.getTagLocalName(entryElement))) {
+ // key
+ Element keyElement = XmlUtil.element(entryElement, "key");
+ Element keyDescriptorElement = (keyElement!=null ? XmlUtil.element(keyElement) : null);
+ Descriptor keyDescriptor = (Descriptor) parser.parseElement(keyDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+ // value
+ Element valueElement = XmlUtil.element(entryElement, "value");
+ Element valueDescriptorElement = (valueElement!=null ? XmlUtil.element(valueElement) : null);
+ Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
- if ( (keyDescriptor!=null)
- && (valueDescriptor!=null)
- ) {
- keyDescriptors.add(keyDescriptor);
- valueDescriptors.add(valueDescriptor);
- } else {
- parse.addProblem("entry must have key and value element with a single descriptor as contents: "+XmlUtil.toString(entryElement));
- }
+ if ( (keyDescriptor!=null)
+ && (valueDescriptor!=null)
+ ) {
+ keyDescriptors.add(keyDescriptor);
+ valueDescriptors.add(valueDescriptor);
} else {
- parse.addProblem("map can only contain entry elements: "+XmlUtil.toString(entryElement));
+ parse.addProblem("entry must have key and value element with a single descriptor as contents: "+XmlUtil.toString(entryElement));
}
-
+ } else {
+ parse.addProblem("map can only contain entry elements: "+XmlUtil.toString(entryElement));
}
}
+
descriptor.setKeyDescriptors(keyDescriptors);
descriptor.setValueDescriptors(valueDescriptors);
return descriptor;
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-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -122,22 +122,20 @@
// read the operations elements
List<Operation> operations = null;
List<Element> elements = XmlUtil.elements(element);
- if (elements!=null) {
- for (Element childElement: elements) {
- if(!childElement.getTagName().equals("constructor")
- && !childElement.getTagName().equals("factory")
- && !childElement.getTagName().equals("arg")){
- Operation operation = (Operation) parser.parseElement(childElement, parse, WireParser.CATEGORY_OPERATION);
- if (operation!=null) {
- if (operations==null) {
- operations = new ArrayList<Operation>();
- }
- operations.add(operation);
- }else{
- parse.addProblem("element 'object' can only have 'factory', 'arg', 'constructor' elements or an operation element ("+
- parser.getBindings().getTagNames(WireParser.CATEGORY_OPERATION) +")." +
- " Invalid element '"+childElement.getTagName()+"' in: "+XmlUtil.toString(element));
+ for (Element childElement: elements) {
+ if(!childElement.getTagName().equals("constructor")
+ && !childElement.getTagName().equals("factory")
+ && !childElement.getTagName().equals("arg")){
+ Operation operation = (Operation) parser.parseElement(childElement, parse, WireParser.CATEGORY_OPERATION);
+ if (operation!=null) {
+ if (operations==null) {
+ operations = new ArrayList<Operation>();
}
+ operations.add(operation);
+ }else{
+ parse.addProblem("element 'object' can only have 'factory', 'arg', 'constructor' elements or an operation element ("+
+ parser.getBindings().getTagNames(WireParser.CATEGORY_OPERATION) +")." +
+ " Invalid element '"+childElement.getTagName()+"' in: "+XmlUtil.toString(element));
}
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -68,28 +68,26 @@
List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
List<Element> elements = XmlUtil.elements(element);
- if (elements!=null) {
- for (Element propertyElement: elements) {
- if ("property".equals(XmlUtil.getTagLocalName(propertyElement))) {
- // key
- String name = XmlUtil.attribute(propertyElement, "name");
- // value
- String value = XmlUtil.attribute(propertyElement, "value");
+ for (Element propertyElement: elements) {
+ if ("property".equals(XmlUtil.getTagLocalName(propertyElement))) {
+ // key
+ String name = XmlUtil.attribute(propertyElement, "name");
+ // value
+ String value = XmlUtil.attribute(propertyElement, "value");
- if ( (name!=null)
- && (value!=null)
- ) {
- keyDescriptors.add(new StringDescriptor(name));
- valueDescriptors.add(new StringDescriptor(value));
- } else {
- parse.addProblem("property must have name and value attributes: "+XmlUtil.toString(propertyElement));
- }
+ if ( (name!=null)
+ && (value!=null)
+ ) {
+ keyDescriptors.add(new StringDescriptor(name));
+ valueDescriptors.add(new StringDescriptor(value));
} else {
- parse.addProblem("properties can only contain property elements: "+XmlUtil.toString(propertyElement));
+ parse.addProblem("property must have name and value attributes: "+XmlUtil.toString(propertyElement));
}
-
+ } else {
+ parse.addProblem("properties can only contain property elements: "+XmlUtil.toString(propertyElement));
}
}
+
descriptor.setKeyDescriptors(keyDescriptors);
descriptor.setValueDescriptors(valueDescriptors);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -56,11 +56,9 @@
commandServiceDescriptor.setCommandService(commandService);
List<Element> interceptorElements = XmlUtil.elements(element);
- if (interceptorElements!=null) {
- for (Element interceptorElement : interceptorElements) {
- Descriptor interceptorDescriptor = (Descriptor) parser.parseElement(interceptorElement, parse, WireParser.CATEGORY_INTERCEPTOR);
- commandServiceDescriptor.addInterceptorDescriptor(interceptorDescriptor);
- }
+ for (Element interceptorElement : interceptorElements) {
+ Descriptor interceptorDescriptor = (Descriptor) parser.parseElement(interceptorElement, parse, WireParser.CATEGORY_INTERCEPTOR);
+ commandServiceDescriptor.addInterceptorDescriptor(interceptorDescriptor);
}
return commandServiceDescriptor;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/VariableTypesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/VariableTypesBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/VariableTypesBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -25,10 +25,10 @@
import java.net.URL;
import java.util.List;
-import org.jbpm.pvm.internal.stream.FileStreamSource;
-import org.jbpm.pvm.internal.stream.ResourceStreamSource;
-import org.jbpm.pvm.internal.stream.StreamSource;
-import org.jbpm.pvm.internal.stream.UrlStreamSource;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
import org.jbpm.pvm.internal.type.Converter;
import org.jbpm.pvm.internal.type.Matcher;
import org.jbpm.pvm.internal.type.Type;
@@ -57,12 +57,12 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- StreamSource streamSource = null;
+ StreamInput streamSource = null;
if (element.hasAttribute("file")) {
String fileName = element.getAttribute("file");
File file = new File(fileName);
if (file.exists() && file.isFile()) {
- streamSource = new FileStreamSource(file);
+ streamSource = new FileStreamInput(file);
parser.importStream(streamSource, element, parse);
} else {
parse.addProblem("file "+fileName+" isn't a file");
@@ -71,7 +71,7 @@
if (element.hasAttribute("resource")) {
String resource = element.getAttribute("resource");
- streamSource = new ResourceStreamSource(resource, parse.getClassLoader());
+ streamSource = new ResourceStreamInput(resource, parse.getClassLoader());
parser.importStream(streamSource, element, parse);
}
@@ -79,7 +79,7 @@
String urlText = element.getAttribute("url");
try {
URL url = new URL(urlText);
- streamSource = new UrlStreamSource(url);
+ streamSource = new UrlStreamInput(url);
parser.importStream(streamSource, element, parse);
} catch (Exception e) {
parse.addProblem("couldn't open url "+urlText, e);
@@ -89,12 +89,10 @@
VariableTypeResolverDescriptor variableTypeResolverDescriptor = new VariableTypeResolverDescriptor();
List<Element> typeElements = XmlUtil.elements(element, "type");
- if (typeElements!=null) {
- for (Element typeElement: typeElements) {
- TypeMapping typeMapping = parseTypeMapping(typeElement, parse, parser);
- variableTypeResolverDescriptor.addTypeMapping(typeMapping);
- }
- }
+ for (Element typeElement: typeElements) {
+ TypeMapping typeMapping = parseTypeMapping(typeElement, parse, parser);
+ variableTypeResolverDescriptor.addTypeMapping(typeMapping);
+ }
return variableTypeResolverDescriptor;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -29,7 +29,7 @@
*/
public abstract class WireBinding extends TagBinding {
- static final String WIRE_NAMESPACE = "http://jbpm.org/wire";
+ static final String WIRE_NAMESPACE = "http://jbpm.org/4/cfg";
public WireBinding(String tagName, String category) {
super(tagName, WIRE_NAMESPACE, category);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -30,7 +30,6 @@
import org.jbpm.pvm.internal.xml.Bindings;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
-
import org.w3c.dom.Element;
public class BindingParser extends Parser {
@@ -39,31 +38,29 @@
public Object parseDocumentElement(Element documentElement, Parse parse) {
List<Element> elements = XmlUtil.elements(documentElement, "binding");
- if (elements!=null) {
- for (Element bindingElement : elements) {
- String bindingClassName = XmlUtil.attribute(bindingElement, "class");
-
- log.trace("adding wire binding for "+bindingClassName);
+ for (Element bindingElement : elements) {
+ String bindingClassName = XmlUtil.attribute(bindingElement, "class");
+
+ log.trace("adding wire binding for "+bindingClassName);
- Binding binding = null;
- if (bindingClassName!=null) {
- try {
- Class<?> bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
- binding = (Binding) bindingClass.newInstance();
- } catch (Exception e) {
- parse.addProblem("couldn't instantiate binding "+bindingClassName, e);
- }
- } else {
- parse.addProblem("class is a required attribute in a binding "+XmlUtil.toString(bindingElement));
+ Binding binding = null;
+ if (bindingClassName!=null) {
+ try {
+ Class<?> bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
+ binding = (Binding) bindingClass.newInstance();
+ } catch (Exception e) {
+ parse.addProblem("couldn't instantiate binding "+bindingClassName, e);
}
-
- if (binding!=null) {
- Bindings bindings = parse.findObject(Bindings.class);
- bindings.addBinding(binding);
- } else {
- log.info("WARNING: binding for "+bindingClassName+" could not be parsed. See parsing problems for more details.");
- }
+ } else {
+ parse.addProblem("class is a required attribute in a binding "+XmlUtil.toString(bindingElement));
}
+
+ if (binding!=null) {
+ Bindings bindings = parse.findObject(Bindings.class);
+ bindings.addBinding(binding);
+ } else {
+ log.info("WARNING: binding for "+bindingClassName+" could not be parsed. See parsing problems for more details.");
+ }
}
return null;
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-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -195,16 +195,15 @@
WireDefinition wireDefinition = new WireDefinition();
wireDefinition.setClassLoader(classLoader);
- if (elements!=null) {
- parse.pushObject(wireDefinition);
- try {
- for (Element descriptorElement: elements) {
- parseElement(descriptorElement, parse, CATEGORY_DESCRIPTOR);
- }
- } finally {
- parse.popObject();
+ parse.pushObject(wireDefinition);
+ try {
+ for (Element descriptorElement: elements) {
+ parseElement(descriptorElement, parse, CATEGORY_DESCRIPTOR);
}
+ } finally {
+ parse.popObject();
}
+
return wireDefinition;
}
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-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -33,12 +33,12 @@
import org.jbpm.JbpmException;
import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.stream.FileStreamSource;
-import org.jbpm.pvm.internal.stream.InputStreamSource;
-import org.jbpm.pvm.internal.stream.ResourceStreamSource;
-import org.jbpm.pvm.internal.stream.StreamSource;
-import org.jbpm.pvm.internal.stream.StringStreamSource;
-import org.jbpm.pvm.internal.stream.UrlStreamSource;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
@@ -57,7 +57,7 @@
protected Parser parser;
protected ClassLoader classLoader;
- protected StreamSource streamSource;
+ protected StreamInput streamSource;
protected InputStream inputStream;
protected InputSource inputSource;
@@ -73,19 +73,19 @@
/** specify an input stream as the source for this parse */
public Parse setInputStream(InputStream inputStream) {
- this.streamSource = new InputStreamSource(inputStream);
+ this.streamSource = new InputStreamInput(inputStream);
return this;
}
/** specify a URL as the source for this parse */
public Parse setUrl(URL url) {
- this.streamSource = new UrlStreamSource(url);
+ this.streamSource = new UrlStreamInput(url);
return this;
}
/** specify a file as the source for this parse */
public Parse setFile(File file) {
- this.streamSource = new FileStreamSource(file);
+ this.streamSource = new FileStreamInput(file);
return this;
}
@@ -98,18 +98,18 @@
/** specify a resource as the source for this parse */
public Parse setResource(String resource) {
- this.streamSource = new ResourceStreamSource(resource, classLoader);
+ this.streamSource = new ResourceStreamInput(resource, classLoader);
return this;
}
/** specify an XML string as the source for this parse */
public Parse setString(String xmlString) {
- this.streamSource = new StringStreamSource(xmlString);
+ this.streamSource = new StringStreamInput(xmlString);
return this;
}
- /** specify a {@link StreamSource} as the source for this parse */
- public Parse setStreamSource(StreamSource streamSource) {
+ /** specify a {@link StreamInput} as the source for this parse */
+ public Parse setStreamSource(StreamInput streamSource) {
this.streamSource = streamSource;
return this;
}
@@ -146,17 +146,25 @@
/** part of {@link ErrorHandler} to capture XML parsing problems. */
public void error(SAXParseException e) {
- addProblem(e.getMessage(), e, ProblemImpl.SEVERITY_ERROR);
+ addXmlValidationProblem(e, ProblemImpl.TYPE_XML_VALIDATION_ERROR);
}
+
/** part of {@link ErrorHandler} to capture XML parsing problems. */
public void fatalError(SAXParseException e) {
- addProblem(e.getMessage(), e, ProblemImpl.SEVERITY_FATALERROR);
+ addXmlValidationProblem(e, ProblemImpl.TYPE_XML_VALIDATION_ERROR);
}
/** part of {@link ErrorHandler} to capture XML parsing problems. */
public void warning(SAXParseException e) {
- addProblem(e.getMessage(), e, ProblemImpl.SEVERITY_WARNING);
+ addXmlValidationProblem(e, ProblemImpl.TYPE_XML_VALIDATION_WARNING);
}
-
+
+ protected void addXmlValidationProblem(SAXParseException e, String type) {
+ ProblemImpl problem = new ProblemImpl(e.getMessage(), e, type);
+ problem.setLine(e.getLineNumber());
+ problem.setColumn(e.getColumnNumber());
+ addProblem(problem);
+ }
+
// contextual objects ///////////////////////////////////////////////////////
/** push a contextual object on the stack of this parse. */
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-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -21,19 +21,22 @@
*/
package org.jbpm.pvm.internal.xml;
-import java.io.File;
-import java.util.HashMap;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
+import org.jbpm.JbpmException;
import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.stream.StreamSource;
+import org.jbpm.pvm.internal.stream.StreamInput;
import org.jbpm.pvm.internal.util.UrlEntity;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.w3c.dom.Document;
@@ -99,7 +102,7 @@
* {@link Parse#setInputStream(java.io.InputStream)},
* {@link Parse#setInputSource(InputSource)},
* {@link Parse#setUrl(java.net.URL)} and
- * {@link Parse#setStreamSource(StreamSource)}.
+ * {@link Parse#setStreamSource(StreamInput)}.
* </p>
*
* <p><b>line 7</b> shows how the execution of the parse is performed. The
@@ -242,21 +245,12 @@
*
* @author Tom Baeyens
*/
-public class Parser implements EntityResolver {
+public class Parser {
private static Log log = Log.getLog(Parser.class.getName());
protected DocumentBuilderFactory documentBuilderFactory = null;
- /* TODO add schema's
-Source schemaSource = new StreamSource(inputStream);
-SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-Schema schema = schemaFactory.newSchema(schemaSource);
-// Instead of explicitly validating, assign the Schema to the factory
-factory.setSchema(schema);
- */
-
- protected Map<String, Entity> entities = null;
protected Bindings bindings = null;
protected ClassLoader classLoader = null;
@@ -274,7 +268,6 @@
* in specialized subclasses of Parser. */
public Parser(Bindings bindings, Map<String, Entity> entities) {
this.bindings = bindings;
- this.entities = entities;
}
// document builder methods /////////////////////////////////////////////////
@@ -303,48 +296,37 @@
return factory;
}
- // entities /////////////////////////////////////////////////////////////////
-
- /** adds a resolver to the schema catalog.
- * See also <a href="#entityresolving">section 'Entity resolving'</a>. */
- public void addEntity(String publicId, Entity entity) {
- if (entities==null) {
- entities = new HashMap<String, Entity>();
+ // schema validation ////////////////////////////////////////////////////////
+
+ protected void setSchemaResources(List<String> resources) {
+ if ( (resources==null)
+ || (resources.isEmpty())
+ ) {
+ throw new JbpmException("no schema resoures");
}
- entities.put(publicId, entity);
- }
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- /** makes sure that an {@link EntityResolver} is created based on the {@link Entity}s in this parser.
- * even when none of the {@link #addEntity(String, Entity)} methods are called.
- * This enables addition of entities on a per-{@link Parse} basis when there are no parser-level entities. */
- public void useParseEntityResolver() {
- if (entities==null) {
- entities = new HashMap<String, Entity>();
- }
- }
-
- /** implementation of {@link EntityResolver} based on a map of {@link Entity}s.
- * See also <a href="entityresolving">section 'Entity resolving'</a>.
- * @see #addEntity(String, Entity) */
- public InputSource resolveEntity(String publicId, String systemId) {
- InputSource inputSource = null;
- if (entities!=null) {
- Entity entity = entities.get(publicId);
- if (entity!=null) {
- inputSource = entity.getInputSource();
+ List<Source> schemaSources = new ArrayList<Source>();
+ for (String resource: resources) {
+ InputStream schemaStream = classLoader.getResourceAsStream(resource);
+ if (schemaStream==null) {
+ throw new JbpmException("schema resource "+resource+" unavailable");
}
+ StreamSource schemaSource = new StreamSource(schemaStream);
+ schemaSources.add(schemaSource);
}
- if (inputSource==null) {
- if (systemId!=null) {
- // plan b: see if we can build an inputsource from the systemId
- inputSource = new InputSource(systemId);
- } else {
- log.error("couldn't resolve entity with publicId "+publicId+" and systemId "+systemId);
- }
+ try {
+ Source[] schemaSourceArray = schemaSources.toArray(new Source[schemaSources.size()]);
+ Schema schema = schemaFactory.newSchema(schemaSourceArray);
+ DocumentBuilderFactory factory = getDocumentBuilderFactory();
+ factory.setSchema(schema);
+ factory.setNamespaceAware(true);
+ } catch (Exception e) {
+ log.error("couldn't install schema's for validation: "+e.toString());
}
- return inputSource;
}
-
+
// bindings /////////////////////////////////////////////////////////////////
/** the handlers for specific element types */
@@ -378,7 +360,7 @@
/** builds a dom from the importedStreamSource and appends the child elements
* of the document element to the destination element. Problems are reported
* in the importingParse. */
- public void importStream(StreamSource importedStreamSource, Element destination, Parse importingParse) {
+ public void importStream(StreamInput importedStreamSource, Element destination, Parse importingParse) {
try {
// build the dom of the imported document
Parse importedParse = createParse();
@@ -411,7 +393,7 @@
parseDocument(parse.document, parse);
} catch (Exception e) {
- parse.addProblem("couldn't interpret the dom model", e);
+ parse.addProblem("couldn't interpret the dom model: "+e.getMessage(), e);
}
}
@@ -458,7 +440,6 @@
return null;
}
parse.documentBuilder.setErrorHandler(parse);
- parse.documentBuilder.setEntityResolver(this);
return parse.documentBuilder;
}
Modified: 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 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -36,19 +36,20 @@
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";
+ public static final String TYPE_ERROR = "error";
+ public static final String TYPE_WARNING = "warning";
+ public static final String TYPE_XML_VALIDATION_ERROR = "xml validation error";
+ public static final String TYPE_XML_VALIDATION_WARNING = "xml validation warning";
String resource;
- String severity;
- Integer line = -1;
- Integer column = -1;
+ String type;
+ Integer line;
+ Integer column;
String msg;
Throwable cause;
- public ProblemImpl(String msg, Exception e, String severity) {
- this.severity = severity;
+ public ProblemImpl(String msg, Exception e, String type) {
+ this.type = type;
this.msg = msg;
this.cause = e;
if (e instanceof SAXParseException) {
@@ -90,20 +91,20 @@
this.resource = resource;
}
public String getSeverity() {
- return severity;
+ return type;
}
public void setSeverity(String severity) {
- this.severity = severity;
+ this.type = severity;
}
public String toString() {
StringBuffer text = new StringBuffer();
- text.append(severity);
- text.append(" : ");
+ text.append(type);
+ text.append(": ");
text.append(msg);
text.append(" ");
- if ((line!=-1) || (column!=-1) || (resource!=null)) {
+ if ((line!=null) || (column!=null) || (resource!=null)) {
text.append("[");
if (line!=-1) {
text.append("line="+line+" ");
Modified: 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 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -62,26 +62,26 @@
problems.add(problem);
}
- /** add a problem with {@link ProblemImpl#SEVERITY_ERROR the default severity}.*/
+ /** add a problem with {@link ProblemImpl#TYPE_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}.*/
+ * {@link ProblemImpl#TYPE_ERROR the default severity}.*/
public void addProblem(String msg, Exception e) {
- addProblem(msg, e, ProblemImpl.SEVERITY_ERROR);
+ addProblem(msg, e, ProblemImpl.TYPE_ERROR);
}
- /** adds a problem with {@link ProblemImpl#SEVERITY_WARNING severity warning}.*/
+ /** adds a problem with {@link ProblemImpl#TYPE_WARNING severity warning}.*/
public void addWarning(String msg) {
addWarning(msg, null);
}
- /** adds a problem with {@link ProblemImpl#SEVERITY_WARNING severity warning}
+ /** adds a problem with {@link ProblemImpl#TYPE_WARNING severity warning}
* and an exception as the cause.*/
public void addWarning(String msg, Exception e) {
- addProblem(msg, e, ProblemImpl.SEVERITY_WARNING);
+ addProblem(msg, e, ProblemImpl.TYPE_WARNING);
}
/** adds a problem given message, exception cause and severity */
@@ -102,28 +102,42 @@
public String getProblemsText() {
- String errorMsg = null;
if (problems!=null) {
- StringBuffer errorMsgBuffer = null;
+ StringBuffer errorBuffer = null;
+ StringBuffer warningBuffer = null;
for (Problem p : getProblems()) {
- if (p.getSeverity().equals(ProblemImpl.SEVERITY_ERROR) || p.getSeverity().equals(ProblemImpl.SEVERITY_FATALERROR)) {
- if (errorMsgBuffer==null) {
- errorMsgBuffer = new StringBuffer();
+ if (p.getSeverity().equals(ProblemImpl.TYPE_ERROR)) {
+ if (errorBuffer==null) {
+ errorBuffer = new StringBuffer();
+ errorBuffer.append("errors:");
+ errorBuffer.append(NEWLINE);
}
- errorMsgBuffer.append(NEWLINE);
- errorMsgBuffer.append(" ");
- errorMsgBuffer.append(p.toString());
- if (p.getCause()!=null) {
- log.error(p.toString(), p.getCause());
- } else {
- log.error(p.toString());
+ errorBuffer.append(NEWLINE);
+ errorBuffer.append(" ");
+ errorBuffer.append(p.toString());
+ } else {
+ if (warningBuffer==null) {
+ warningBuffer = new StringBuffer();
+ warningBuffer.append("warnings:");
+ warningBuffer.append(NEWLINE);
}
- } else {
- log.info("WARNING: "+p.toString());
+ warningBuffer.append(NEWLINE);
+ warningBuffer.append(" ");
+ warningBuffer.append(p.toString());
}
}
- errorMsg = (errorMsgBuffer!=null ? errorMsgBuffer.toString() : null);
+ if (errorBuffer!=null) {
+ if (warningBuffer!=null) {
+ errorBuffer.append(NEWLINE);
+ errorBuffer.append(warningBuffer.toString());
+ }
+ return errorBuffer.toString();
+ }
+ if (warningBuffer!=null) {
+ warningBuffer.append(NEWLINE);
+ return warningBuffer.toString();
+ }
}
- return errorMsg;
+ return null;
}
}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/WireParserTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/WireParserTest.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/xml/WireParserTest.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -1,35 +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 org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class WireParserTest extends JbpmTestCase
-{
-
- public void testOne() {
-
- }
-}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java 2008-12-08 16:53:26 UTC (rev 3274)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java 2008-12-08 22:35:29 UTC (rev 3275)
@@ -39,14 +39,12 @@
ProcessDefinitionImpl lifeCycleProcess = new ProcessDefinitionImpl();
List<Element> stateElements = XmlUtil.elements(element, "state");
- if (stateElements!=null) {
- for (Element stateElement: stateElements) {
- parseState(stateElement, lifeCycleProcess, parse);
- }
- for (Element stateElement: stateElements) {
- parseTransitions(stateElement, lifeCycleProcess, parse);
- }
+ for (Element stateElement: stateElements) {
+ parseState(stateElement, lifeCycleProcess, parse);
}
+ for (Element stateElement: stateElements) {
+ parseTransitions(stateElement, lifeCycleProcess, parse);
+ }
String initialStateName = null;
if (element.hasAttribute("initial")) {
@@ -71,10 +69,8 @@
NodeImpl state = (NodeImpl) lifeCycleProcess.getNode(stateName);
List<Element> transitionElements = XmlUtil.elements(element, "transition");
- if (transitionElements!=null) {
- for (Element transitionElement: transitionElements) {
- parseTransition(transitionElement, state, parse);
- }
+ for (Element transitionElement: transitionElements) {
+ parseTransition(transitionElement, state, parse);
}
}
More information about the jbpm-commits
mailing list