[jbpm-commits] JBoss JBPM SVN: r2408 - in jbpm4/branches/tdiesler/modules: api/src/main/java/org/jbpm/api and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Sep 27 14:27:51 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-09-27 14:27:51 -0400 (Sat, 27 Sep 2008)
New Revision: 2408

Added:
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java
   jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/
   jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java
Removed:
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java
Modified:
   jbpm4/branches/tdiesler/modules/api/pom.xml
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java
   jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java
   jbpm4/branches/tdiesler/modules/impl/pom.xml
   jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java
   jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml
Log:
wip

Modified: jbpm4/branches/tdiesler/modules/api/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/api/pom.xml	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/pom.xml	2008-09-27 18:27:51 UTC (rev 2408)
@@ -27,7 +27,7 @@
 
   <!-- Properties -->
   <properties>
-    <jboss.microcontainer.version>2.0.0.Beta15</jboss.microcontainer.version>
+    <jboss.microcontainer.version>2.0.0.CR1</jboss.microcontainer.version>
   </properties>
   
   <!-- DependencyManagement -->

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,36 @@
+/*
+ * 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.api;
+
+//$Id$
+
+
+/**
+ * Defines the constants used by the jBPM API
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface Constants 
+{
+  static final String ID_DOMAIN = "jboss.jbpm";
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -26,8 +26,7 @@
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.jbpm.api.config.Configuration;
@@ -60,7 +59,7 @@
   final static Logger log = LoggerFactory.getLogger(ProcessEngine.class);
 
   // The map of registered services
-  private Map<Class<Service>, Service> services = new HashMap<Class<Service>, Service>();
+  protected Set<Service> services = new HashSet<Service>();
   // The name of this engine
   private String name;
 
@@ -77,7 +76,16 @@
   @SuppressWarnings("unchecked")
   public <T> T getService(Class<T> clazz)
   {
-    return (T)services.get(clazz);
+    Service service = null;
+    for (Service aux : services)
+    {
+      if (clazz.isAssignableFrom(aux.getClass()))
+      {
+        service = aux;
+        break;
+      }
+    }
+    return (T)service;
   }
 
   /**

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.api.model;
-
-// $Id$
-
-/**
- * The base of all builders.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface Builder
-{
-}
\ No newline at end of file

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.api.model;
-
-//$Id$
-
-/**
- * There are two ways of Connecting Objects in BPMN: a Flow, either sequence or message, and an Association. Sequence
- * Flow and Message Flow, to a certain extent, represent orthogonal aspects of the business processes depicted in a model,
- * although they both affect the performance of activities within a Process.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface ConnectingObject
-{
-  /**
-   * Name is an optional attribute that is text description of the Connecting Object.
-   */
-  String getName();
-
-  /**
-   * SourceRef is an attribute that identifies which Graphical Element the Connecting
-   * Object is connected from. Note: there are restrictions as to what objects Sequence
-   * Flow and Message Flow can connect. 
-   */
-  Node getSourceRef();
-
-  /**
-   * TargetRef is an attribute that identifies which Graphical Element the Connecting
-   * Object is connected to. Note: there are restrictions as to what objects Sequence
-   * Flow and Message Flow can connect.
-   */
-  Node getTargetRef();
-
-  /**
-   * Get the required target name
-   */
-  String getTargetName();
-}
\ No newline at end of file

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -35,4 +35,16 @@
  */
 public interface EndEvent extends Event
 {
+  /**
+   * Defines the type of end result
+   */
+  enum ResultType
+  {
+    None, Message, Error, Compensation, Link, Multiple 
+  }
+  
+  /**
+   * Get the type od end result
+   */
+  ResultType getResultType();
 }
\ No newline at end of file

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,58 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * Sequence Flow and Message Flow, to a certain extent, represent orthogonal aspects of the business processes depicted in a model,
+ * although they both affect the performance of activities within a Process.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface Flow
+{
+  /**
+   * Name is an optional attribute that is text description of the Connecting Object.
+   */
+  String getName();
+
+  /**
+   * SourceRef is an attribute that identifies which Graphical Element the Connecting
+   * Object is connected from. Note: there are restrictions as to what objects Sequence
+   * Flow and Message Flow can connect. 
+   */
+  Node getSourceRef();
+
+  /**
+   * TargetRef is an attribute that identifies which Graphical Element the Connecting
+   * Object is connected to. Note: there are restrictions as to what objects Sequence
+   * Flow and Message Flow can connect.
+   */
+  Node getTargetRef();
+
+  /**
+   * Get the required target name
+   */
+  String getTargetName();
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -60,7 +60,7 @@
    * set to None.
    * 
    * For DefaultGates:
-   * The Sequence Flow MUST have its Condition attribute set to Otherwise
+   * The Sequence Flow MUST have its Condition attribute set to Default
    */
   SequenceFlow getOutgoingSequenceFlow();
 

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -21,7 +21,7 @@
  */
 package org.jbpm.api.model;
 
-//$Id:$
+//$Id$
 
 import java.util.List;
 
@@ -78,5 +78,5 @@
    * Get the gate for the given target name
    * @return null if there is none
    */
-  Gate getGateByTargetName(String targetName);
+  Gate getGateByName(String targetName);
 }
\ No newline at end of file

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -22,6 +22,7 @@
 package org.jbpm.api.model;
 
 
+
 //$Id$
 
 /**

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,66 +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.api.model;
-
-//$Id$
-
-import javax.management.ObjectName;
-
-
-/**
- * A MessageBuilder can be used to build a {@link Message} dynamically.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface MessageBuilder extends Builder
-{
-  /**
-   * Create a {@link Message} with a given name
-   */
-  MessageBuilder newMessage(String msgName);
-
-  /**
-   * Add a message destination
-   */
-  MessageBuilder addToRef(ObjectName toRef);
-  
-  /**
-   * Add a message source
-   */
-  MessageBuilder addFromRef(ObjectName fromRef);
-  
-  /**
-   * Add a message property
-   */
-  MessageBuilder addProperty(String name, Object value);
-  
-  /**
-   * Add a message property
-   */
-  MessageBuilder addProperty(String name, Object value, boolean isCorrelation);
-  
-  /**
-   * Get the Message
-   */
-  Message getMessage();
-}
\ No newline at end of file

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,42 +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.api.model;
-
-//$Id$
-
-/**
- * A Message Flow is a dashed line that is used to show the flow of messages between two entities that are prepared to
- * send and receive them. In BPMN, two separate Pools in the Diagram will represent the two entities.
- * 
- * Message Flow MUST connect two Pools, either to the Pools themselves or to Flow Objects within the Pools. They cannot
- * connect two objects within the same Pool.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface MessageFlow extends ConnectingObject
-{
-  /**
-   * MessageRef is an optional attribute that identifies the Message that is being sent.
-   */
-  Message getMessageRef();
-}
\ No newline at end of file

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -29,7 +29,7 @@
  * @author thomas.diesler at jboss.com
  * @since 08-Jul-2008
  */
