[jbpm-commits] JBoss JBPM SVN: r2040 - in jbpm4/pvm/trunk/modules/core/src: main/java/org/jbpm/pvm/env and 14 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Aug 28 10:17:03 EDT 2008


Author: tom.baeyens at jboss.com
Date: 2008-08-28 10:17:03 -0400 (Thu, 28 Aug 2008)
New Revision: 2040

Added:
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/IdGenerator.java
Removed:
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateKey.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateKeyBinding.java
Modified:
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Deployment.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Execution.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ProcessDefinition.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/env/Environment.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/session/PvmDbSession.java
   jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml
   jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.execution.hbm.xml
   jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java
   jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml
Log:
introduction of the execution keys and ids

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Deployment.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Deployment.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Deployment.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -63,9 +63,6 @@
   protected Map<String, Document> documents;
   
   protected ProcessDefinition processDefinition;
-  /** user provided short reference for the process definition
-   * that can be used by the KeyGenerator */
-  protected String processDefinitionRef;
   
   public Deployment() {
   }
@@ -245,10 +242,4 @@
   public void setName(String name) {
     this.name = name;
   }
-  public String getProcessDefinitionRef() {
-    return processDefinitionRef;
-  }
-  public void setProcessDefinitionRef(String processDefinitionRef) {
-    this.processDefinitionRef = processDefinitionRef;
-  }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Execution.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Execution.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/Execution.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -121,16 +121,19 @@
   
 
   long getDbid();
+  /** the externally given name or id of this execution. The id of a main 
+   * path of execution is null.   Can be used to differentiate concurrent 
+   * paths of execution e.g. the shipping and billing paths.  */
+  String getName();
 
-  /** the meaningful but optional business key that is unique within one 
+  /** the optional user provided business key that is unique within one 
    * process definition.  This could be for instance the order number.  
    * It's a user defined identifier for one execution within the scope of 
    * a single process definition. */
   String getKey();
   
-  /** the name of this execution. The name of a main 
-   * path of execution is null. */
-  String getName();
+  /** a globally unique identifier for this execution. */
+  String getId();
   
   /** represents the current position in the process by indicating the 
    * name of the current node. */

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -76,35 +76,52 @@
   Execution startExecutionInLatest(String processDefinitionName, Map<String, Object> variables, String executionRef);
 
   /** the execution with the given database primary key */
+  // TODO REMOVE
   Execution findExecution(long executionDbid);
 
   /** the execution that is uniquely defined by the process definition and the business key. */
   Execution findExecution(String processDefinitionName, String executionKey);
 
+  /** the execution that is uniquely defined by the process definition and the business key. */
+  Execution findExecution(String executionId);
+
   /** provides an external trigger to an execution. */
+  // TODO REMOVE
   Execution signalExecution(long executionDbid);
   
   /** provides a named external trigger to an execution. */
+  // TODO REMOVE
   Execution signalExecution(long executionDbid, String signalName);
   
   /** provides a named external trigger to an execution with parameters. */
+  // TODO REMOVE
   Execution signalExecution(long executionDbid, String signalName, Map<String, Object> parameters);
 
   /** provides a external trigger to an execution with parameters. */
+  // TODO REMOVE
   Execution signalExecution(long executionDbid, Map<String, Object> parameters);
+
   
-  /** provides an external trigger to an execution. */
-  Execution signalExecution(String processDefinitionName, String executionKey);
-  
   /** provides a named external trigger to an execution. */
   Execution signalExecution(String processDefinitionName, String executionKey, String signalName);
   
   /** provides a named external trigger to an execution with parameters. */
   Execution signalExecution(String processDefinitionName, String executionKey, String signalName, Map<String, Object> parameters);
 
+  
+  /** provides an external trigger to an execution. */
+  Execution signalExecution(String executionId);
+  
+  /** provides a named external trigger to an execution. */
+  Execution signalExecution(String executionId, String signalName);
+   
+  /** provides a named external trigger to an execution with parameters. */
+  Execution signalExecution(String executionId, String signalName, Map<String, Object> parameters);
+
   /** provides a external trigger to an execution with parameters. */
-  Execution signalExecution(String processDefinitionName, String executionKey, Map<String, Object> parameters);
+  Execution signalExecution(String executionId, Map<String, Object> parameters);
   
