[jbpm-commits] JBoss JBPM SVN: r3054 - in jbpm3/trunk/modules: integration/api and 7 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Nov 24 09:14:07 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-11-24 09:14:07 -0500 (Mon, 24 Nov 2008)
New Revision: 3054

Added:
   jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/jpdl32/
   jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/jpdl32/DialectHandlerImpl.java
Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
   jbpm3/trunk/modules/integration/api/pom.xml
   jbpm3/trunk/modules/integration/api/src/
   jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/NodeImpl.java
   jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
   jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessImpl.java
   jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java
   jbpm3/trunk/modules/integration/api/src/main/resources/jbpm-cfg-beans.xml
   jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/simple-process.xml
Log:
Add jPDL DialectHandler

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -48,9 +48,9 @@
   
   private static final long serialVersionUID = 1L;
   
-  protected List leavingTransitions = null;
+  protected List<Transition> leavingTransitions = null;
   transient Map leavingTransitionMap = null;
-  protected Set arrivingTransitions = null;
+  protected Set<Transition> arrivingTransitions = null;
   protected Action action = null;
   protected SuperState superState = null;
   protected boolean isAsync = false;
@@ -92,10 +92,14 @@
 
   // leaving transitions //////////////////////////////////////////////////////
   
-  public List getLeavingTransitions() {
+  public List<Transition> getLeavingTransitions() {
     return leavingTransitions;
   }
 
+  public List<Transition> getLeavingTransitionsList() {
+    return leavingTransitions;
+  }
+
   /**
    * are the leaving {@link Transition}s, mapped by their name (java.lang.String).
    */
@@ -226,15 +230,11 @@
     if ( (leavingTransitions!=null)
          && (Math.min(oldIndex, newIndex)>=0)
          && (Math.max(oldIndex, newIndex)<leavingTransitions.size()) ) {
-      Object o = leavingTransitions.remove(oldIndex);
+      Transition o = leavingTransitions.remove(oldIndex);
       leavingTransitions.add(newIndex, o);
     }
   }
 