-public interface Node extends AbstractElement
+public interface Node extends AbstractElement 
 {
   /**
    * Get the unique name.

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -25,6 +25,8 @@
 
 import javax.management.ObjectName;
 
+
+
 /**
  * A Participant, which is used in the definition of attributes for a Pool, {@link Message}, and WebService
  * 

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -56,17 +56,22 @@
   ProcessStatus getProcessStatus();
   
   /**
-   * Get the list of flow objects
+   * Get the list of nodes
    */
   List<Node> getNodes();
 
   /**
-   * Get a list of flow objects of a given type.
+   * Get a list of nodes of a given type.
    */
   <T extends Node> List<T> getNodes(Class<T> clazz);
 
   /**
-   * Get a flow object by name.
+   * Get a node of a given type and name
+   */
+  <T extends Node> T getNode(Class<T> clazz, String name);
+
+  /**
+   * Get a node by name.
    * @return null if not found
    */
   Node getNode(String name);

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,119 +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.api.model;
-
-// $Id$
-
-/**
- * The ProcessBuilder can be used to build a {@link Process} dynamically.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface ProcessBuilder extends Builder
-{
-  /**
-   * Add a {@link Process} with a given name
-   */
-  ProcessBuilder addProcess(String name);
-
-  /**
-   * Get the {@link Process}. 
-   * <p/> 
-   * This is the final call to the ProcessBuilder after all elements have been added.
-   * The {@link Process} is initialized and put in state READY
-   */
-  Process getProcess();
-
-  /**
-   * Get the {@link Process} for inclusion in another.
-   * <p/> 
-   * This is the final call to the ProcessBuilder after all elements have been added.
-   * The {@link Process} is not initialized and stays in state CREATED
-   */
-  Process getProcessForInclude();
-
-  /**
-   * Add a SequenceFlow with a given name
-   */
-  ProcessBuilder addSequenceFlow(String targetName);
-
-  /**
-   * Add a MessageFlow with a given name
-   */
-  ProcessBuilder addMessageFlow(String targetName);
-
-  /**
-   * Add a SartEvent with a given name
-   */
-  ProcessBuilder addStartEvent(String name);
-
-  /**
-   * Add an IntermediateEvent with a given name
-   */
-  ProcessBuilder addEvent(String name);
-
-  /**
-   * Add an EndEvent with a given name
-   */
-  ProcessBuilder addEndEvent(String name);
-
-  /**
-   * Add a Task of {@link Task.TaskType} NONE with a given name
-   */
-  ProcessBuilder addTask(String name);
-
-  /**
-   * Add a Task with a given name and type
-   */
-  ProcessBuilder addTask(String name, Task.TaskType type);
-
-  /**
-   * Add a Gateway with a given name
-   */
-  ProcessBuilder addGateway(String name, Gateway.GatewayType type);
-
-  /**
-   * Add a {@link Message} with a given name.
-   */
-  MessageBuilder addMessage(String name);
-  
-  /**
-   * Add a process property
-   */
-  ProcessBuilder addProperty(String name, String value);
-  
-  /**
-   * Add an {@link ExecutionHandler} with a given Class
-   */
-  ProcessBuilder addExecutionHandler(Class<?> clazz);
-
-  /**
-   * Add an {@link FlowHandler} with a given Class
-   */
-  ProcessBuilder addFlowHandler(Class<?> clazz);
-
-  /**
-   * Add an {@link SignalHandler} with a given Class
-   */
-  ProcessBuilder addSignalHandler(Class<?> clazz);
-}
\ No newline at end of file

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.api.model;
 
+
 //$Id$
 
 /**
@@ -33,7 +34,7 @@
  * @author thomas.diesler at jboss.com
  * @since 08-Jul-2008
  */
-public interface SequenceFlow extends ConnectingObject
+public interface SequenceFlow extends Flow
 {
   /**
    * The ConditionType

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -33,4 +33,21 @@
  */
 public interface StartEvent extends Event
 {
+  /**
+   * Defines the start trigger type
+   */
+  enum TriggerType
+  {
+    None, Message, Timer, Rule, Signal 
+  }
+  
+  /**
+   * Get the outgoing SequenceFlow
+   */
+  SequenceFlow getOutFlow();
+  
+  /**
+   * Get the start trigger type
+   */
+  TriggerType getTriggerType();
 }
\ No newline at end of file

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,51 +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.api.model;
-
-//$Id$
-
-import java.util.List;
-
-/**
- * A Process is any Activity performed within a company or organization.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface StructuralProcess extends Process
-{
-  /**
-   * Get the list of flow objects
-   */
-  List<Node> getNodes();
-
-  /**
-   * Get a list of flow objects of a given type.
-   */
-  <T extends Node> List<T> getNodes(Class<T> clazz);
-
-  /**
-   * Get a flow object by name.
-   * @return null if not found
-   */
-  Node getNode(String name);
-}
\ No newline at end of file

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -52,4 +52,9 @@
    * The TaskType list MAY be extended to include new types.
    */
   TaskType getTaskType();
+  
+  /**
+   * Get the outgoing SequenceFlow
+   */
+  SequenceFlow getOutFlow();
 }