+
   /** creates or overwrites a variable value on the referenced execution */ 
   Execution setVariable(long executionDbid, String name, Object value);
   

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ProcessDefinition.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ProcessDefinition.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ProcessDefinition.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -32,26 +32,32 @@
  */
 public interface ProcessDefinition extends Serializable {
 
-  /** the unique key for this process definition. */
-  String getKey();
+  /** the optional package name of this process.  This can be used to create 
+   * hierarchy of process categories for easy lookup.   This is a 
+   * similar way of grouping and creating a structure as in Java. 
+   * We recommend the same conventions as with Java package names. */
+  String getPackageName();
 
   /** the short display name given to this process definition. 
    * Multiple process definitions can have the same as long 
    * as they are given a different {@link #version}.  */
   String getName();
 
-  /** the description name given to this process definition. 
-   * Multiple process definitions can have the same */
-  String getDescription();
+  /** the user defined short representation of the name. Just 
+   * like the name, multiple versions of a process definition 
+   * can have the same key. */
+  String getKey();
 
-  /** the package name of this process.  This can be used to create 
-   * hierarchy of process categories for easy lookup.   This is a 
-   * similar way of grouping and creating a structure as in Java. 
-   * We recommend the same conventions as with Java package names. */
-  String getPackageName();
+  /** the unique id for this process definition. */
+  String getId();
 
   /** automatically assigned during deployment of a process that 
    * represents the sequence number for process definitions with 
    * the same {@link ObservableElement#getName() name}. */ 
   int getVersion();
+
+  /** the description name given to this process definition. 
+   * Multiple process definitions can have the same */
+  String getDescription();
+
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/env/Environment.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/env/Environment.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/env/Environment.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -24,7 +24,9 @@
 import java.io.Serializable;
 import java.util.Stack;
 
+import org.jbpm.pvm.PvmException;
 
+
 /**
  * maintains contextual information for a thread in a set of
  * {@link Context}s.
@@ -145,6 +147,7 @@
    */
   public abstract <T> T get(Class<T> type);
 
+  
   /** searches an object based on type.  The search doesn take superclasses of the context elements 
    * into account.
    * @return the first object of the given type or null in case no such element was found.  
@@ -180,7 +183,51 @@
   public static Environment getCurrent() {
     return currentEnvironment.get();
   }
+  
+  public static <T> T getFromCurrent(Class<T> type) {
+    return getFromCurrent(type, true);
+  }
 
+  public static <T> T getFromCurrent(Class<T> type, boolean required) {
+    Environment environment = getCurrent();
+    if (environment==null) {
+      if (required) {
+        throw new PvmException("no environment to get "+type.getName());
+      }
+      return null;
+    }
+    T object = environment.get(type);
+    if (object==null) {
+      if (required) {
+        throw new PvmException("no "+type.getName()+" in current environment");
+      }
+      return null;
+    }
+    return object;
+  }
+
+  public static Object getFromCurrent(String name) {
+    return getFromCurrent(name, true);
+  }
+
+  public static Object getFromCurrent(String name, boolean required) {
+    Environment environment = getCurrent();
+    if (environment==null) {
+      if (required) {
+        throw new PvmException("no environment to get '"+name+"'");
+      }
+      return null;
+    }
+    Object object = environment.get(name);
+    if (object==null) {
+      if (required) {
+        throw new PvmException("no '"+name+"' in current environment");
+      }
+      return null;
+    }
+    return object;
+  }
+
   static Stack<Environment> getStack() {
     // lazy initialize the current environment stack
     Stack<Environment> stack = currentEnvironmentStack.get();

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -35,23 +35,31 @@
   private static final long serialVersionUID = 1L;
   
   protected long executionDbid;
+  protected String executionId;
   protected String processDefinitionName;
-  protected String key;
+  protected String executionKey;
   
-  public FindExecutionCmd(String processDefinitionName, String key) {
+  public FindExecutionCmd(String processDefinitionName, String executionKey) {
     this.processDefinitionName = processDefinitionName;
-    this.key = key;
+    this.executionKey = executionKey;
   }
 
+  // TODO: REMOVE
   public FindExecutionCmd(long executionDbid) {
     this.executionDbid = executionDbid;
   }
 
+  public FindExecutionCmd(String executionId) {
+    this.executionId = executionId;
+  }
+
   public Execution execute(Environment environment) throws Exception {
     PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
-    if (processDefinitionName!=null) {
-      return pvmDbSession.findExecutionByKey(key);
-    } 
+    if (executionId!=null) {
+      return pvmDbSession.findExecutionById(executionId);
+    } else if (processDefinitionName!=null && executionKey!=null){
+      return pvmDbSession.findExecutionByKey(processDefinitionName, executionKey);
+    }
     return pvmDbSession.get(ExecutionImpl.class, executionDbid);
   }
 

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -42,13 +42,15 @@
   protected String executionKey;
   protected String signalName;
   protected Map<String, Object> parameters;
-  
+
+  // TODO REMOVE
   public SignalCmd(long executionDbid, String signalName, Map<String, Object> parameters) {
     this.executionDbid = executionDbid;
     this.signalName = signalName;
     this.parameters = parameters;
   }
 
+  // TODO REMOVE
   public SignalCmd(String processDefinitionName, String executionKey, String signalName, Map<String, Object> parameters) {
     if (processDefinitionName==null) {
       throw new PvmException("processDefinitionName is null");
@@ -61,6 +63,15 @@
     this.parameters = parameters;
   }
 
+  public SignalCmd(String executionKey, String signalName, Map<String, Object> parameters) {
+    if (executionKey==null) {
+      throw new PvmException("executionKey is null");
+    }
+    this.executionKey = executionKey;
+    this.signalName = signalName;
+    this.parameters = parameters;
+  }
+
   public Execution execute(Environment environment) throws Exception {
     ClientExecution execution = null;
     
@@ -71,9 +82,9 @@
         throw new PvmException("execution "+executionDbid+" does not exist");
       }
     } else {
-      execution = pvmDbSession.findExecutionByKey(executionKey);
+      execution = pvmDbSession.findExecutionById(executionKey);
       if (execution==null) {
-        throw new PvmException("execution for process "+processDefinitionName+" with executionKey "+executionKey+" does not exist");
+        throw new PvmException("execution "+executionKey+" does not exist");
       }
     }
     

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -38,11 +38,11 @@
 
   private static final long serialVersionUID = 1L;
   
-  protected String processDefinitionKey;
+  protected String processDefinitionId;
   protected String executionKey;
 
-  public StartExecutionCmd(String processDefinitionKey, Map<String, Object> variables, String executionKey) {
-    this.processDefinitionKey = processDefinitionKey;
+  public StartExecutionCmd(String processDefinitionId, Map<String, Object> variables, String executionKey) {
+    this.processDefinitionId = processDefinitionId;
     this.variables = variables;
     this.executionKey = executionKey;
   }
@@ -52,9 +52,9 @@
 
     ClientProcessDefinition processDefinition = null;
     
-    processDefinition = pvmDbSession.findProcessDefinitionByKey(processDefinitionKey);
+    processDefinition = pvmDbSession.findProcessDefinitionById(processDefinitionId);
     if (processDefinition==null) {
-      throw new PvmException("no process definition with key '"+processDefinitionKey+"'");
+      throw new PvmException("no process definition with key '"+processDefinitionId+"'");
     }
     
     ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
@@ -66,10 +66,10 @@
   }
 
   public String getProcessDefinitionKey() {
-    return processDefinitionKey;
+    return processDefinitionId;
   }
   public void setProcessDefinitionKey(String processDefinitionKey) {
-    this.processDefinitionKey = processDefinitionKey;
+    this.processDefinitionId = processDefinitionKey;
   }
   public String getExecutionKey() {
     return executionKey;

Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java (from rev 1997, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateKey.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -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.pvm.internal.deploy;
+
+import org.jbpm.pvm.Deployment;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateId implements Deployer {
+
+  public void deploy(Deployment deployment) {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) deployment.getProcessDefinition();
+    
+    String key = processDefinition.getKey();
+    if (key==null) {
+      key = processDefinition.getName();
+    }
+    
+    // replace any non-word character with an underscore
+    key = key.replaceAll("\\W", "_");
+
+    String id = key+":"+processDefinition.getVersion();
+    
+    processDefinition.setId(id);
+  }
+}


Property changes on: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateId.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateKey.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateKey.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/deploy/CreateKey.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -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.pvm.internal.deploy;
-
-import org.jbpm.pvm.Deployment;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class CreateKey implements Deployer {
-
-  public void deploy(Deployment deployment) {
-    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) deployment.getProcessDefinition();
-    
-    String ref = deployment.getProcessDefinitionRef();
-    if (ref==null) {
-      ref = processDefinition.getName();
-    }
-
-    String key = ref+"-"+processDefinition.getVersion();
-    
-    processDefinition.setKey(key);
-  }
-}

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -70,19 +70,28 @@
     return processDefinition;
   }
 
-  public ClientProcessDefinition findProcessDefinitionByKey(String processDefinitionKey) {
+  public ClientProcessDefinition findProcessDefinitionById(String processDefinitionId) {
     // query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.definition.hbm.xml
-    Query query = session.getNamedQuery("findProcessDefinitionsByKey");
-    query.setString("key", processDefinitionKey);
+    Query query = session.getNamedQuery("findProcessDefinitionsById");
+    query.setString("id", processDefinitionId);
     query.setMaxResults(1);
     ClientProcessDefinition processDefinition = (ClientProcessDefinition) query.uniqueResult();
     return processDefinition;
   }
 
-  public ClientExecution findExecutionByKey(String executionKey) {
+  public ClientExecution findExecutionById(String executionId) {
     // query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.execution.hbm.xml
+    Query query = session.getNamedQuery("findExecutionById");
+    query.setString("id", executionId);
+    query.setMaxResults(1);
+    return (ClientExecution) query.uniqueResult();
+  }
+
+  public Execution findExecutionByKey(String processDefinitionName, String executionKey) {
+    // query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.execution.hbm.xml
     Query query = session.getNamedQuery("findExecutionByKey");
-    query.setString("key", executionKey);
+    query.setString("processDefinitionName", processDefinitionName);
+    query.setString("executionKey", executionKey);
     query.setMaxResults(1);
     return (ClientExecution) query.uniqueResult();
   }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -55,7 +55,7 @@
             log.trace("taking jobs from queue");
             Collection<Long> jobDbids = null;
             jobDbids = queue.take();
-            log.debug("took jobImpl(s) "+jobDbids+" from queue");
+            log.debug("took job(s) "+jobDbids+" from queue");
 
             for (Long jobDbid: jobDbids) {
               CommandService commandService = jobExecutor.getCommandExecutor();
@@ -64,7 +64,7 @@
           } catch (InterruptedException e) {
             log.trace("waiting for acquired jobs got interrupted");
           } catch (Exception e) {
-            log.error("exception in jobImpl executor thread", e);
+            log.error("exception in job executor thread", e);
           }
         }
       }

Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.ProcessDefinition;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.model.IdGenerator;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DefaultIdGenerator implements IdGenerator {
+
+  public String createId(ProcessDefinition processDefinition, Execution parent, Execution execution) {
+
+    String base = null;
+    if (parent!=null) {
+      base = parent.getId(); 
+    } else {
+      base = processDefinition.getId();
+    }
+
+    String executionPart = null;
+    if (execution.getKey()!=null) {
+      executionPart = execution.getKey();
+    
+    } else if (execution.getName()!=null) {
+      executionPart = execution.getName();
+
+    } else {
+      ExecutionImpl executionImpl = (ExecutionImpl) execution;
+      Session session = Environment.getFromCurrent(Session.class);
+      session.save(executionImpl);
+      executionPart = Long.toString(executionImpl.getDbid());
+    }
+
+    return base+"/"+executionPart;
+  }
+
+}

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -65,6 +65,7 @@
 import org.jbpm.pvm.listener.EventListenerExecution;
 import org.jbpm.pvm.model.Comment;
 import org.jbpm.pvm.model.Event;
+import org.jbpm.pvm.model.IdGenerator;
 import org.jbpm.pvm.model.Node;
 import org.jbpm.pvm.model.ObservableElement;
 import org.jbpm.pvm.model.OpenExecution;
@@ -95,9 +96,18 @@
   protected long dbid;
   protected int dbversion;
 
+  /** an optional name for this execution.  can be used to 
+   * differentiate concurrent paths of execution like e.g. 
+   * the 'shipping' and 'billing' paths. */
+  protected String name;
+
+  /** a key for this execution. typically this is an externally provided reference 
+   * that is unique within the scope of the process definition.  */
   protected String key;
-  protected String name;
-  
+
+  /** a unique id for this execution. */
+  protected String id;
+
   /** @see Execution */  
   protected String state;
 
@@ -183,8 +193,13 @@
     this.processDefinition = processDefinition;
     this.node = (NodeImpl) processDefinition.getInitial();
     this.processInstance = this;
+    this.state = STATE_CREATED;
     this.key = key;
-    this.state = STATE_CREATED;
+
+    IdGenerator keyGenerator = Environment.getFromCurrent(IdGenerator.class, false);
+    if (keyGenerator!=null) {
+      this.id = keyGenerator.createId(processDefinition, null, this);
+    }
   }
 
   // execution method : start /////////////////////////////////////////////////
