Author: kukeltje
Date: 2009-07-27 15:34:52 -0400 (Mon, 27 Jul 2009)
New Revision: 5350
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
Log:
Remove dependency on jBPM module
Modified: jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml 2009-07-27 18:29:46 UTC
(rev 5349)
+++ jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml 2009-07-27 19:34:52 UTC
(rev 5350)
@@ -1,8 +1,8 @@
<activities>
- <activity binding="com.camunda.bpmn.activity.StartBinding" />
- <activity binding="com.camunda.bpmn.activity.TaskBinding" />
- <activity binding="com.camunda.bpmn.activity.ServiceActivityBinding"
/>
- <activity binding="com.camunda.bpmn.activity.ReceiveBinding" />
- <activity binding="com.camunda.bpmn.activity.EndBinding" />
- <activity binding="com.camunda.bpmn.activity.DecisionBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.StartBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.TaskBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.ServiceActivityBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.ReceiveBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.EndBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.DecisionBinding" />
</activities>
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2009-07-27
18:29:46 UTC (rev 5349)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2009-07-27
19:34:52 UTC (rev 5350)
@@ -21,7 +21,7 @@
*/
package org.jbpm.bpmn.flownodes;
-import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.model.ScopeElementImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.xml.Parse;
@@ -43,7 +43,7 @@
TaskActivity taskActivity = new TaskActivity();
ScopeElementImpl scopeElement = parse.findObject(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = JpdlParser.parseTaskDefinition(element, parse,
scopeElement);
+ TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse,
scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
return taskActivity;
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
(rev 0)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java 2009-07-27
19:34:52 UTC (rev 5350)
@@ -0,0 +1,69 @@
+/*
+ * 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.bpmn.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.internal.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 BindingsParser extends Parser {
+
+ private static final Log log = Log.getLog(BindingsParser.class.getName());
+
+ public Object parseDocumentElement(Element documentElement, Parse parse) {
+ List<Binding> bindings = new ArrayList<Binding>();
+ parse.setDocumentObject(bindings);
+
+ for (Element bindingElement : XmlUtil.elements(documentElement)) {
+ Binding binding = instantiateBinding(bindingElement, parse);
+ bindings.add(binding);
+ }
+
+ return bindings;
+ }
+
+ protected Binding instantiateBinding(Element bindingElement, Parse parse) {
+ String bindingClassName = XmlUtil.attribute(bindingElement, "binding",
true, parse);
+
+ log.trace("adding bpmn 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;
+ }
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-07-27
18:29:46 UTC (rev 5349)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-07-27
19:34:52 UTC (rev 5350)
@@ -27,9 +27,10 @@
import java.util.List;
import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.bpmn.flownodes.BpmnBinding;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.internal.log.Log;
-import org.jbpm.jpdl.internal.activity.JpdlBinding;
+//import org.jbpm.jpdl.internal.activity.JpdlBinding;
import org.jbpm.jpdl.internal.xml.BindingsParser;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
@@ -59,7 +60,7 @@
// array elements are mutable, even when final
// never make a static array public
- static final String[] DEFAULT_ACTIVITIES_RESOURCES = {
"jbpm.bpmn.activities.xml" };
+ static final String[] DEFAULT_ACTIVITIES_RESOURCES = {
"jbpm.bpmn.flownodes.xml" };
static final String CATEGORY_ACTIVITY = "activity";
static BindingsParser bindingsParser = new BindingsParser();
@@ -138,7 +139,7 @@
while (resourceUrls.hasMoreElements()) {
URL resourceUrl = resourceUrls.nextElement();
log.trace("loading bpmn activities from resource: " + resourceUrl);
- List<JpdlBinding> activityBindings = (List<JpdlBinding>)
bindingsParser
+ List<BpmnBinding> activityBindings = (List<BpmnBinding>)
bindingsParser
.createParse()
.setUrl(resourceUrl)
.execute()
@@ -210,7 +211,9 @@
String sourceRef = XmlUtil.attribute(transitionElement, "sourceRef",
true, parse);
String targetRef = XmlUtil.attribute(transitionElement, "targetRef",
true, parse);
- System.out.println(sourceRef + " -> " + targetRef);
+ System.out.println(transitionId + ": " + sourceRef + " -> "
+ targetRef);
+ System.out.println(" with " + XmlUtil.elements(transitionElement,
"conditionExpression").size() + " conditionExpressions");
+
TransitionImpl transition =
compositeElement.findActivity(sourceRef).createOutgoingTransition();
compositeElement.findActivity(targetRef).addIncomingTransition(transition);