\ No newline at end of file

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,68 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.Message;
+
+
+/**
+ * A MessageBuilder can be used to build a {@link Message} dynamically.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MessageBuilder
+{
+  /**
+   * Create a {@link Message} with a given name
+   */
+  MessageBuilder newMessage(String msgName);
+
+  /**
+   * Add a message destination
+   */
+  MessageBuilder addToRef(ObjectName toRef);
+  
+  /**
+   * Add a message source
+   */
+  MessageBuilder addFromRef(ObjectName fromRef);
+  
+  /**
+   * Add a message property
+   */
+  MessageBuilder addProperty(String name, Object value);
+  
+  /**
+   * Add a message property
+   */
+  MessageBuilder addProperty(String name, Object value, boolean isCorrelation);
+  
+  /**
+   * Get the Message
+   */
+  Message getMessage();
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,48 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple incomming {@link SequenceFlow}s.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleInFlowSupport
+{
+  /**
+   * Gat the incomming SequenceFlows
+   */
+  List<SequenceFlow> getInFlows();
+  
+  /**
+   * Add an incomming SequenceFlow
+   */
+  void addInFlow(SequenceFlow flow);
+
+}


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,48 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple outgoing {@link SequenceFlow}s.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleOutFlowSupport
+{
+  /**
+   * Gat the outgoing SequenceFlows
+   */
+  List<SequenceFlow> getOutFlows();
+  
+  /**
+   * Add an outgoing SequenceFlow
+   */
+  void addOutFlow(SequenceFlow flow);
+
+}


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.api.model.builder;
+
+// $Id$
+
+import java.util.Hashtable;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * A simple factory for creating safe object names.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 08-May-2006
+ */
+public class ObjectNameFactory
+{
+   public static ObjectName create(String name)
+   {
+      try
+      {
+         return new ObjectName(name);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         throw new Error("Invalid ObjectName: " + name + "; " + e);
+      }
+   }
+
+   public static ObjectName create(String domain, String key, String value)
+   {
+      try
+      {
+         return new ObjectName(domain, key, value);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
+      }
+   }
+
+   public static ObjectName create(String domain, Hashtable<String, String> table)
+   {
+      try
+      {
+         return new ObjectName(domain, table);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
+      }
+   }
+}


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,91 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.api.model.Task.TaskType;
+
+/**
+ * The ProcessBuilder can be used to build a {@link Process} dynamically.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ProcessBuilder
+{
+  /**
+   * Add a {@link Process} with a given name
+   */
+  ProcessBuilder addProcess(String name);
+
+  /**
+   * Get the {@link Process}. 
+   * <p/> 
+   * This is the final call to the ProcessBuilder after all elements have been added.
+   * The {@link Process} is initialized and put in state READY
+   */
+  Process getProcess();
+
+  /**
+   * Add a SequenceFlow with a given name
+   */
+  ProcessBuilder addSequenceFlow(String targetName);
+
+  /**
+   * Add a SartEvent with a given name
+   */
+  ProcessBuilder addStartEvent(String name);
+
+  /**
+   * Add an IntermediateEvent with a given name
+   */
+  ProcessBuilder addEvent(String name);
+
+  /**
+   * Add an EndEvent with a given name
+   */
+  ProcessBuilder addEndEvent(String name);
+
+  /**
+   * Add a Task of {@link TaskType} NONE with a given name
+   */
+  ProcessBuilder addTask(String name);
+
+  /**
+   * Add a Task of {@link TaskType} with a given name
+   */
+  ProcessBuilder addTask(String name, TaskType type);
+
+  /**
+   * Add a Gateway with a given name
+   */
+  ProcessBuilder addGateway(String name, GatewayType type);
+  
+  /**
+   * Add a user defined Node
+   */
+  ProcessBuilder addNode(Node node);
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.api.model.builder;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single incomming {@link SequenceFlow}.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleInFlowSupport
+{
+  /**
+   * Get the incomming SequenceFlow
+   */
+  SequenceFlow getInFlow();
+  
+  /**
+   * Set the incomming SequenceFlow
+   */
+  void setInFlow(SequenceFlow flow);
+}


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.api.model.builder;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single outgoing {@link SequenceFlow}.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleOutFlowSupport
+{
+  /**
+   * Get the outgoing SequenceFlow
+   */
+  SequenceFlow getOutFlow();
+  
+  /**
+   * Set the outgoing SequenceFlow
+   */
+  void setOutFlow(SequenceFlow flow);
+}


Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,41 +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.api.runtime;
-
-//$Id$
-
-
-/**
- * The ProcessEngine invokes the ExecutionHandler on a 
- * Node to execute user provided business logic.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface ExecutionHandler extends Handler
-{
-  /**
-   * Execute the associated business logic.
-   */
-  void execute(Token token);
-
-}
\ No newline at end of file

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,45 +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.api.runtime;
-
-// $Id$
-
-import org.jbpm.api.client.ProcessEngine;
-
-/**
- * The {@link ProcessEngine} invokes the FlowHandler on an {@link HandlerSupport} 
- * {@link Node} to move the {@link Token} to the next {@link Node}.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface FlowHandler extends Handler
-{
-  /**
-   * Execute the FlowHandler.
-   * <p/>
-   * The FlowHandler typically invoves one of the {@link TokenExecutor} 
-   * methods to move the {@link Token} to the next {@link Node}.    
-   */
-  void execute(TokenExecutor tokenExecutor, Token token);
-
-}
\ No newline at end of file

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,37 +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.api.runtime;
-
-import java.io.Serializable;
-
-//$Id$
-
-/**
- * The generic base for handlers that can be associated with a Node.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface Handler extends Serializable
-{
-
-}
\ No newline at end of file

Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,47 +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.api.runtime;
-
-// $Id$
-
-import org.jbpm.api.client.ProcessEngine;
-import org.jbpm.api.model.Signal;
-
-/**
- * The {@link ProcessEngine} invokes the SignalHandler on an {@link HandlerSupport} 
- * {@link Node} to send {@link Signal}s.
- * 
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public interface SignalHandler extends Handler
-{
-  /** 
-   * Get signal for enter 
-   */
-  void throwEnterSignal(Token token);
-
-  /** 
-   * Get signal for exit 
-   */
-  void throwExitSignal(Token token);
-}
\ No newline at end of file

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -31,6 +31,7 @@
 
 import javax.management.ObjectName;
 
+import org.jbpm.api.client.ProcessEngine;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,6 +46,8 @@
   // Provide logging
   final static Logger log = LoggerFactory.getLogger(ProcessService.class);
 
+  // The associated ProcessEngine
+  private ProcessEngine processEngine;
   // The set of registered processes
   private Map<ObjectName, Process> procs = new HashMap<ObjectName, Process>();
 
@@ -53,10 +56,23 @@
   {
   }
 
+  /**
+   * Get the associated ProcessEngine
+   */
+  public ProcessEngine getProcessEngine()
+  {
+    return processEngine;
+  }
+
+  public void setProcessEngine(ProcessEngine processEngine)
+  {
+    this.processEngine = processEngine;
+  }
+  
   /** 
    * Deploy a new process to the process service. 
    */