@@ -1155,7 +1170,7 @@
   }
 
   public Execution createExecution(String name, Execution parent) {
-    throw new UnsupportedOperationException();
+    return ((ExecutionImpl)parent).createExecution(name);
   }
 
   /** @see Execution#createProcessInstance(String) */
@@ -1179,6 +1194,12 @@
     addExecution(childExecution);
     // invalidate the cached executionsMap
     executionsMap = null;
+    
+    IdGenerator keyGenerator = Environment.getFromCurrent(IdGenerator.class, false);
+    if (keyGenerator!=null) {
+      childExecution.id = keyGenerator.createId(processDefinition, this, childExecution);
+    }
+    
     return childExecution;
   }
 
@@ -1465,4 +1486,10 @@
   public void setKey(String key) {
     this.key = key;
   }
+  public String getId() {
+    return id;
+  }
+  public void setId(String id) {
+    this.id = id;
+  }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -43,13 +43,19 @@
   private static final long serialVersionUID = 1L;
   private static final Log log = Log.getLog(ProcessDefinitionImpl.class.getName());
 
+  /** user provided short reference for the process definition that 
+   * has the same scope as the name.  Multiple versions of the same 
+   * process can have the same key. The key is used to build the 
+   * globally unique execution ids. */
+  protected String key;
+  
+  /** the unique id (e.g. combination of name and versionnumber) for this 
+   * process definition. */
+  protected String id;
+
   /** the version number of the process definitions with the same name.*/
   protected int version;
   