-  public List getLeavingTransitionsList() {
-    return leavingTransitions;
-  }
-
   // arriving transitions /////////////////////////////////////////////////////
 
   /**

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -57,7 +57,7 @@
   protected int version = -1;
   protected boolean isTerminationImplicit = false;
   protected Node startState = null;
-  protected List nodes = null;
+  protected List<Node> nodes = null;
   transient Map nodesMap = null;
   protected Map actions = null;
   protected Map definitions = null;
@@ -202,7 +202,7 @@
   // nodes ////////////////////////////////////////////////////////////////////
 
   // javadoc description in NodeCollection
-  public List getNodes() {
+  public List<Node> getNodes() {
     return nodes;
   }
 
@@ -272,7 +272,7 @@
     if ( (nodes!=null)
          && (Math.min(oldIndex, newIndex)>=0)
          && (Math.max(oldIndex, newIndex)<nodes.size()) ) {
-      Object o = nodes.remove(oldIndex);
+      Node o = nodes.remove(oldIndex);
       nodes.add(newIndex, o);
     } else {
       throw new IndexOutOfBoundsException("couldn't reorder element from index '"+oldIndex+"' to index '"+newIndex+"' in nodeList '"+nodes+"'");

Modified: jbpm3/trunk/modules/integration/api/pom.xml
===================================================================
--- jbpm3/trunk/modules/integration/api/pom.xml	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/api/pom.xml	2008-11-24 14:14:07 UTC (rev 3054)
@@ -75,16 +75,39 @@
   </dependencies>
   
   <build>
+   <testResources>
+    <testResource>
+      <directory>src/test/resources</directory>
+    </testResource>
+    <testResource>
+      <directory>src/cts/resources</directory>
+    </testResource>
+   </testResources>
    <plugins>
       <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-test-source</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>src/cts</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-clean-plugin</artifactId>
         <configuration>
           <filesets>
             <fileset>
-              <directory>src/test</directory>
-              <includes>
-                <include>java/org/jbpm/test/**</include>
-              </includes>
+              <directory>src/cts</directory>
             </fileset>
           </filesets>
         </configuration>
@@ -105,7 +128,7 @@
                   <type>zip</type>
                 </artifactItem>
               </artifactItems>
-              <outputDirectory>src/test</outputDirectory>
+              <outputDirectory>src/cts</outputDirectory>
             </configuration>
           </execution>
         </executions>


Property changes on: jbpm3/trunk/modules/integration/api/src
___________________________________________________________________
Name: svn:ignore
   - test

   + test
cts


Added: jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/jpdl32/DialectHandlerImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/jpdl32/DialectHandlerImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/jpdl32/DialectHandlerImpl.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -0,0 +1,70 @@
+/*
+ * 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.integration.jpdl32;
+
+// $Id$
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URL;
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.service.AbstractDialectHandler;
+import org.jbpm.api.service.DialectHandler;
+import org.jbpm.integration.model.ProcessDefinitionImpl;
+
+/**
+ * A jPDL a {@link DialectHandler}
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Nov-2008
+ */
+public class DialectHandlerImpl extends AbstractDialectHandler
+{
+  public URI getNamespaceURI()
+  {
+    return URI.create("urn:jbpm.org:jpdl-3.2");
+  }
+
+  public ProcessDefinition parseProcessDefinition(URL pdXML) throws IOException
+  {
+    InputStream inStream = pdXML.openStream();
+    org.jbpm.graph.def.ProcessDefinition oldProcDef = org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(inStream);
+    ProcessDefinition procDef = new ProcessDefinitionImpl(getProcessEngine(), oldProcDef);
+    return procDef;
+  }
+
+  public ProcessDefinition parseProcessDefinition(String pdXML)
+  {
+    org.jbpm.graph.def.ProcessDefinition oldProcDef = org.jbpm.graph.def.ProcessDefinition.parseXmlString(pdXML);
+    ProcessDefinition procDef = new ProcessDefinitionImpl(getProcessEngine(), oldProcDef);
+    return procDef;
+  }
+
+  public void marshallProcessDefinition(ProcessDefinition procDef, Writer out) throws IOException
+  {
+    throw new NotImplementedException("jPDL marshalling not implemented");
+  }
+}
\ No newline at end of file


Property changes on: jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/jpdl32/DialectHandlerImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/NodeImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/NodeImpl.java	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/NodeImpl.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -58,7 +58,6 @@
     this.oldNode = oldNode;
   }
 
-  //@Override
   public ObjectName getKey()
   {
     long id = oldNode.getId();
@@ -70,19 +69,16 @@
     return oldNode;
   }
 
-  //@Override
   public String getName()
   {
     return oldNode.getName();
   }
 
-  //@Override
   public ProcessDefinition getProcessDefinition()
   {
     return procDef;
   }
 
-  //@Override
   public Process getProcess()
   {
     return proc;
@@ -101,8 +97,11 @@
       throw new InvalidProcessException("Cannot obtain target node: " + targetRef);
     
     Transition trans = flow.getOldTransition();
-    oldNode.addLeavingTransition(trans);
-    targetNode.getOldNode().addArrivingTransition(trans);
+    if (oldNode.hasLeavingTransition(trans.getName()) == false)
+    {
+      oldNode.addLeavingTransition(trans);
+      targetNode.getOldNode().addArrivingTransition(trans);
+    }
     
     outFlows.add(flow);
   }
@@ -112,7 +111,6 @@
     return Collections.unmodifiableList(outFlows);
   }
 