-  ObjectName deploy(Deployment deployment)
+  public ObjectName deploy(Deployment deployment)
   {
     
     return null;

Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.api.service;
 
-import org.jbpm.api.client.ProcessEngine;
 
 //$Id$
 
@@ -33,8 +32,4 @@
  */
 public interface Service
 {
-  /**
-   * Get the associated ProcessEngine
-   */
-  ProcessEngine getProcessEngine();
 }
\ No newline at end of file

Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,181 @@
+/*
+ * 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.test.cts.processbuilder;
+
+// $Id$
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.Task;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.api.test.CTSTestCase;
+
+/**
+ * Test the ProcessBuilder
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Sep-2008
+ */
+public class ProcessBuilderTest extends CTSTestCase
+{
+  public void testBasicProcess() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    assertNotNull("ProcessBuilder not null", builder);
+
+    builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+    builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+    Process proc = builder.getProcess();
+    assertNotNull("Process not null", proc);
+    assertEquals("Proc", proc.getName());
+
+    StartEvent start = (StartEvent)proc.getNode("Start");
+    Task task = (Task)proc.getNode("Task");
+    EndEvent end = (EndEvent)proc.getNode("End");
+
+    assertNotNull("Start not null", start);
+    assertNotNull("Task not null", task);
+    assertNotNull("End not null", end);
+
+    assertSame(start, proc.getNode(StartEvent.class, "Start"));
+    assertSame(task, proc.getNode(Task.class, "Task"));
+    assertSame(end, proc.getNode(EndEvent.class, "End"));
+
+    SequenceFlow startFlow = start.getOutFlow();
+    assertNotNull("Start flow not null", startFlow);
+    assertEquals("Task", startFlow.getTargetName());
+    assertSame(start, startFlow.getSourceRef());
+    assertSame(task, startFlow.getTargetRef());
+
+    SequenceFlow taskFlow = task.getOutFlow();
+    assertNotNull("Task flow not null", taskFlow);
+    assertEquals("End", taskFlow.getTargetName());
+    assertSame(task, taskFlow.getSourceRef());
+    assertSame(end, taskFlow.getTargetRef());
+  }
+
+  public void testNoProcessName() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    builder.addProcess(null).addStartEvent("Start").addSequenceFlow("Task");
+    builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+    try
+    {
+      builder.getProcess();
+      fail("Process name required");
+    }
+    catch (InvalidProcessException e)
+    {
+      // expected
+    }
+  }
+
+  public void testNoStartName() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    builder.addProcess("Proc").addStartEvent(null).addSequenceFlow("Task");
+    builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+    try
+    {
+      builder.getProcess();
+      fail("StartEvent name required");
+    }
+    catch (InvalidProcessException e)
+    {
+      // expected
+    }
+  }
+
+  public void testNoTaskName() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+    builder.addTask(null).addSequenceFlow("End").addEndEvent("End");
+    try
+    {
+      builder.getProcess();
+      fail("Task name required");
+    }
+    catch (InvalidProcessException e)
+    {
+      // expected
+    }
+  }
+
+  public void testNoEndName() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+    builder.addTask("Task").addSequenceFlow("End").addEndEvent(null);
+    try
+    {
+      builder.getProcess();
+      fail("EndEvent name required");
+    }
+    catch (InvalidProcessException e)
+    {
+      // expected
+    }
+  }
+
+  public void testNoStartEvent() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    builder.addProcess("Proc").addTask("Task").addSequenceFlow("End").addEndEvent("End");
+    try
+    {
+      builder.getProcess();
+      fail("StartEvent required");
+    }
+    catch (InvalidProcessException e)
+    {
+      // expected
+    }
+  }
+
+  public void testNoEndEvent() throws Exception
+  {
+    ProcessEngine engine = ProcessEngine.getProcessEngine();
+    ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+    builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+    builder.addTask("Task");
+    try
+    {
+      builder.getProcess();
+      fail("EndEvent required");
+    }
+    catch (InvalidProcessException e)
+    {
+      // expected
+    }
+  }
+}


Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm4/branches/tdiesler/modules/impl/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/pom.xml	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/impl/pom.xml	2008-09-27 18:27:51 UTC (rev 2408)
@@ -70,7 +70,7 @@
     <dependency>
       <groupId>org.jbpm.jbpm4</groupId>
       <artifactId>jbpm-api</artifactId>
-      <version>1.0.0-SNAPSHOT</version>
+      <version>${version}</version>
     </dependency>
     <dependency>
       <groupId>org.hibernate</groupId>

Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -23,7 +23,10 @@
 
 //$Id$
 