-  /** the unique key (e.g. combination of name and versionnumber) for this 
-   * process definition that is exposed to the users. */
-  protected String key;
-  
   /** optional package name similar to the Java package name. */
   protected String packageName;
   
@@ -179,4 +185,10 @@
   public void setKey(String key) {
     this.key = key;
   }
+  public String getId() {
+    return id;
+  }
+  public void setId(String id) {
+    this.id = id;
+  }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -45,20 +45,20 @@
 
   protected CommandService commandService;
 
-  public Execution startExecution(String processDefinitionKey){
-    return commandService.execute(new StartExecutionCmd(processDefinitionKey, null, null));
+  public Execution startExecution(String processDefinitionId){
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, null, null));
   }
 
-  public Execution startExecution(String processDefinitionKey, String executionKey) {
-    return commandService.execute(new StartExecutionCmd(processDefinitionKey, null, executionKey));
+  public Execution startExecution(String processDefinitionId, String executionKey) {
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, null, executionKey));
   }
 
-  public Execution startExecution(String processDefinitionKey, Map<String, Object> variables){
-    return commandService.execute(new StartExecutionCmd(processDefinitionKey, variables, null));
+  public Execution startExecution(String processDefinitionId, Map<String, Object> variables){
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, null));
   }
 
-  public Execution startExecution(String processDefinitionKey, Map<String, Object> variables, String executionKey){
-    return commandService.execute(new StartExecutionCmd(processDefinitionKey, variables, executionKey));
+  public Execution startExecution(String processDefinitionId, Map<String, Object> variables, String executionKey){
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, executionKey));
   }
 
   public Execution startExecutionInLatest(String processDefinitionName) {
@@ -76,7 +76,17 @@
   public Execution startExecutionInLatest(String processDefinitionName, Map<String, Object> variables, String executionKey){
     return commandService.execute(new StartExecutionInLatestCmd(processDefinitionName, variables, executionKey));
   }
+
   
+  public Execution signalExecution(String executionId) {
+    return null;
+  }
+
+  public Execution signalExecution(String executionId, Map<String, Object> parameters) {
+    return null;
+  }
+
+  
   public Execution signalExecution(long executionDbid) {
     return commandService.execute(new SignalCmd(executionDbid, null, null));
   }
@@ -132,6 +142,10 @@
   public Execution findExecution(String processDefinitionName, String key) {
     return commandService.execute(new FindExecutionCmd(processDefinitionName, key));
   }
+  
+  public Execution findExecution(String executionId) {
+    return commandService.execute(new FindExecutionCmd(executionId));
+  }
 
   public Object getVariable(long executionDbid, String variableName) {
     return commandService.execute(new GetVariableCmd(executionDbid, variableName));

Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java (from rev 1997, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateKeyBinding.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.deploy.CreateId;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateIdBinding extends WireDescriptorBinding {
+
+  public CreateIdBinding() {
+    super("create-id");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ObjectDescriptor(CreateId.class);
+  }
+
+}


Property changes on: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateIdBinding.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateKeyBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateKeyBinding.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/CreateKeyBinding.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire.binding;
-
-import org.jbpm.pvm.internal.deploy.CreateKey;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class CreateKeyBinding extends WireDescriptorBinding {
-
-  public CreateKeyBinding() {
-    super("create-key");
-  }
-
-  public Object parse(Element element, Parse parse, Parser parser) {
-    return new ObjectDescriptor(CreateKey.class);
-  }
-
-}

Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.model.DefaultIdGenerator;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdGeneratorBinding extends WireDescriptorBinding {
+
+  public IdGeneratorBinding() {
+    super("id-generator");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ObjectDescriptor(DefaultIdGenerator.class);
+  }
+
+}

Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/IdGenerator.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/IdGenerator.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/IdGenerator.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -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.pvm.model;
+
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.ProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface IdGenerator {
+
+  /** generates a unique id for the given execution. */
+  String createId(ProcessDefinition processDefinition, Execution parent, Execution execution);
+
+}

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/session/PvmDbSession.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/session/PvmDbSession.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/session/PvmDbSession.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -23,6 +23,7 @@
 
 import java.util.List;
 
+import org.jbpm.pvm.Execution;
 import org.jbpm.pvm.client.ClientExecution;
 import org.jbpm.pvm.client.ClientProcessDefinition;
 import org.jbpm.pvm.job.Job;
@@ -46,19 +47,24 @@
   /** latest version of the processDefinition with the given name. */
   ClientProcessDefinition findLatestProcessDefinitionByName(String name);
 
-  /** the process definition uniquely identified by the given processDefinitionKey. */
-  ClientProcessDefinition findProcessDefinitionByKey(String processDefinitionKey);
+  /** the process definition uniquely identified by the given 
+   * processDefinition id. */
+  ClientProcessDefinition findProcessDefinitionById(String processDefinitionId);
 
   /** the execution uniquely identified by the given executionKey. */ 
-  ClientExecution findExecutionByKey(String executionKey);
+  ClientExecution findExecutionById(String executionId);
 
+  /** the execution uniquely identified by the given processDefinition name 
+   * and the execution key. */
+  Execution findExecutionByKey(String processDefinitionName, String executionKey);
+
   /** timers */
   List<Timer> findTimers();
   
   /** timers */
   List<Message> findMessages();
   
-  /** the jobs for which all the retries have failed and which will not be picked up 
-   * any more by the jobImpl executor */
+  /** the jobs for which all the retries have failed and which will not be 
+   * picked up any more by the jobImpl executor */
   public List<Job> findDeadJobs();
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml	2008-08-28 14:17:03 UTC (rev 2040)
@@ -60,7 +60,8 @@
     </set>
 
     <!-- ProcessDefinitionImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
-    <property name="key" column="KEY_" unique="true" />
+    <property name="key" column="KEY_" />
+    <property name="id" column="ID_" unique="true" />
 
     <property name="packageName" column="PACKAGE_" />
     <property name="version" column="VERSION_" />
@@ -408,11 +409,11 @@
     ]]>
   </query>
   
-  <query name="findProcessDefinitionsByKey">
+  <query name="findProcessDefinitionsById">
     <![CDATA[
      select process
      from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
-     where process.key = :key
+     where process.id = :id
     ]]>
   </query>
   

Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.execution.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.execution.hbm.xml	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.execution.hbm.xml	2008-08-28 14:17:03 UTC (rev 2040)
@@ -37,8 +37,10 @@
       <one-to-many class="org.jbpm.pvm.internal.job.TimerImpl" />
     </set>
 
+    <property name="name" column="NAME_" />
     <property name="key" column="KEY_" />
-    <property name="name" column="NAME_" />
+    <property name="id" column="ID_" unique="true" />
+
     <property name="state" column="STATE_" />
 
     <property name="priority" column="PRIORITY_" />
@@ -114,11 +116,20 @@
 
   <!-- ### QUERIES ######################################################## -->
 
+  <query name="findExecutionById">
+    <![CDATA[
+     select execution
+     from org.jbpm.pvm.internal.model.ExecutionImpl as execution
+     where execution.id = :id
+    ]]>
+  </query>
+
   <query name="findExecutionByKey">
     <![CDATA[
      select execution
      from org.jbpm.pvm.internal.model.ExecutionImpl as execution
-     where execution.key = :key    
+     where execution.key = :executionKey
+       and execution.processDefinition.name = :processDefinitionName
     ]]>
   </query>
 

Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml	2008-08-28 14:17:03 UTC (rev 2040)
@@ -36,6 +36,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JobTestHelperBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.ScriptManagerBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
   <!-- hibernate bindings -->
   <binding class="org.jbpm.pvm.internal.wire.binding.HibernateConfigurationBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.SeamHibernateSessionBinding" />
@@ -60,7 +61,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.CreateProcessBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.VerifyVersionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.SaveProcessBinding" />
-  <binding class="org.jbpm.pvm.internal.wire.binding.CreateKeyBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CreateIdBinding" />
 
   <!-- ############################ -->
   <!-- ### Interceptor bindings ### -->

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -85,15 +85,15 @@
     processDefinition.setName("nuclear fusion");
     processDefinition.setVersion(1);
     Deployment deployment = new Deployment(processDefinition);
-    deployment.setProcessDefinitionRef("NCLFU");
+    processDefinition.setKey("NCLFU");
     processService.deploy(deployment);
     
     ProcessDefinition deployed = processService.findProcessDefinition("nuclear fusion", 1);
-    String processDefinitionKey = deployed.getKey();
+    String processDefinitionId = deployed.getId();
 
     ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
 
-    Execution execution = executionService.startExecution(processDefinitionKey);
+    Execution execution = executionService.startExecution(processDefinitionId);
     assertNotNull(execution);
 
     // TODO fix after refactoring
@@ -131,7 +131,7 @@
     processService.deploy(new Deployment(processDefinition));
 
     ProcessDefinition deployed = processService.findProcessDefinition("nuclear fusion", 1);
-    String processDefinitionKey = deployed.getKey();
+    String processDefinitionId = deployed.getId();
 
     Map<String, Object> variables = new HashMap<String, Object>();
     variables.put("a", new Integer(1));
@@ -139,7 +139,7 @@
 
     ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
 
-    Execution execution = executionService.startExecution(processDefinitionKey, variables);
+    Execution execution = executionService.startExecution(processDefinitionId, variables);
 
     long executionDbid = execution.getDbid();
     assertEquals(new Integer(1), executionService.getVariable(executionDbid, "a"));
@@ -150,34 +150,34 @@
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
     ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
+    processDefinition.setName("NuclearFusion");
     processDefinition.setVersion(1);
     processService.deploy(new Deployment(processDefinition));
     
     ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
 
-    executionService.startExecutionInLatest("nuclear fusion", null, "the first time");
-    
-    assertNotNull(executionService.findExecution("nuclear fusion", "the first time"));
+    Execution execution = executionService.startExecutionInLatest("NuclearFusion", "TheFirstTime");
+    assertEquals("NuclearFusion:1/TheFirstTime", execution.getId());
+    assertNotNull(executionService.findExecution("NuclearFusion:1/TheFirstTime"));
   }
   
   public void testStartExecutionByDbidWithKey() {
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
     ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
+    processDefinition.setName("NuclearFusion");
     processDefinition.setVersion(1);
     Deployment deployment = new Deployment(processDefinition);
     processService.deploy(deployment);
 
-    ProcessDefinition deployed = processService.findProcessDefinition("nuclear fusion", 1);
-    String processDefinitionKey = deployed.getKey();
+    ProcessDefinition deployed = processService.findProcessDefinition("NuclearFusion", 1);
+    String processDefinitionId = deployed.getId();
 
     ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
 
-    executionService.startExecution(processDefinitionKey, null, "the first time");
+    executionService.startExecution(processDefinitionId, null, "the first time");
 
-    assertNotNull(executionService.findExecution("nuclear fusion", "the first time"));
+    assertNotNull(executionService.findExecution("NuclearFusion", "the first time"));
   }
 
   public void testFindExecution() {

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -30,6 +30,10 @@
 import java.util.TimerTask;
 
 import org.hibernate.Session;
+import org.jbpm.pvm.Deployment;
+import org.jbpm.pvm.ProcessService;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
 import org.jbpm.pvm.client.ClientProcessDefinition;
 import org.jbpm.pvm.client.ClientProcessInstance;
 import org.jbpm.pvm.env.Environment;
@@ -40,6 +44,7 @@
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.job.Job;
 import org.jbpm.pvm.model.Comment;
+import org.jbpm.pvm.model.ProcessFactory;
 import org.jbpm.pvm.session.MessageSession;
 import org.jbpm.pvm.session.PvmDbSession;
 import org.jbpm.pvm.test.base.DbTestCase;
@@ -81,7 +86,7 @@
     }
 
     for (int i=0; i<nbrOfTestMessages; i++) {
-      assertTrue("message "+i+" is not processed", processedMessageIds.contains(i));
+      assertTrue("message "+i+" is not processed: "+processedMessageIds, processedMessageIds.contains(i));
     }
   }
 