-  //@Override
   public String toString()
   {
     return oldNode.toString();

Modified: jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -31,11 +31,16 @@
 
 import org.jbpm.api.Constants;
 import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
 import org.jbpm.api.client.ProcessEngine;
 import org.jbpm.api.model.Node;
 import org.jbpm.api.model.Process;
 import org.jbpm.api.model.ProcessDefinition;
 import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.node.EndState;
+import org.jbpm.graph.node.StartState;
+import org.jbpm.graph.node.State;
 
 /**
  * An integration wrapper
@@ -53,40 +58,45 @@
 
   public ProcessDefinitionImpl(ProcessEngine engine, String name)
   {
-    this.oldProcDef = new org.jbpm.graph.def.ProcessDefinition(name);
+    this(engine, new org.jbpm.graph.def.ProcessDefinition(name));
+  }
+  
+  public ProcessDefinitionImpl(ProcessEngine engine, org.jbpm.graph.def.ProcessDefinition oldProcDef)
+  {
+    this.oldProcDef = oldProcDef;
     this.engine = engine;
-
-    if (name == null)
+    
+    if (oldProcDef.getName() == null)
       throw new InvalidProcessException("ProcessDefinition name cannot be null");
+    
+    if (oldProcDef.getNodes() != null)
+    {
+      initializeNodes(oldProcDef);
+      initializeSequenceFlows(oldProcDef);
+    }
   }
 
-  
   public org.jbpm.graph.def.ProcessDefinition getOldProcessDefinition()
   {
     return oldProcDef;
   }
 
-
-  //@Override
   public ProcessEngine getProcessEngine()
   {
     return engine;
   }
 
-  //@Override
   public ObjectName getKey()
   {
     long id = oldProcDef.getId();
     return ObjectNameFactory.create(Constants.ID_DOMAIN + ":procdef=" + getName() + ",id=" + id);
   }
 
-  //@Override
   public String getName()
   {
     return oldProcDef.getName();
   }
 
-  //@Override
   public Process newInstance()
   {
     ProcessImpl procImpl = new ProcessImpl(this);
@@ -105,20 +115,17 @@
     nodes.put(oldNode.getName(), nodeImpl);
   }
 
-  //@Override
   public Node getNode(String name)
   {
     return nodes.get(name);
   }
 
-  //@Override
   public List<Node> getNodes()
   {
     List<Node> nodeList = new ArrayList<Node>(nodes.values());
     return Collections.unmodifiableList(nodeList);
   }
 
-  //@Override
   @SuppressWarnings("unchecked")
   public <T extends Node> T getNode(Class<T> clazz, String name)
   {
@@ -130,7 +137,6 @@
     return null;
   }
 
-  //@Override
   @SuppressWarnings("unchecked")
   public <T extends Node> List<T> getNodes(Class<T> clazz)
   {
@@ -142,4 +148,45 @@
     }
     return retNodes;
   }
+
+  private void initializeNodes(org.jbpm.graph.def.ProcessDefinition oldProcDef)
+  {
+    for(org.jbpm.graph.def.Node oldNode : oldProcDef.getNodes())
+    {
+      NodeImpl nodeImpl;
+      if (oldNode instanceof StartState)
+      {
+        nodeImpl = new StartEventImpl(this, (StartState)oldNode);
+      }
+      else if (oldNode instanceof State)
+      {
+        nodeImpl = new WaitStateImpl(this, (State)oldNode);
+      }
+      else if (oldNode instanceof EndState)
+      {
+        nodeImpl = new EndEventImpl(this, (EndState)oldNode);
+      }
+      else
+      {
+        throw new NotImplementedException("Unsupported node type: " + oldNode);
+      }
+      nodes.put(oldNode.getName(), nodeImpl);
+    }
+  }
+
+  private void initializeSequenceFlows(org.jbpm.graph.def.ProcessDefinition oldProcDef)
+  {
+    for(org.jbpm.graph.def.Node oldNode : oldProcDef.getNodes())
+    {
+      NodeImpl nodeImpl = (NodeImpl)nodes.get(oldNode.getName());
+      if (oldNode.getLeavingTransitions() != null)
+      {
+        for (Transition trans : oldNode.getLeavingTransitions())
+        {
+          SequenceFlowImpl seqFlow = new SequenceFlowImpl(trans);
+          nodeImpl.addSequenceFlow(seqFlow);
+        }
+      }
+    }
+  }
 }

Modified: jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessImpl.java	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/model/ProcessImpl.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -30,8 +30,8 @@
 import org.jbpm.api.client.Token;
 import org.jbpm.api.client.Token.TokenStatus;
 import org.jbpm.api.model.Node;
+import org.jbpm.api.model.ProcessDefinition;
 import org.jbpm.api.model.Process;
-import org.jbpm.api.model.ProcessDefinition;
 import org.jbpm.api.model.builder.ObjectNameFactory;
 import org.jbpm.api.runtime.Attachments;
 import org.jbpm.graph.exe.ProcessInstance;

Modified: jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/api/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java	2008-11-24 14:14:07 UTC (rev 3054)
@@ -51,25 +51,22 @@
   // The set of registered ProcessDefinitions
   private Map<ObjectName, ProcessDefinition> procDefs = new HashMap<ObjectName, ProcessDefinition>();
   
-  //@Override
+  @Override
   public void setProcessEngine(ProcessEngine engine)
   {
     super.setProcessEngine(engine);
   }
 
-  //@Override
   public ProcessDefinition getProcessDefinition(ObjectName procDefID)
   {
     return procDefs.get(procDefID);
   }
 
-  //@Override
   public Set<ObjectName> getProcessDefinitions()
   {
     return Collections.unmodifiableSet(procDefs.keySet());
   }
 
-  //@Override
   public ObjectName registerProcessDefinition(ProcessDefinition procDef)
   {
     if (getProcessDefinition(procDef.getKey()) != null)
@@ -84,7 +81,6 @@
     return procDefID;
   }
 
-  //@Override
   public boolean unregisterProcessDefinition(ObjectName procDefID)
   {
     boolean removed = false;

Modified: jbpm3/trunk/modules/integration/api/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/api/src/main/resources/jbpm-cfg-beans.xml	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/api/src/main/resources/jbpm-cfg-beans.xml	2008-11-24 14:14:07 UTC (rev 3054)
@@ -33,10 +33,12 @@
       <property name="dialectHandlers">
         <map keyClass="java.net.URI" valueClass="org.jbpm.api.service.DialectHandler">
           <entry><key>urn:jbpm.jboss:api-0.1</key><value><inject bean="jBPMDialectHandlerAPI10"/></value></entry>
+          <entry><key>urn:jbpm.org:jpdl-3.2</key><value><inject bean="jBPMDialectHandlerJPDL32"/></value></entry>
         </map>
       </property>
     </bean>
     <bean name="jBPMDialectHandlerAPI10" class="org.jbpm.dialect.api10.DialectHandlerImpl"/>
+    <bean name="jBPMDialectHandlerJPDL32" class="org.jbpm.integration.jpdl32.DialectHandlerImpl"/>
     
     <!-- Other Services -->
     <bean name="jBPMProcessBuilderService" class="org.jbpm.integration.service.ProcessBuilderServiceImpl" />

Modified: jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/simple-process.xml
===================================================================
--- jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/simple-process.xml	2008-11-24 13:59:41 UTC (rev 3053)
+++ jbpm3/trunk/modules/integration/jboss42/src/test/resources/simple/simple-process.xml	2008-11-24 14:14:07 UTC (rev 3054)
@@ -1,4 +1,4 @@
-<process-definition name="timerProcess" xmlns="urn:jbpm.org:jpdl-3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<process-definition name="simpleProcess" xmlns="urn:jbpm.org:jpdl-3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd">
   <start-state name='start'>
     <transition to='a' />




More information about the jbpm-commits mailing list