+import java.util.Set;
+
 import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.service.Service;
 
 /**
  * A process engine with public access
@@ -33,5 +36,8 @@
  */
 public class ProcessEngineImpl extends ProcessEngine
 {
-
+  public void setServices(Set<Service> services)
+  {
+    this.services = services;
+  }
 }

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,82 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+
+import org.jboss.util.id.UID;
+import org.jbpm.api.model.AbstractElement;
+import org.jbpm.api.model.Process;
+
+/**
+ * The parrent of all Elements
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at MappedSuperclass
+public abstract class AbstractElementImpl implements AbstractElement
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+
+  // The cached ID
+  protected transient ObjectName id;
+  // The persistent key
+  private transient String key;
+
+  @Id
+  @Column(name = "id")
+  public String getKey()
+  {
+    if (key == null)
+    {
+      key = new UID().toString();
+    }
+    return key;
+  }
+
+  public void setKey(String key)
+  {
+    this.key = key;
+  }
+
+  /**
+   * Get the ID of this element
+   */
+  @Transient
+  public abstract ObjectName getID();
+
+  /**
+   * Called when the process is created
+   */
+  protected void initialize(Process proc)
+  {
+    // nothing to do
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,109 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.model.builder.SingleInFlowSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * As the name implies, the End Event indicates where a Process will end.
+ * 
+ * In terms of Sequence Flow, the End Event ends the flow of the Process, and thus, will not have any outgoing Sequence
+ * Flow. An End Event can have a specific Result that will appear as a marker within the center of the End Event shape.
+ * End Event Results are Message, Error, Compensation, Link, and Multiple.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at Entity
+ at Table(name = "JBPM_END_EVENT")
+public class EndEventImpl extends EventImpl implements EndEvent, SingleInFlowSupport
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+  // provide logging
+  final static Logger log = LoggerFactory.getLogger(EndEventImpl.class);
+
+  private SequenceFlow inFlow;
+  private ResultType resultType = ResultType.None;
+
+  public EndEventImpl(String name)
+  {
+    super(name);
+  }
+
+  // Persistence ctor
+  protected EndEventImpl()
+  {
+  }
+
+  public EventType getEventType()
+  {
+    return EventType.End;
+  }
+
+  public ResultType getResultType()
+  {
+    return resultType;
+  }
+  
+  @Override
+  @Transient
+  public ObjectName getID()
+  {
+    if (id == null)
+    {
+      StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+      str.append("type=EndEvent,name=" + getName() + ",id=" + getKey());
+      id = ObjectNameFactory.create(str.toString());
+    }
+    return id;
+  }
+
+  @Transient
+  public SequenceFlow getInFlow()
+  {
+    return inFlow;
+  }
+
+  public void setInFlow(SequenceFlow inFlow)
+  {
+    this.inFlow = inFlow;
+  }
+
+  public String toString()
+  {
+    return "EndEvent[" + getName() + "]";
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,71 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.Event;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+
+/**
+ * An Event is something that “happens” during the course of a business process. 
+ * <p/> 
+ * These Events affect the flow of the Process and usually have a cause or an impact.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class EventImpl extends NodeImpl implements Event
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+  
+  public EventImpl(String name)
+  {
+    super(name);
+  }
+  
+  // Persistence ctor
+  protected EventImpl()
+  {
+  }
+
+  @Override
+  public ObjectName getID()
+  {
+    if (id == null)
+    {
+      StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+      str.append("type=Event,name=" + getName() + ",id=" + getKey());
+      id = ObjectNameFactory.create(str.toString());
+    }
+    return id;
+  }
+
+  public EventType getEventType()
+  {
+    return EventType.Intermediate;
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,65 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.Gateway;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.SequenceFlow.ConditionType;
+
+/**
+ * A {@link Gate} associated with a {@link Gateway}.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class GateImpl implements Gate
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+  
+  private SequenceFlow seqFlow;
+
+  public GateImpl(String targetName)
+  {
+    seqFlow = new SequenceFlowImpl(targetName);
+  }
+
+  public GateImpl(String targetName, ConditionType type, Expression expr)
+  {
+    seqFlow = new SequenceFlowImpl(targetName, type, expr);
+  }
+
+  public SequenceFlow getOutgoingSequenceFlow()
+  {
+    return seqFlow;
+  }
+  
+  public String toString()
+  {
+    String flowStr = seqFlow.toString();
+    return "Gate" + flowStr.substring(flowStr.indexOf('['));
+  }
+}


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,118 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.Gateway;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.SequenceFlow.ConditionType;
+import org.jbpm.api.model.builder.MultipleInFlowSupport;
+import org.jbpm.api.model.builder.MultipleOutFlowSupport;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+
+/**
+ * Gateways are modelling elements that are used to control how Sequence Flow interact as they converge and diverge
+ * within a Process. If the flow does not need to be controlled, then a Gateway is not needed.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public abstract class GatewayImpl extends NodeImpl implements Gateway, MultipleOutFlowSupport, MultipleInFlowSupport
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+  
+  // The list of incomming flows
+  protected List<SequenceFlow> inFlows = new ArrayList<SequenceFlow>();
+  // The list of outgoing gates
+  private Map<String, Gate> gates = new LinkedHashMap<String, Gate>();
+
+  public GatewayImpl(String name)
+  {
+    super(name);
+  }
+
+  @Override
+  public ObjectName getID()
+  {
+    if (id == null)
+    {
+      StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+      str.append("type=" + getGatewayType() + "Gateway,name=" + getName() + ",id=" + getKey());
+      id = ObjectNameFactory.create(str.toString());
+    }
+    return id;
+  }
+  
+  public List<Gate> getGates()
+  {
+    return Collections.unmodifiableList(new ArrayList<Gate>(gates.values()));
+  }
+
+  public void addGate(Gate gate)
+  {
+    String targetName = gate.getOutgoingSequenceFlow().getTargetName();
+    gates.put(targetName, gate);
+  }
+
+  public List<SequenceFlow> getInFlows()
+  {
+    return Collections.unmodifiableList(inFlows);
+  }
+
+  public void addInFlow(SequenceFlow inFlow)
+  {
+    this.inFlows.add(inFlow);
+  }
+
+  public Gate getDefaultGate()
+  {
+    Gate gate = null;
+    for (Gate aux : gates.values())
+    {
+      SequenceFlow seqFlow = aux.getOutgoingSequenceFlow();
+      if (seqFlow.getConditionType() == ConditionType.Default)
+      {
+        gate = aux;
+        break;
+      }
+    }
+    return gate;
+  }
+
+  public Gate getGateByName(String targetName)
+  {
+    Gate gate = gates.get(targetName);
+    return gate;
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,48 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple incomming {@link SequenceFlow}s.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleInFlowSupport
+{
+  /**
+   * Gat the incomming SequenceFlows
+   */
+  List<SequenceFlow> getInFlows();
+  
+  /**
+   * Add an incomming SequenceFlow
+   */
+  void addInFlow(SequenceFlow flow);
+
+}


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,48 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple outgoing {@link SequenceFlow}s.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleOutFlowSupport
+{
+  /**
+   * Gat the outgoing SequenceFlows
+   */
+  List<SequenceFlow> getOutFlows();
+  
+  /**
+   * Add an outgoing SequenceFlow
+   */
+  void addOutFlow(SequenceFlow flow);
+
+}


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,184 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NameNotUniqueException;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.Gateway;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.builder.MultipleInFlowSupport;
+import org.jbpm.api.model.builder.MultipleOutFlowSupport;
+import org.jbpm.api.model.builder.SingleInFlowSupport;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+
+/**
+ * A Flow Object is one of the set of following graphical objects: Event, Activity, and
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at Entity
+ at Table(name = "JBPM_NODE")
+public abstract class NodeImpl extends AbstractElementImpl implements Node
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+
+  private String name;
+  private Process proc;
+
+  public NodeImpl(String name)
+  {
+    this.name = name;
+  }
+
+  // Persistence ctor
+  protected NodeImpl()
+  {
+  }
+
+  @ManyToOne(targetEntity = ProcessImpl.class)
+  public Process getProcess()
+  {
+    return proc;
+  }
+
+  // Persistence method
+  protected void setProcess(Process proc)
+  {
+    this.proc = proc;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  @Override
+  protected void initialize(Process proc)
+  {
+    super.initialize(proc);
+    
+    // Set the associated process
+    setProcess(proc);
+
+    // Check required name
+    if (name == null)
+      throw new InvalidProcessException("Name is required for: " + this);
+
+    // Check name uniqueness
+    for (Node aux : proc.getNodes())
+    {
+      String auxName = aux.getName();
+      if (aux != this && name.equals(auxName))
+        throw new NameNotUniqueException(toString());
+    }
+
+    // Initialize in/out flows
+    SequenceFlow outFlow = null;
+    if (this instanceof SingleOutFlowSupport)
+    {
+      SingleOutFlowSupport sof = (SingleOutFlowSupport)this;
+      outFlow = sof.getOutFlow();
+      initFlow(proc, (SequenceFlowImpl)outFlow);
+    }
+    else if (this instanceof MultipleOutFlowSupport)
+    {
+      MultipleOutFlowSupport mof = (MultipleOutFlowSupport)this;
+      for (SequenceFlow flow : mof.getOutFlows())
+      {
+        outFlow = flow;
+        initFlow(proc, (SequenceFlowImpl)outFlow);
+      }
+    }
+    else if (this instanceof Gateway)
+    {
+      Gateway gateway = (Gateway)this;
+      for (Gate gate : gateway.getGates())
+      {
+        outFlow = gate.getOutgoingSequenceFlow();
+        initFlow(proc, (SequenceFlowImpl)outFlow);
+      }
+    }
+
+    SequenceFlow inFlow = null;
+    if (this instanceof SingleInFlowSupport)
+    {
+      SingleInFlowSupport sif = (SingleInFlowSupport)this;
+      inFlow = sif.getInFlow();
+    }
+    else if (this instanceof MultipleInFlowSupport)
+    {
+      MultipleInFlowSupport mif = (MultipleInFlowSupport)this;
+      for (SequenceFlow flow : mif.getInFlows())
+      {
+        inFlow = flow;
+      }
+    }
+
+    if (inFlow == null && outFlow == null)
+      throw new InvalidProcessException("Unconnected flow object: " + this);
+  }
+
+  private void initFlow(Process proc, SequenceFlowImpl flow)
+  {
+    if (flow != null)
+    {
+      String name = flow.getTargetName();
+      Node target = proc.getNode(name);
+      if (target == null)
+        throw new InvalidProcessException("Cannot find target for out flow: " + name);
+
+      if (target instanceof SingleInFlowSupport)
+      {
+        SingleInFlowSupport sif = (SingleInFlowSupport)target;
+        sif.setInFlow(flow);
+      }
+      else if (target instanceof MultipleInFlowSupport)
+      {
+        MultipleInFlowSupport mif = (MultipleInFlowSupport)target;
+        mif.addInFlow(flow);
+      }
+      else
+      {
+        throw new InvalidProcessException("Target does not support in flow: " + target);
+      }
+
+      flow.setSourceRef(this);
+      flow.setTargetRef(target);
+    }
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,265 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.management.ObjectName;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.runtime.Attachments;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Process is any Activity performed within a company or organization.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at Entity
+ at Table(name = "JBPM_PROCESS")
+public class ProcessImpl extends AbstractElementImpl implements Process
+{
+  // Provide logging
+  final static Logger log = LoggerFactory.getLogger(ProcessImpl.class);
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+
+  // The required process name
+  private String name;
+  // The list of associated flow objects
+  private List<Node> nodes = new ArrayList<Node>();
+  // the status of the process
+  private ProcessStatus status = ProcessStatus.None;
+  // The possible exception that caused the process to abort
+  private transient RuntimeException runtimeException;
+
+  public ProcessImpl(String name)
+  {
+    this.name = name;
+  }
+
+  // Persistence ctor
+  protected ProcessImpl()
+  {
+  }
+
+  @Override
+  @Transient
+  public ObjectName getID()
+  {
+    if (id == null)
+    {
+      StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+      str.append("type=Process,name=" + getName() + ",id=" + getKey());
+      id = ObjectNameFactory.create(str.toString());
+    }
+    return id;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  @Enumerated(EnumType.STRING)
+  public synchronized ProcessStatus getProcessStatus()
+  {
+    return status;
+  }
+
+  public synchronized void setProcessStatus(ProcessStatus status)
+  {
+    this.status = status;
+  }
+
+  public void addNode(Node node)
+  {
+    nodes.add(node);
+  }
+
+  @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "process", targetEntity = NodeImpl.class)
+  public List<Node> getNodes()
+  {
+    if (status == ProcessStatus.None)
+      return nodes;
+
+    return Collections.unmodifiableList(nodes);
+  }
+
+  // Persistence method
+  protected void setNodes(List<Node> Nodes)
+  {
+    this.nodes = Nodes;
+  }
+
+  public Node getNode(String name)
+  {
+    if (name == null)
+      throw new IllegalArgumentException("Cannot find node with name: null");
+
+    Node Node = null;
+    for (Node aux : nodes)
+    {
+      if (name.equals(aux.getName()))
+      {
+        Node = aux;
+        break;
+      }
+    }
+    return Node;
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T extends Node> List<T> getNodes(Class<T> clazz)
+  {
+    List<T> retNodes = new ArrayList<T>();
+    for (Node node : nodes)
+    {
+      if (clazz.isAssignableFrom(node.getClass()))
+        retNodes.add((T)node);
+    }
+    return retNodes;
+  }
+
+  public <T extends Node> T getNode(Class<T> clazz, String name)
+  {
+    T node = null;
+    for (T aux : getNodes(clazz))
+    {
+      if (aux.getName().equals(name))
+      {
+        node = aux;
+        break;
+      }
+    }
+    return node;
+  }
+  
+  @Override
+  public void initialize(Process proc)
+  {
+    if (status != ProcessStatus.None)
+      throw new IllegalStateException("Cannot initialize process in state: " + status);
+
+    // Initialize the Element
+    super.initialize(this);
+
+    // Check required name
+    if (name == null)
+      throw new InvalidProcessException("Name is required for: " + this);
+    
+    if (getNodes(StartEvent.class).size() == 0)
+      throw new InvalidProcessException("Process does not have a start event");
+
+    if (getNodes(EndEvent.class).size() == 0)
+      throw new InvalidProcessException("Process does not have end events");
+
+    // Initialize the nodes
+    for (Node node : nodes)
+    {
+      NodeImpl nodeImpl = (NodeImpl)node;
+      nodeImpl.initialize(this);
+    }
+
+    status = ProcessStatus.Ready;
+  }
+  
+  // Runtime Aspects ====================================================================================================
+  
+  @Transient
+  public RuntimeException getRuntimeException()
+  {
+    return runtimeException;
+  }
+
+  public void setRuntimeException(RuntimeException rte)
+  {
+    this.runtimeException = rte;
+    setProcessStatus(ProcessStatus.Aborted);
+  }
+
+  public ObjectName startProcess()
+  {
+    return startProcessInternal(null);
+  }
+
+  public ObjectName startProcess(Attachments att)
+  {
+    return startProcessInternal(att);
+  }
+
+  private ObjectName startProcessInternal(Attachments att)
+  {
+    return getID();
+  }
+
+  public ProcessStatus waitForEnd()
+  {
+    return waitForEndInternal(0);
+  }
+
+  public ProcessStatus waitForEnd(long timeout)
+  {
+    return waitForEndInternal(timeout);
+  }
+
+  /**
+   * Wait for the Process to end. All Tokens that are generated at the Start Event for that Process must eventually
+   * arrive at an End Event. The Process will be in a running state until all Tokens are consumed. If the process was
+   * aborted this method throws the causing RuntimeException if avaialable.
+   */
+  private ProcessStatus waitForEndInternal(long timeout)
+  {
+    throw new NotImplementedException();
+  }
+
+  public String toString()
+  {
+    return "Process[" + getName() + ",status=" + getProcessStatus() + "]";
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,142 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.persistence.Transient;
+
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * A Sequence Flow is a solid graphical line that is used to show the order that Activities will be performed in a
+ * Process. Each Flow has only one source and only one target.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class SequenceFlowImpl implements SequenceFlow
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+
+  private ConditionType conditionType = ConditionType.None;
+  private Expression conditionExpression;
+  private String name;
+  private String targetName;
+  private Node source;
+  private Node target;
+
+  public SequenceFlowImpl(String targetName)
+  {
+    this.targetName = targetName;
+  }
+
+  public SequenceFlowImpl(String targetName, ConditionType type, Expression expr)
+  {
+    this.targetName = targetName;
+    this.conditionType = type;
+    this.conditionExpression = expr;
+  }
+
+  // Persistence ctor
+  protected SequenceFlowImpl()
+  {
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  @Transient
+  public Node getSourceRef()
+  {
+    return source;
+  }
+
+  protected void setSourceRef(Node source)
+  {
+    this.source = source;
+  }
+
+  @Transient
+  public Node getTargetRef()
+  {
+    return target;
+  }
+  
+  protected void setTargetRef(Node target)
+  {
+    this.target = target;
+  }
+
+  public String getTargetName()
+  {
+    return targetName;
+  }
+
+  // Persistence method
+  protected void setTargetName(String targetName)
+  {
+    this.targetName = targetName;
+  }
+  
+  public ConditionType getConditionType()
+  {
+    return conditionType;
+  }
+
+  // Persistent method
+  protected void setConditionType(ConditionType conditionType)
+  {
+    this.conditionType = conditionType;
+  }
+
+  public Expression getConditionExpression()
+  {
+    return conditionExpression;
+  }
+
+  public String toString()
+  {
+    Node sourceRef = getSourceRef();
+    Node targetRef = getTargetRef();
+
+    String srcName = null;
+    if (sourceRef != null)
+      srcName = (sourceRef.getName() != null ? sourceRef.getName() : sourceRef.getID().getCanonicalName());
+
+    String tarName = null;
+    if (targetRef != null)
+      tarName = (targetRef.getName() != null ? targetRef.getName() : targetRef.getID().getCanonicalName());
+
+    return "SequenceFlow[" + srcName + "->" + tarName + "]";
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.ri.model;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single incomming {@link SequenceFlow}.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleInFlowSupport
+{
+  /**
+   * Get the incomming SequenceFlow
+   */
+  SequenceFlow getInFlow();
+  
+  /**
+   * Set the incomming SequenceFlow
+   */
+  void setInFlow(SequenceFlow flow);
+}


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.ri.model;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single outgoing {@link SequenceFlow}.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleOutFlowSupport
+{
+  /**
+   * Get the outgoing SequenceFlow
+   */
+  SequenceFlow getOutFlow();
+  
+  /**
+   * Set the outgoing SequenceFlow
+   */
+  void setOutFlow(SequenceFlow flow);
+}


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,112 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Start Event indicates where a particular Process will start. In terms of Sequence Flow, the Start Event starts the
+ * Flow of the Process, and thus, will not have any incoming Sequence Flow. A Start Event can have a Trigger that
+ * indicates how the Process starts: Message, Timer, Rule, Link, or Multiple.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+ at Entity
+ at Table(name = "JBPM_START_EVENT")
+public class StartEventImpl extends EventImpl implements StartEvent, SingleOutFlowSupport
+{
+  // Provide logging
+  final static Logger log = LoggerFactory.getLogger(StartEventImpl.class);
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+
+  private SequenceFlow outFlow;
+  private TriggerType triggerType = TriggerType.None;
+
+  public StartEventImpl(String name)
+  {
+    super(name);
+  }
+
+  // Persistence ctor
+  protected StartEventImpl()
+  {
+  }
+
+  public EventType getEventType()
+  {
+    return EventType.Start;
+  }
+
+  public TriggerType getTriggerType()
+  {
+    return triggerType;
+  }
+  
+  @Override
+  @Transient
+  public ObjectName getID()
+  {
+    if (id == null)
+    {
+      StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+      str.append("type=StartEvent,name=" + getName() + ",id=" + getKey());
+      id = ObjectNameFactory.create(str.toString());
+    }
+    return id;
+  }
+
+  @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = SequenceFlowImpl.class)
+  @JoinColumn
+  public SequenceFlow getOutFlow()
+  {
+    return outFlow;
+  }
+
+  public void setOutFlow(SequenceFlow flow)
+  {
+    this.outFlow = flow;
+  }
+
+  public String toString()
+  {
+    return "StartEvent[" + getName() + "]";
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,105 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.Task;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.model.builder.SingleInFlowSupport;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+
+/**
+ * A Task is an Atomic Activity that is included within a Process.
+ * 
+ * A Task is used when the work in the Process is not broken down to a finer level of Process Model detail. Generally,
+ * an end-user and/or an application are used to perform the Task when it is executed.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class TaskImpl extends NodeImpl implements Task, SingleOutFlowSupport, SingleInFlowSupport
+{
+  // provide serial version UID
+  private static final long serialVersionUID = 1L;
+  
+  private SequenceFlow inFlow;
+  private SequenceFlow outFlow;
+  
+  public TaskImpl(String name)
+  {
+    super(name);
+  }
+
+  // Persistence ctor
+  protected TaskImpl()
+  {
+  }
+
+  public TaskType getTaskType()
+  {
+    return TaskType.None;
+  }
+
+  @Override
+  @Transient
+  public ObjectName getID()
+  {
+    if (id == null)
+    {
+      StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+      str.append("type=" + getTaskType() + "Task,name=" + getName() + ",id=" + getKey());
+      id = ObjectNameFactory.create(str.toString());
+    }
+    return id;
+  }
+  
+  public SequenceFlow getInFlow()
+  {
+    return inFlow;
+  }
+
+  public void setInFlow(SequenceFlow inFlow)
+  {
+    this.inFlow = inFlow;
+  }
+
+  public SequenceFlow getOutFlow()
+  {
+    return outFlow;
+  }
+
+  public void setOutFlow(SequenceFlow outFlow)
+  {
+    this.outFlow = outFlow;
+  }
+
+  public String toString()
+  {
+    return "Task[" + getTaskType() + "," + getName() + "]";
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java	                        (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java	2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,193 @@
+/*
+ * 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.ri.model.builder;
+
+//$Id$
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.api.model.Task.TaskType;
+import org.jbpm.api.model.builder.MultipleOutFlowSupport;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+import org.jbpm.api.service.Service;
+import org.jbpm.ri.model.EndEventImpl;
+import org.jbpm.ri.model.EventImpl;
+import org.jbpm.ri.model.NodeImpl;
+import org.jbpm.ri.model.ProcessImpl;
+import org.jbpm.ri.model.SequenceFlowImpl;
+import org.jbpm.ri.model.StartEventImpl;
+import org.jbpm.ri.model.TaskImpl;
+
+/**
+ * The ProcessBuilder can be used to dynamically build a {@link Process}.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class ProcessBuilderImpl implements ProcessBuilder, Service
+{
+  protected ProcessImpl proc;
+  protected NodeImpl node;
+
+  public ProcessBuilderImpl()
+  {
+  }
+
+  public ProcessBuilder addProcess(String procName)
+  {
+    proc = new ProcessImpl(procName);
+    return this;
+  }
+
+  public Process getProcess()
+  {
+    ProcessImpl procImpl = getProcessInternal();
+    procImpl.initialize(procImpl);
+    return procImpl;
+  }
+
+  public ProcessBuilder addSequenceFlow(String targetName)
+  {
+    if (node instanceof SingleOutFlowSupport)
+    {
+      SingleOutFlowSupport outFlow = (SingleOutFlowSupport)node;
+      outFlow.setOutFlow(new SequenceFlowImpl(targetName));
+    }
+    else if (node instanceof MultipleOutFlowSupport)
+    {
+      MultipleOutFlowSupport outFlow = (MultipleOutFlowSupport)node;
+      outFlow.addOutFlow(new SequenceFlowImpl(targetName));
+    }
+    else
+    {
+      throw new IllegalStateException("Cannot add a sequence flow to: " + node);
+    }
+    return this;
+  }
+
+  public ProcessBuilder addStartEvent(String name)
+  {
+    node = new StartEventImpl(name);
+    return addNode(node);
+  }
+
+  public ProcessBuilder addEvent(String name)
+  {
+    node = new EventImpl(name);
+    return addNode(node);
+  }
+
+  public ProcessBuilder addEndEvent(String name)
+  {
+    node = new EndEventImpl(name);
+    return addNode(node);
+  }
+
+  public ProcessBuilder addTask(String name)
+  {
+    return addTask(name, TaskType.None);
+  }
+
+  public ProcessBuilder addTask(String name, TaskType type)
+  {
+    if (type == TaskType.None || type == null)
+    {
+      node = new TaskImpl(name);
+    }
+    else if (type == TaskType.Service)
+    {
+      throw new NotImplementedException("JBPM-1652", "Task Type Service");
+    }
+    else if (type == TaskType.Receive)
+    {
+      throw new NotImplementedException();
+    }
+    else if (type == TaskType.Send)
+    {
+      throw new NotImplementedException();
+    }
+    else if (type == TaskType.User)
+    {
+      throw new NotImplementedException("JBPM-1653", "Task Type User");
+    }
+    else if (type == TaskType.Script)
+    {
+      throw new NotImplementedException("JBPM-1654", "Task Type Script");
+    }
+    else if (type == TaskType.Manual)
+    {
+      throw new NotImplementedException("JBPM-1655", "Task Type Manual");
+    }
+    else if (type == TaskType.Reference)
+    {
+      throw new NotImplementedException("JBPM-1656", "Task Type Reference");
+    }
+    else
+    {
+      throw new IllegalStateException("Task type: " + type);
+    }
+    return addNode(node);
+  }
+
+  public ProcessBuilder addGateway(String name, GatewayType type)
+  {
+    node = (NodeImpl)getProcessInternal().getNode(name);
+    if (node == null)
+    {
+      if (GatewayType.Exclusive == type)
+      {
+        throw new NotImplementedException();
+      }
+      else if (GatewayType.Inclusive == type)
+      {
+        throw new NotImplementedException();
+      }
+      else if (GatewayType.Parallel == type)
+      {
+        throw new NotImplementedException();
+      }
+      else if (GatewayType.Complex == type)
+      {
+        throw new NotImplementedException();
+      }
+      addNode(node);
+    }
+    return this;
+  }
+
+  public ProcessBuilder addNode(Node node)
+  {
+    getProcessInternal().addNode(node);
+    return this;
+  }
+
+  private ProcessImpl getProcessInternal()
+  {
+    if (proc == null)
+      throw new IllegalStateException("No process available");
+
+    return proc;
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml	2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml	2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,10 +1,19 @@
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
- 
-  <!-- The KernelLocator -->
-  <bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator"/>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+  xmlns="urn:jboss:bean-deployer:2.0">
   
-  <!-- The ProcessEngine -->
-  <bean name="jBPMProcessEngine" class="org.jbpm.ri.client.ProcessEngineImpl">
-  </bean>
-  
-</deployment>
+    <!-- The KernelLocator -->
+    <bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator" />
+
+    <!-- The ProcessEngine -->
+    <bean name="jBPMProcessEngine" class="org.jbpm.ri.client.ProcessEngineImpl">
+      <property name="services">
+        <set elementClass="org.jbpm.api.service.Service">
+          <inject bean="jBPMProcessBuilder" />
+        </set>
+      </property>
+    </bean>
+
+    <!-- The Services -->
+    <bean name="jBPMProcessBuilder" class="org.jbpm.ri.model.builder.ProcessBuilderImpl" />
+
+  </deployment>




More information about the jbpm-commits mailing list