@@ -237,27 +242,48 @@
     });
   }
   // helper methods ///////////////////////////////////////////////////////////
+  
+  public static class InsertMessageCmd implements Command<Object> {
+    private static final long serialVersionUID = 1L;
+    int i;
+    public InsertMessageCmd(int i) {
+      this.i = i;
+    }
+    public Object execute(Environment environment) throws Exception {
+      MessageSession messageSession = environment.get(MessageSession.class);
+      CommandMessage commandMessage = TestMessageCommand.createMessage(i);
+      messageSession.send(commandMessage);
+      return null;
+    }
+  }
 
   void insertTestMessages() {
-    commandService.execute(new Command<Object>() {
-      public Object execute(Environment environment) throws Exception {
-        MessageSession messageSession = environment.get(MessageSession.class);
-        for (int i=0; i<nbrOfTestMessages; i++) {
-          CommandMessage commandMessage = TestMessageCommand.createMessage(i);
-          messageSession.send(commandMessage);
-        }
-        return null;
-      }
-    });
+    for (int i=0; i<nbrOfTestMessages; i++) {
+      commandService.execute(new InsertMessageCmd(i));
+    }
   }
+  
+  public static class WaitState implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      execution.take(signalName);
+    }
+  }
 
   void insertExclusiveTestMessages() {
     commandService.execute(new Command<Object>() {
       public Object execute(Environment environment) throws Exception {
+        ClientProcessDefinition processDefinition = ProcessFactory.build("excl")
+          .node("initial").initial().behaviour(WaitState.class)
+        .done();
+        Deployment deployment = new Deployment(processDefinition);
+        ProcessService processService = environment.get(ProcessService.class);
+        processService.deploy(deployment);
+        
         PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
-        ClientProcessDefinition processDefinition = new ProcessDefinitionImpl();
-        pvmDbSession.save(processDefinition);
-        
         MessageSession messageSession = environment.get(MessageSession.class);
         for (int i=0; i<nbrOfTestExecutions; i++) {
           ClientProcessInstance execution = processDefinition.beginProcessInstance("execution-"+i);
@@ -274,17 +300,25 @@
     Environment environment = getEnvironmentFactory().openEnvironment();
   }
 
+  
+  public static class InsertFailOnceTestMsgCmd implements Command<Object> {
+    private static final long serialVersionUID = 1L;
+    int i;
+    public InsertFailOnceTestMsgCmd(int i) {
+      this.i = i;
+    }
+    public Object execute(Environment environment) throws Exception {
+      MessageSession messageSession = environment.get(MessageSession.class);
+      CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
+      messageSession.send(commandMessage);
+      return null;
+    }
+  }
+  
   void insertFailOnceTestMessages() {
-    commandService.execute(new Command<Object>() {
-      public Object execute(Environment environment) throws Exception {
-        MessageSession messageSession = environment.get(MessageSession.class);
-        for (int i=0; i<nbrOfTestMessages; i++) {
-          CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
-          messageSession.send(commandMessage);
-        }
-        return null;
-      }
-    });
+    for (int i=0; i<nbrOfTestMessages; i++) {
+      commandService.execute(new InsertFailOnceTestMsgCmd(i));
+    }
   }
 
   private void waitTillNoMoreMessages(JobExecutor jobExecutor) {
@@ -328,6 +362,12 @@
         }
         return false;
       }
-    });
+
+
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+    }
+
+    public void execute(ActivityExecution execution) throws Exception {
+    }    });
   }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java	2008-08-28 14:17:03 UTC (rev 2040)
@@ -60,15 +60,15 @@
 
     ExecutionService executionService = ExamplesConfiguration.getExecutionService();
     
-    Execution execution = executionService.startExecutionInLatest("basic", "one");
+    Execution execution = executionService.startExecutionInLatest("basic-1/one");
 
     assertEquals("a", execution.getNodeName());
 
-    execution = executionService.signalExecution("basic", "one");
+    execution = executionService.signalExecution("basic-1/one");
 
     assertEquals("b", execution.getNodeName());
 
-    execution = executionService.signalExecution("basic", "one");
+    execution = executionService.signalExecution("basic-1/one");
 
     assertEquals("e", execution.getNodeName());
   }

Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml	2008-08-28 10:31:07 UTC (rev 2039)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml	2008-08-28 14:17:03 UTC (rev 2040)
@@ -7,7 +7,7 @@
     <deployer-manager resource="pvm.language.deployers.xml">
       <language name="api">
         <verify-version />
-        <create-key />
+        <create-id />
         <save-process />
       </language>
     </deployer-manager>
@@ -22,8 +22,6 @@
       <standard-transaction-interceptor />
     </command-service>
     
-    <job-executor threads="1" auto-start="false" />
-  
     <hibernate-configuration>
       <properties resource="hibernate.properties" />
       <mappings resource="org/jbpm/pvm/pvm.hibernate.mappings.xml" />
@@ -32,8 +30,12 @@
     
     <hibernate-session-factory />
     
+    <id-generator />
+    
     <variable-types resource="org/jbpm/pvm/pvm.types.xml" />
 
+    <job-executor auto-start="false" />
+  
   </environment-factory>
 
   <environment>




More information about the jbpm-commits mailing list