[jbpm-commits] JBoss JBPM SVN: r6435 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/history and 36 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jun 24 02:06:30 EDT 2010


Author: alex.guizar at jboss.com
Date: 2010-06-24 02:06:27 -0400 (Thu, 24 Jun 2010)
New Revision: 6435

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/CollectionUtil.java
Removed:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/goup/
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/job/Job.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
   jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryDetailQueryCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteJobCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetStartActivityNamesCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskVariableNamesCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JstlFunction.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentFactory.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/TaskContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/StartProcessTimer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/BshScriptEngine.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/GroovyScriptEngine.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/JuelScriptEngine.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptContextEngineView.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/XPathScriptEngine.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializeInterceptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransaction.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/startevent/TimerStartEventTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java
Log:
JBPM-2893: remove type parameter from JobImpl
fix many raw type warnings

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -37,7 +37,7 @@
 public interface JobQuery {
 
   /** duedate property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
-  public static final String PROPERTY_DUEDATE = "duedate";
+  public static final String PROPERTY_DUEDATE = "dueDate";
   /** state property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
   public static final String PROPERTY_STATE = "state";
   

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -40,5 +40,5 @@
   String getMessage();
 
   /** threaded replies to this comment */
-  List<HistoryComment> getReplies();
+  List<? extends HistoryComment> getReplies();
 }
\ No newline at end of file

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/job/Job.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/job/Job.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/job/Job.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -42,7 +42,8 @@
   Date getDueDate();
 
   /** in case this is a timer, it is the time that the timer should fire, in case this 
-   * is a message, it is null. */
+   * is a message, it is null.
+   * @deprecated call {@link #getDueDate()} instead */
   @Deprecated
   Date getDuedate();
 

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml	2010-06-24 06:06:27 UTC (rev 6435)
@@ -3,13 +3,13 @@
 <process name="InlineMail" xmlns="http://jbpm.org/4.3/jpdl">
 
   <start g="20,25,80,40">
-    <transition to="send rectify note" />
+    <transition to="send rectify note"/>
   </start>
 
-  <mail name="send rectify note" language="juel" g="99,25,115,45">
-    <to addresses="winston at minitrue" />
-    <cc users="bb" groups="innerparty" />
-    <bcc groups="thinkpol" />
+  <mail g="99,25,115,45" language="juel" name="send rectify note">
+    <to addresses="winston at minitrue"/>
+    <cc groups="innerparty" users="bb"/>
+    <bcc groups="thinkpol"/>
     <subject>rectify ${newspaper}</subject>
     <text>${newspaper} ${date} reporting bb dayorder doubleplusungood
       refs unpersons rewrite fullwise upsub antefiling</text>
@@ -24,9 +24,9 @@
       <attachment file='${user.home}/.face' />
     </attachments>
     -->
-    <transition to="end" />
+    <transition to="wait"/>
   </mail>
 
-  <state name="end" g="240,25,98,45"/>
+  <state g="240,25,98,45" name="wait"/>
 
 </process>
\ No newline at end of file

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml	2010-06-24 06:06:27 UTC (rev 6435)
@@ -1,17 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<process name="TemplateMail" xmlns="http://jbpm.org/4.3/jpdl">
-
-  <start g="20,25,80,40">
-    <transition to="send rectify note"/>
-  </start>
-
-  <mail name="send rectify note" 
-        template="rectify-template" 
-        g="99,25,115,45">
-    <transition to="end"/>
-  </mail>
-
-  <state name="end" g="240,25,98,45"/>
-
+<process name="TemplateMail" xmlns="http://jbpm.org/4.3/jpdl">
+
+  <start g="20,25,80,40">
+    <transition to="send rectify note"/>
+  </start>
+
+  <mail g="99,25,115,45" name="send rectify note" template="rectify-template">
+    <transition to="wait"/>
+  </mail>
+
+  <state g="240,25,98,45" name="wait"/>
+
 </process>
\ No newline at end of file

Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -1,6 +1,7 @@
 package org.jbpm.integration.console;
 
 import javax.naming.InitialContext;
+import javax.naming.NamingException;
 
 import org.jbpm.api.Configuration;
 import org.jbpm.api.ProcessEngine;
@@ -13,25 +14,27 @@
 public final class ProcessEngineUtil {
 
   private static ProcessEngine processEngine;
-  
-  private static final String PROCESS_ENGINE_JNDI_NAME = "java:/ProcessEngine";
 
+  private static final String PROCESS_ENGINE_JNDI_NAME = "java:ProcessEngine";
+
   public static ProcessEngine retrieveProcessEngine() {
     if (processEngine == null) {
       synchronized (ProcessEngine.class) {
-        
         if (processEngine == null) {
-          
           try {
             InitialContext ctx = new InitialContext();
-            processEngine = (ProcessEngine) ctx.lookup(PROCESS_ENGINE_JNDI_NAME);
-          } catch (Exception e) {
-            // Fall back to default mechanism which build a procEngine from a default jbpm.cfg.xml
+            try {
+              processEngine = (ProcessEngine) ctx.lookup(PROCESS_ENGINE_JNDI_NAME);
+            }
+            finally {
+              ctx.close();
+            }
+          }
+          catch (NamingException e) {
+            // build a process engine from a default jbpm.cfg.xml
             processEngine = Configuration.getProcessEngine();
           }
-          
         }
-        
       }
     }
     return processEngine;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,9 +23,10 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.zip.ZipInputStream;
 
@@ -42,10 +43,9 @@
  */
 public class JbpmDeployTask extends MatchingTask {
 
-  String jbpmCfg = null;
-  File file = null;
-  List fileSets = new ArrayList();
-  boolean failOnError = true;
+  private String jbpmCfg;
+  private File file;
+  private List<FileSet> fileSets = new ArrayList<FileSet>();
 
   public void execute() throws BuildException {
     Thread currentThread = Thread.currentThread();
@@ -54,31 +54,30 @@
     try {
       // get the ProcessEngineImpl
       ProcessEngine processEngine = AntHelper.getProcessEngine(jbpmCfg);
-      
+
       // if attribute process is set, deploy that process file
-      if (file!=null) {
+      if (file != null) {
         deployFile(processEngine, file);
       }
-      
+
       // loop over all files that are specified in the filesets
-      Iterator iter = fileSets.iterator();
-      while (iter.hasNext()) {
-        FileSet fileSet = (FileSet) iter.next();
+      for (FileSet fileSet : fileSets) {
         DirectoryScanner dirScanner = fileSet.getDirectoryScanner(getProject());
         File baseDir = dirScanner.getBasedir();
-        String[] includedFiles = dirScanner.getIncludedFiles();
-        List excludedFiles = Arrays.asList(dirScanner.getExcludedFiles());
 
-        for (int i = 0; i < includedFiles.length; i++) {
-          String fileName = includedFiles[i];
-          if (!excludedFiles.contains(fileName)) {
+        String[] excludedFiles = dirScanner.getExcludedFiles();
+        // sort excluded files in preparation for binary search
+        Arrays.sort(excludedFiles);
+
+        for (String fileName : dirScanner.getIncludedFiles()) {
+          if (Arrays.binarySearch(excludedFiles, fileName) < 0) {
             File file = new File(baseDir, fileName);
             deployFile(processEngine, file);
           }
         }
       }
-      
-    } finally {
+    }
+    finally {
       currentThread.setContextClassLoader(originalClassLoader);
     }
   }
@@ -88,30 +87,32 @@
     NewDeployment deployment = repositoryService.createDeployment();
     deployment.setName(processFile.getName());
     deployment.setTimestamp(System.currentTimeMillis());
-    
-    if (processFile.getName().endsWith(".xml")) {
-      log("deploying process file "+processFile.getName());
+
+    String contentType = URLConnection.guessContentTypeFromName(processFile.getName());
+    if (contentType.contains("xml")) {
+      log("deploying process file " + processFile.getName());
       deployment.addResourceFromFile(processFile);
-      
-    } else if (processFile.getName().endsWith("ar")) {
-      log("deploying business archive "+processFile.getName());
+    }
+    else if (contentType.contains("zip")) {
+      log("deploying business archive " + processFile.getName());
       try {
         FileInputStream fileInputStream = new FileInputStream(processFile);
         ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
         deployment.addResourcesFromZipInputStream(zipInputStream);
-      } catch (Exception e) {
-        throw new BuildException("couldn't read business archive "+processFile, e);
       }
-
-    } else {
-      throw new BuildException("unsupported extension: "+processFile+"  Only .xml files and .*ar archives are supported");
+      catch (IOException e) {
+        throw new BuildException("failed to read process archive " + processFile, e);
+      }
     }
-    
+    else {
+      throw new BuildException("unsupported extension: " + processFile
+        + "  Only .xml files and .*ar archives are supported");
+    }
     deployment.deploy();
   }
 
   public void addFileset(FileSet fileSet) {
-    this.fileSets.add(fileSet);
+    fileSets.add(fileSet);
   }
   public void setJbpmCfg(String jbpmCfg) {
     this.jbpmCfg = jbpmCfg;
@@ -119,7 +120,4 @@
   public void setFile(File file) {
     this.file = file;
   }
-  public void setFailOnError(boolean failOnError) {
-    this.failOnError = failOnError;
-  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -5,7 +5,6 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.SortedSet;
@@ -187,8 +186,8 @@
     protected static final Integer ALL_SPEC = new Integer(ALL_SPEC_INT);
     protected static final Integer NO_SPEC = new Integer(NO_SPEC_INT);
     
-    protected static Map monthMap = new HashMap(20);
-    protected static Map dayMap = new HashMap(60);
+    protected static Map<String, Integer> monthMap = new HashMap<String, Integer>(20);
+    protected static Map<String, Integer> dayMap = new HashMap<String, Integer>(60);
     static {
         monthMap.put("JAN", new Integer(0));
         monthMap.put("FEB", new Integer(1));
@@ -212,21 +211,21 @@
         dayMap.put("SAT", new Integer(7));
     }
 
-    private String cronExpression = null;
-    private TimeZone timeZone = null;
-    protected transient TreeSet seconds;
-    protected transient TreeSet minutes;
-    protected transient TreeSet hours;
-    protected transient TreeSet daysOfMonth;
-    protected transient TreeSet months;
-    protected transient TreeSet daysOfWeek;
-    protected transient TreeSet years;
+    private String cronExpression;
+    private TimeZone timeZone;
+    protected transient TreeSet<Integer> seconds;
+    protected transient TreeSet<Integer> minutes;
+    protected transient TreeSet<Integer> hours;
+    protected transient TreeSet<Integer> daysOfMonth;
+    protected transient TreeSet<Integer> months;
+    protected transient TreeSet<Integer> daysOfWeek;
+    protected transient TreeSet<Integer> years;
 
-    protected transient boolean lastdayOfWeek = false;
-    protected transient int nthdayOfWeek = 0;
-    protected transient boolean lastdayOfMonth = false;
-    protected transient boolean nearestWeekday = false;
-    protected transient boolean expressionParsed = false;
+    protected transient boolean lastdayOfWeek;
+    protected transient int nthdayOfWeek;
+    protected transient boolean lastdayOfMonth;
+    protected transient boolean nearestWeekday;
+    protected transient boolean expressionParsed;
     
     /**
      * Constructs a new <CODE>CronExpression</CODE> based on the specified 
@@ -377,27 +376,26 @@
         expressionParsed = true;
 
         try {
-
             if (seconds == null) {
-                seconds = new TreeSet();
+                seconds = new TreeSet<Integer>();
             }
             if (minutes == null) {
-                minutes = new TreeSet();
+                minutes = new TreeSet<Integer>();
             }
             if (hours == null) {
-                hours = new TreeSet();
+                hours = new TreeSet<Integer>();
             }
             if (daysOfMonth == null) {
-                daysOfMonth = new TreeSet();
+                daysOfMonth = new TreeSet<Integer>();
             }
             if (months == null) {
-                months = new TreeSet();
+                months = new TreeSet<Integer>();
             }
             if (daysOfWeek == null) {
-                daysOfWeek = new TreeSet();
+                daysOfWeek = new TreeSet<Integer>();
             }
             if (years == null) {
-                years = new TreeSet();
+                years = new TreeSet<Integer>();
             }
 
             int exprOn = SECOND;
@@ -527,7 +525,7 @@
                             i);
             }
             if (type == DAY_OF_WEEK && !lastdayOfMonth) {
-                int val = ((Integer) daysOfMonth.last()).intValue();
+                int val = daysOfMonth.last().intValue();
                 if (val == NO_SPEC_INT) {
                     throw new ParseException(
                                 "'?' can only be specfied for Day-of-Month -OR- Day-of-Week.",
@@ -637,7 +635,7 @@
             } else {
                 throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i);
             }
-            TreeSet set = getSet(type);
+            TreeSet<Integer> set = getSet(type);
             set.add(new Integer(val));
             i++;
             return i;
@@ -649,7 +647,7 @@
             } else {
                 throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
             }
-            TreeSet set = getSet(type);
+            TreeSet<Integer> set = getSet(type);
             set.add(new Integer(val));
             i++;
             return i;
@@ -671,7 +669,7 @@
                         i);
             }
 
-            TreeSet set = getSet(type);
+            TreeSet<Integer> set = getSet(type);
             set.add(new Integer(val));
             i++;
             return i;
@@ -790,7 +788,7 @@
         return summary.toString();
     }
 
-    protected String getExpressionSetSummary(java.util.Set set) {
+    protected String getExpressionSetSummary(java.util.Set<Integer> set) {
 
         if (set.contains(NO_SPEC)) {
             return "?";
@@ -801,10 +799,8 @@
 
         StringBuilder summary = new StringBuilder();
 
-        Iterator itr = set.iterator();
         boolean first = true;
-        while (itr.hasNext()) {
-            Integer iVal = (Integer) itr.next();
+        for (Integer iVal : set) {
             String val = iVal.toString();
             if (!first) {
                 summary.append(",");
@@ -816,7 +812,7 @@
         return summary.toString();
     }
 
-    protected String getExpressionSetSummary(java.util.List list) {
+    protected String getExpressionSetSummary(java.util.List<Integer> list) {
 
         if (list.contains(NO_SPEC)) {
             return "?";
@@ -827,10 +823,8 @@
 
         StringBuilder summary = new StringBuilder();
 
-        Iterator itr = list.iterator();
         boolean first = true;
-        while (itr.hasNext()) {
-            Integer iVal = (Integer) itr.next();
+        for (Integer iVal : list) {
             String val = iVal.toString();
             if (!first) {
                 summary.append(",");
@@ -861,7 +855,7 @@
     protected void addToSet(int val, int end, int incr, int type)
         throws ParseException {
         
-        TreeSet set = getSet(type);
+        TreeSet<Integer> set = getSet(type);
 
         if (type == SECOND || type == MINUTE) {
             if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
@@ -960,7 +954,7 @@
         }
     }
 
-    protected TreeSet getSet(int type) {
+    protected TreeSet<Integer> getSet(int type) {
         switch (type) {
             case SECOND:
                 return seconds;
@@ -1006,7 +1000,7 @@
     }
 
     protected int getMonthNumber(String s) {
-        Integer integer = (Integer) monthMap.get(s);
+        Integer integer = monthMap.get(s);
 
         if (integer == null) {
             return -1;
@@ -1016,7 +1010,7 @@
     }
 
     protected int getDayOfWeekNumber(String s) {
-        Integer integer = (Integer) dayMap.get(s);
+        Integer integer = dayMap.get(s);
 
         if (integer == null) {
             return -1;
@@ -1052,7 +1046,7 @@
             if(cl.get(Calendar.YEAR) > 2999) // prevent endless loop...
                 return null;
 
-            SortedSet st = null;
+            SortedSet<Integer> st = null;
             int t = 0;
 
             int sec = cl.get(Calendar.SECOND);
@@ -1061,9 +1055,9 @@
             // get second.................................................
             st = seconds.tailSet(new Integer(sec));
             if (st != null && st.size() != 0) {
-                sec = ((Integer) st.first()).intValue();
+                sec = st.first().intValue();
             } else {
-                sec = ((Integer) seconds.first()).intValue();
+                sec = seconds.first().intValue();
                 min++;
                 cl.set(Calendar.MINUTE, min);
             }
@@ -1077,9 +1071,9 @@
             st = minutes.tailSet(new Integer(min));
             if (st != null && st.size() != 0) {
                 t = min;
-                min = ((Integer) st.first()).intValue();
+                min = st.first().intValue();
             } else {
-                min = ((Integer) minutes.first()).intValue();
+                min = minutes.first().intValue();
                 hr++;
             }
             if (min != t) {
@@ -1098,9 +1092,9 @@
             st = hours.tailSet(new Integer(hr));
             if (st != null && st.size() != 0) {
                 t = hr;
-                hr = ((Integer) st.first()).intValue();
+                hr = st.first().intValue();
             } else {
-                hr = ((Integer) hours.first()).intValue();
+                hr = hours.first().intValue();
                 day++;
             }
             if (hr != t) {
@@ -1166,7 +1160,7 @@
                     }
                 } else if(nearestWeekday) {
                     t = day;
-                    day = ((Integer) daysOfMonth.first()).intValue();
+                    day = daysOfMonth.first().intValue();
 
                     java.util.Calendar tcal = java.util.Calendar.getInstance();
                     tcal.set(Calendar.SECOND, 0);
@@ -1197,14 +1191,14 @@
                     tcal.set(Calendar.MONTH, mon - 1);
                     Date nTime = tcal.getTime();
                     if(nTime.before(afterTime)) {
-                        day = ((Integer) daysOfMonth.first()).intValue();;
+                        day = daysOfMonth.first().intValue();;
                         mon++;
                     }
                 } else if (st != null && st.size() != 0) {
                     t = day;
-                    day = ((Integer) st.first()).intValue();
+                    day = st.first().intValue();
                 } else {
-                    day = ((Integer) daysOfMonth.first()).intValue();
+                    day = daysOfMonth.first().intValue();
                     mon++;
                 }
                 
@@ -1221,7 +1215,7 @@
             } else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule
                 if (lastdayOfWeek) { // are we looking for the last XXX day of
                     // the month?
-                    int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+                    int dow = daysOfWeek.first().intValue(); // desired
                     // d-o-w
                     int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
                     int daysToAdd = 0;
@@ -1245,7 +1239,7 @@
                         continue;
                     }
 
-                    // find date of last occurance of this day in this month...
+                    // find date of last occurrence of this day in this month...
                     while ((day + daysToAdd + 7) <= lDay) {
                         daysToAdd += 7;
                     }
@@ -1264,7 +1258,7 @@
 
                 } else if (nthdayOfWeek != 0) {
                     // are we looking for the Nth XXX day in the month?
-                    int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+                    int dow = daysOfWeek.first().intValue(); // desired
                     // d-o-w
                     int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
                     int daysToAdd = 0;
@@ -1308,11 +1302,11 @@
                     }
                 } else {
                     int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
-                    int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+                    int dow = daysOfWeek.first().intValue(); // desired
                     // d-o-w
                     st = daysOfWeek.tailSet(new Integer(cDow));
                     if (st != null && st.size() > 0) {
-                        dow = ((Integer) st.first()).intValue();
+                        dow = st.first().intValue();
                     }
 
                     int daysToAdd = 0;
@@ -1334,7 +1328,7 @@
                         cl.set(Calendar.MONTH, mon);
                         // no '- 1' here because we are promoting the month
                         continue;
-                    } else if (daysToAdd > 0) { // are we swithing days?
+                    } else if (daysToAdd > 0) { // are we switching days?
                         cl.set(Calendar.SECOND, 0);
                         cl.set(Calendar.MINUTE, 0);
                         cl.set(Calendar.HOUR_OF_DAY, 0);
@@ -1368,9 +1362,9 @@
             st = months.tailSet(new Integer(mon));
             if (st != null && st.size() != 0) {
                 t = mon;
-                mon = ((Integer) st.first()).intValue();
+                mon = st.first().intValue();
             } else {
-                mon = ((Integer) months.first()).intValue();
+                mon = months.first().intValue();
                 year++;
             }
             if (mon != t) {
@@ -1395,7 +1389,7 @@
             st = years.tailSet(new Integer(year));
             if (st != null && st.size() != 0) {
                 t = year;
-                year = ((Integer) st.first()).intValue();
+                year = st.first().intValue();
             } else {
                 return null; // ran out of years...
             }
@@ -1508,11 +1502,10 @@
             throw new IncompatibleClassChangeError("Not Cloneable.");
         }
         return copy;
-    }        
-}
+    }
 
-class ValueSet {
-    public int value;
-
-    public int pos;
+    static class ValueSet {
+        int value;
+        int pos;
+    }
 }
\ No newline at end of file

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -22,15 +22,12 @@
 package org.jbpm.pvm.internal.cal;
 
 import java.io.Serializable;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.jbpm.api.JbpmException;
@@ -241,45 +238,45 @@
     fieldSetter.set(this, quantity);
   }
   
-  private interface FieldSetter {
+  interface FieldSetter {
     void set(Duration duration, int quantity);
   }
-  private static class MillisSetter implements FieldSetter {
+  static class MillisSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.millis = quantity;
     }
   }
-  private static class SecondSetter implements FieldSetter {
+  static class SecondSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.seconds = quantity;
     }
   }
-  private static class MinuteSetter implements FieldSetter {
+  static class MinuteSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.minutes = quantity;
     }
   }
-  private static class HourSetter implements FieldSetter {
+  static class HourSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.hours = quantity;
     }
   }
-  private static class DaySetter implements FieldSetter {
+  static class DaySetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.days = quantity;
     }
   }
-  private static class WeekSetter implements FieldSetter {
+  static class WeekSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.weeks = quantity;
     }
   }
-  private static class MonthSetter implements FieldSetter {
+  static class MonthSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.months = quantity;
     }
   }
-  private static class YearSetter implements FieldSetter {
+  static class YearSetter implements FieldSetter {
     public void set(Duration duration, int quantity) {
       duration.years = quantity;
     }
@@ -288,7 +285,7 @@
   private static final Map<String, FieldSetter> fieldSetters = new HashMap<String, FieldSetter>();
   static {
     FieldSetter fieldSetter = new MillisSetter();
-    fieldSetters.put("milli", fieldSetter);
+    fieldSetters.put("ms", fieldSetter);
     fieldSetters.put("millis", fieldSetter);
     fieldSetters.put("millisecond", fieldSetter);
     fieldSetters.put("milliseconds", fieldSetter);
@@ -333,42 +330,34 @@
     return days;
   }
 
-  
   public int getHours() {
     return hours;
   }
 
-  
   public boolean isBusinessTime() {
     return isBusinessTime;
   }
 
-  
   public int getMillis() {
     return millis;
   }
 
-  
   public int getMinutes() {
     return minutes;
   }
 
-  
   public int getMonths() {
     return months;
   }
 
-  
   public int getSeconds() {
     return seconds;
   }
-
   
   public int getWeeks() {
     return weeks;
   }
 
-  
   public int getYears() {
     return years;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,7 +27,6 @@
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
 
-
 /** container for executing multiple commands in one transaction. 
  * 
  * @author Tom Baeyens
@@ -39,7 +38,7 @@
   protected List<Command<?>> commands = new ArrayList<Command<?>>();
 
   public Void execute(Environment environment) throws Exception {
-    for (Command command: commands) {
+    for (Command<?> command: commands) {
       command.execute(environment);
     }
     return null;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,10 +24,8 @@
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
-import org.jbpm.pvm.internal.query.JobQueryImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryDetailQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryDetailQueryCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryDetailQueryCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,10 +24,8 @@
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.pvm.internal.query.HistoryDetailQueryImpl;
-import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,19 +24,17 @@
 import java.util.List;
 
 import org.hibernate.Session;
+
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
 import org.jbpm.pvm.internal.repository.RepositoryCache;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.session.RepositorySession;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteJobCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteJobCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteJobCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -26,7 +26,6 @@
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
-
 /**
  * @author Joram Barrez
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -34,8 +34,6 @@
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.tx.Transaction;
 
-
-
 /**
  * @author Tom Baeyens
  */
@@ -64,7 +62,7 @@
   	if (dbSession==null) {
   	  throw new JbpmException("no db-session configured");
   	}
-    JobImpl<?> job = dbSession.get(JobImpl.class, jobDbid);
+    JobImpl job = dbSession.get(JobImpl.class, jobDbid);
 
   	// in case of decision jobs, the job might have been deleted
   	// before we execute it (they are in a list)
@@ -73,8 +71,11 @@
         environment.setContext(jobContext);
 	    try {
 	      log.debug("executing job "+job+"...");
-	      job.execute(environment);
+	      Boolean deleteJob = job.execute(environment);
 	      log.debug("executed job "+job);
+	      if (deleteJob) {
+	        dbSession.delete(job);
+	      }
 
 	      // if this job is locked too long, it could be unlocked by the lockmonitor and 
 	      // executed by another thread.
@@ -104,7 +105,7 @@
    * Transaction.EVENT_AFTERCOMPLETION (after the job locks of the current transaction are 
    * released).  Then the command will update the job with the exception details in a separate 
    * transaction. */
-  protected void handleJobExecutionException(Environment environment, JobImpl<?> job, Exception exception) {
+  protected void handleJobExecutionException(Environment environment, JobImpl job, Exception exception) {
     Transaction transaction = environment.get(Transaction.class);
     CommandService commandService = (CommandService) environment.get(CommandService.NAME_NEW_TX_REQUIRED_COMMAND_SERVICE);
     JobExceptionHandler jobExceptionHandler = new JobExceptionHandler(job.getDbid(), exception, commandService);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,14 +23,16 @@
 
 import java.util.List;
 
-import org.hibernate.Query;
+import org.hibernate.Criteria;
 import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.api.task.Participation;
 import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -50,25 +52,17 @@
   }
 
   public List<Participation> execute(Environment environment) throws Exception {
-    StringBuilder hql = new StringBuilder();
-    hql.append("select role from ");
-    hql.append(ParticipationImpl.class.getName());
-    hql.append(" as role where ");
+    Criteria criteria = environment.get(Session.class).createCriteria(ParticipationImpl.class);
     
     if (taskId!=null) {
-      hql.append(" role.task.dbid = "+taskId+" ");
-
+      criteria.add(Restrictions.eq("task.dbid", Long.parseLong(taskId)));
     } else if (swimlaneId!=null) {
-      hql.append(" role.swimlane.dbid = "+swimlaneId+" ");
-      
+      criteria.add(Restrictions.eq("swimlane.dbid", Long.parseLong(swimlaneId)));
     } else {
       throw new JbpmException("no task nor swimlane specified");
     }
 
-    Session session = environment.get(Session.class);
-    Query query = session.createQuery(hql.toString());
-
-    List<Participation> participations = query.list();
-    return participations;
+    List<?> participations = criteria.list();
+    return CollectionUtil.checkList(participations, Participation.class);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetStartActivityNamesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetStartActivityNamesCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetStartActivityNamesCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -26,11 +26,10 @@
 
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.api.model.Activity;
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.internal.session.RepositorySession;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -50,7 +49,7 @@
     RepositorySession repositorySession = environment.get(RepositorySession.class);
     ProcessDefinitionImpl processDefinition = repositorySession.findProcessDefinitionById(processDefinitionId);
     
-    for (ActivityImpl activity: (List<ActivityImpl>) processDefinition.getActivities()) {
+    for (Activity activity: processDefinition.getActivities()) {
       if (activity.getIncomingTransitions().isEmpty()) {
         activityNames.add(activity.getName());
       }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,13 +23,14 @@
 
 import java.util.List;
 
-import org.hibernate.Query;
 import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.api.task.Task;
 import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -44,14 +45,10 @@
   }
 
   public List<Task> execute(Environment environment) throws Exception {
-    Session session = environment.get(Session.class);
-    
-    Query query = session.createQuery(
-      "select task " +
-      "from "+TaskImpl.class.getName()+" as task " +
-      "where task.superTask.dbid = "+parentTaskId+" "
-    );
-    
-    return query.list();
+    List<?> tasks = environment.get(Session.class).createCriteria(TaskImpl.class)
+      .createAlias("superTask", "super")
+      .add(Restrictions.eq("super.dbid", Long.parseLong(parentTaskId)))
+      .list();
+    return CollectionUtil.checkList(tasks, Task.class);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -22,16 +22,12 @@
 package org.jbpm.pvm.internal.cmd;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.api.history.HistoryComment;
-import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
-import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -53,7 +49,7 @@
     return comments;
   }
 
-  protected void forceInitializationAndClean(List<HistoryComment> comments) {
+  protected void forceInitializationAndClean(List<? extends HistoryComment> comments) {
     if (comments!=null) {
       comments.size();
       List<HistoryComment> copy = new ArrayList<HistoryComment>(comments);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskVariableNamesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskVariableNamesCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskVariableNamesCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,11 +25,9 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -37,7 +35,7 @@
 
   private static final long serialVersionUID = 1L;
   
-  String taskId;
+  private String taskId;
   
   public GetTaskVariableNamesCmd(String taskId) {
     if (taskId==null) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JstlFunction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JstlFunction.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JstlFunction.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -168,8 +168,8 @@
     if (obj == null) {
       return 0;
     }
-    if (obj instanceof Collection) {
-      return ((Collection) obj).size();
+    if (obj instanceof Collection<?>) {
+      return ((Collection<?>) obj).size();
     }
     if (obj.getClass().isArray()) {
       return Array.getLength(obj);
@@ -177,23 +177,23 @@
     if (obj instanceof String) {
       return ((String) obj).length();
     }
-    if (obj instanceof Map) {
-      return ((Map) obj).size();
+    if (obj instanceof Map<?, ?>) {
+      return ((Map<?, ?>) obj).size();
     }
-    if (obj instanceof Enumeration) {
-      Enumeration e = (Enumeration) obj;
+    if (obj instanceof Iterator<?>) {
+      Iterator<?> i = (Iterator<?>) obj;
       int count = 0;
-      while (e.hasMoreElements()) {
-        e.nextElement();
+      while (i.hasNext()) {
+        i.next();
         count++;
       }
       return count;
     }
-    if (obj instanceof Iterator) {
-      Iterator i = (Iterator) obj;
+    if (obj instanceof Enumeration<?>) {
+      Enumeration<?> e = (Enumeration<?>) obj;
       int count = 0;
-      while (i.hasNext()) {
-        i.next();
+      while (e.hasMoreElements()) {
+        e.nextElement();
         count++;
       }
       return count;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentFactory.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentFactory.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,7 +23,6 @@
 
 import java.io.InputStream;
 import java.io.Serializable;
-import java.util.List;
 
 import org.xml.sax.InputSource;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -127,6 +127,8 @@
  */
 public abstract class EnvironmentImpl implements Serializable, Environment {
 
+  private static final long serialVersionUID = 1L;
+
   /**
    * searches a named object in all the contexts in the default search order. 
    * @return the object if it exists in the environment, <code>null</code> if there is no object with the given name in the environment.

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,10 +24,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
 
 public class ExecutionContext implements Context {
   
@@ -70,8 +68,8 @@
   }
 
   public <T> T get(Class<T> type) {
-    if (Execution.class.isAssignableFrom(type.getClass())) {
-      return (T) execution;
+    if (type.isAssignableFrom(ExecutionImpl.class)) {
+      return type.cast(execution);
     }
     return null;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,7 +25,6 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.jbpm.api.job.Job;
 import org.jbpm.pvm.internal.job.JobImpl;
 
 public class JobContext implements Context {
@@ -39,9 +38,9 @@
     return keys;
   }
 
-  JobImpl<?> job;
+  JobImpl job;
 
-  public JobContext(JobImpl<?> job) {
+  public JobContext(JobImpl job) {
     this.job = job;
   }
 
@@ -65,8 +64,8 @@
   }
   
   public <T> T get(Class<T> type) {
-    if (Job.class.isAssignableFrom(type)) {
-      return (T) job;
+    if (type.isAssignableFrom(JobImpl.class)) {
+      return type.cast(job);
     }
     return null;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/TaskContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/TaskContext.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/TaskContext.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,10 +25,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.jbpm.api.job.Job;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -36,15 +34,15 @@
   
   private static final String KEY_TASK = "task";
   
-  static final Set<String> keys = Collections.unmodifiableSet(getKeys());
+  private static final Set<String> keys = Collections.unmodifiableSet(getKeys());
   
-  static Set<String> getKeys() {
+  private static Set<String> getKeys() {
     Set<String> keys = new HashSet<String>();
     keys.add(KEY_TASK);
     return keys;
   }
 
-  TaskImpl task;
+  private TaskImpl task;
 
   public TaskContext(TaskImpl task) {
     this.task = task;
@@ -71,8 +69,8 @@
   }
   
   public <T> T get(Class<T> type) {
-    if (Job.class.isAssignableFrom(type)) {
-      return (T) task;
+    if (type.isAssignableFrom(TaskImpl.class)) {
+      return type.cast(task);
     }
     return null;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -71,7 +71,7 @@
     return "converter";
   }
 
-  public Class getReturnedClass() {
+  public Class<?> getReturnedClass() {
     return Converter.class;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -26,14 +26,14 @@
 import java.util.List;
 
 import org.hibernate.LockMode;
-import org.hibernate.Query;
 import org.hibernate.Session;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
 import org.hibernate.metadata.ClassMetadata;
 
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.history.HistoryComment;
-import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.api.task.Task;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.client.ClientExecution;
@@ -54,12 +54,13 @@
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.task.TaskImpl;
 import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
  */
 public class DbSessionImpl implements DbSession {
-  
+
   private static Log log = Log.getLog(DbSessionImpl.class.getName());
 
   protected Session session;
@@ -109,104 +110,93 @@
   }
 
   public void deleteProcessDefinitionHistory(String processDefinitionId) {
-    List<HistoryProcessInstanceImpl> historyProcessInstances = 
-          session.createQuery(
-            "select hpi " +
-            "from "+HistoryProcessInstanceImpl.class.getName()+" hpi "+
-            "where hpi.processDefinitionId = :processDefinitionId "
-          )
-          .setString("processDefinitionId", processDefinitionId)
-          .list();
-    
-    for (HistoryProcessInstanceImpl hpi: historyProcessInstances) {
+    List<?> historyProcessInstances = session.createCriteria(HistoryProcessInstanceImpl.class)
+      .add(Restrictions.eq("processDefinitionId", processDefinitionId))
+      .list();
+
+    for (Object hpi : historyProcessInstances) {
       session.delete(hpi);
     }
   }
 
   public boolean isHistoryEnabled() {
-    ClassMetadata historyHibernateMetadata = session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class);
-    return historyHibernateMetadata!=null;
+    ClassMetadata historyHibernateMetadata = session.getSessionFactory()
+      .getClassMetadata(HistoryProcessInstanceImpl.class);
+    return historyHibernateMetadata != null;
   }
 
-
   // process execution queries ////////////////////////////////////////////////
 
   public ClientExecution findExecutionById(String executionId) {
-    // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
-    Query query = session.getNamedQuery("findExecutionById");
-    query.setString("id", executionId);
-    query.setMaxResults(1);
-    return (ClientExecution) query.uniqueResult();
+    // query definition can be found at the bottom of resource jbpm.execution.hbm.xml
+    return (ClientExecution) session.getNamedQuery("findExecutionById")
+      .setString("id", executionId)
+      .setMaxResults(1)
+      .uniqueResult();
   }
 
   public ClientExecution findProcessInstanceById(String processInstanceId) {
-    // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
-    Query query = session.getNamedQuery("findProcessInstanceById");
-    query.setString("processInstanceId", processInstanceId);
-    query.setMaxResults(1);
-    return (ClientExecution) query.uniqueResult();
+    // query definition can be found at the bottom of resource jbpm.execution.hbm.xml
+    return (ClientExecution) session.getNamedQuery("findProcessInstanceById")
+      .setString("processInstanceId", processInstanceId)
+      .setMaxResults(1)
+      .uniqueResult();
   }
 
   public ClientExecution findProcessInstanceByIdIgnoreSuspended(String processInstanceId) {
-    // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
-    Query query = session.getNamedQuery("findProcessInstanceByIdIgnoreSuspended");
-    query.setString("processInstanceId", processInstanceId);
-    query.setMaxResults(1);
-    return (ClientExecution) query.uniqueResult();
+    // query definition can be found at the bottom of resource jbpm.execution.hbm.xml
+    return (ClientExecution) session.getNamedQuery("findProcessInstanceByIdIgnoreSuspended")
+      .setString("processInstanceId", processInstanceId)
+      .setMaxResults(1)
+      .uniqueResult();
   }
-  
+
   public List<String> findProcessInstanceIds(String processDefinitionId) {
-    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
-    Query query = session.createQuery(
-      "select processInstance.id " +
-      "from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance " +
-      "where processInstance.processDefinitionId = :processDefinitionId " +
-      "  and processInstance.parent is null"
-    );
-    query.setString("processDefinitionId", processDefinitionId);
-    return query.list();
+    // query definition can be found at the bottom of resource jbpm.execution.hbm.xml
+    List<?> processInstanceIds = session.getNamedQuery("findProcessInstanceIds")
+      .setString("processDefinitionId", processDefinitionId)
+      .list();
+    return CollectionUtil.checkList(processInstanceIds, String.class);
   }
-  
+
   public void deleteProcessInstance(String processInstanceId) {
     deleteProcessInstance(processInstanceId, true);
   }
 
   public void deleteProcessInstance(String processInstanceId, boolean deleteHistory) {
-    if (processInstanceId==null) {
+    if (processInstanceId == null) {
       throw new JbpmException("processInstanceId is null");
     }
-    
-    // if history should be deleted 
-    if ( deleteHistory 
-         && (isHistoryEnabled())
-       ) {
-      // try to get the history 
+
+    // if history should be deleted
+    if (deleteHistory && (isHistoryEnabled())) {
+      // try to get the history
       HistoryProcessInstanceImpl historyProcessInstance = findHistoryProcessInstanceById(processInstanceId);
-  
+
       // if there is a history process instance in the db
-      if (historyProcessInstance!=null) {
+      if (historyProcessInstance != null) {
         if (log.isDebugEnabled()) {
-          log.debug("deleting history process instance "+processInstanceId);
+          log.debug("deleting history process instance " + processInstanceId);
         }
         session.delete(historyProcessInstance);
       }
     }
-    
+
     ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceByIdIgnoreSuspended(processInstanceId);
-    if (processInstance!=null) {
+    if (processInstance != null) {
       deleteSubProcesses(processInstance, deleteHistory);
-      
+
       // delete remaining tasks for this process instance
       List<TaskImpl> tasks = findTasks(processInstanceId);
-      for (TaskImpl task: tasks) {
+      for (TaskImpl task : tasks) {
         session.delete(task);
       }
 
       // delete remaining jobs for this process instance
       JobImpl currentJob = EnvironmentImpl.getFromCurrent(JobImpl.class, false);
       List<JobImpl> jobs = findJobs(processInstanceId);
-      for (JobImpl job: jobs) {
-        if (job!=currentJob){ 
+      for (JobImpl job : jobs) {
+        if (job != currentJob) {
           session.delete(job);
         }
       }
@@ -215,109 +205,86 @@
         log.debug("Deleting process instance " + processInstanceId);
       }
       session.delete(processInstance);
-      
-    } else {
-    	throw new JbpmException("Can't delete processInstance " + processInstanceId 
-    			+ ": no processInstance found for the given id");
     }
+    else {
+      throw new JbpmException("Can't delete processInstance " + processInstanceId
+        + ": no processInstance found for the given id");
+    }
   }
 
   private void deleteSubProcesses(ExecutionImpl execution, boolean deleteHistory) {
     ExecutionImpl subProcessInstance = execution.getSubProcessInstance();
-    if (subProcessInstance!=null) {
+    if (subProcessInstance != null) {
       subProcessInstance.setSuperProcessExecution(null);
       execution.setSubProcessInstance(null);
       deleteProcessInstance(subProcessInstance.getId(), deleteHistory);
     }
     Collection<ExecutionImpl> childExecutions = execution.getExecutions();
-    if (childExecutions!=null) {
-      for (ExecutionImpl childExecution: childExecutions) {
+    if (childExecutions != null) {
+      for (ExecutionImpl childExecution : childExecutions) {
         deleteSubProcesses(childExecution, deleteHistory);
       }
     }
   }
 
   public HistoryProcessInstanceImpl findHistoryProcessInstanceById(String processInstanceId) {
-    return (HistoryProcessInstanceImpl) session
-      .createQuery(
-        "select hpi " +
-        "from "+HistoryProcessInstance.class.getName()+" as hpi " +
-        "where hpi.processInstanceId = '"+processInstanceId+"'"
-      ).uniqueResult();
+    return (HistoryProcessInstanceImpl) session.createCriteria(HistoryProcessInstanceImpl.class)
+      .add(Restrictions.eq("processInstanceId", processInstanceId))
+      .uniqueResult();
   }
 
   List<TaskImpl> findTasks(String processInstanceId) {
-    Query query = session.createQuery(
-      "select task " +
-      "from "+TaskImpl.class.getName()+" as task " +
-      "where task.processInstance.id = :processInstanceId"
-    );
-    query.setString("processInstanceId", processInstanceId);
-    return query.list();
+    List<?> tasks = session.createCriteria(TaskImpl.class)
+      .createAlias("processInstance", "pi")
+      .add(Restrictions.eq("pi.id", processInstanceId))
+      .list();
+    return CollectionUtil.checkList(tasks, TaskImpl.class);
   }
 
   List<JobImpl> findJobs(String processInstanceId) {
-    Query query = session.createQuery(
-      "select job " +
-      "from "+JobImpl.class.getName()+" as job " +
-      "where job.processInstance.id = :processInstanceId"
-    );
-    query.setString("processInstanceId", processInstanceId);
-    return query.list();
+    List<?> jobs = session.createCriteria(JobImpl.class)
+      .createAlias("processInstance", "pi")
+      .add(Restrictions.eq("pi.id", processInstanceId))
+      .list();
+    return CollectionUtil.checkList(jobs, JobImpl.class);
   }
-  
+
   public void cascadeExecutionSuspend(ExecutionImpl execution) {
     // cascade suspend to jobs
-    Query query = session.createQuery(
-      "select job " +
-      "from "+JobImpl.class.getName()+" as job " +
-      "where job.execution = :execution " +
-      "  and job.state != '"+JobImpl.STATE_SUSPENDED+"' "
-    );
-    query.setEntity("execution", execution);
-    List<JobImpl> jobs = query.list();
-    for (JobImpl job: jobs) {
+    List<?> jobs = session.createCriteria(JobImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .add(Restrictions.ne("state", JobImpl.STATE_SUSPENDED))
+      .list();
+    for (JobImpl job : CollectionUtil.checkList(jobs, JobImpl.class)) {
       job.suspend();
     }
 
     // cascade suspend to tasks
-    query = session.createQuery(
-      "select task " +
-      "from "+TaskImpl.class.getName()+" as task " +
-      "where task.execution = :execution " +
-      "  and task.state != '"+Task.STATE_SUSPENDED+"' "
-    );
-    query.setEntity("execution", execution);
-    List<TaskImpl> tasks = query.list();
-    for (TaskImpl task: tasks) {
+    List<?> tasks = session.createCriteria(TaskImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .add(Restrictions.ne("state", Task.STATE_SUSPENDED))
+      .list();
+    for (TaskImpl task : CollectionUtil.checkList(tasks, TaskImpl.class)) {
       task.suspend();
     }
   }
 
   public void cascadeExecutionResume(ExecutionImpl execution) {
-    // cascade suspend to jobs
-    Query query = session.createQuery(
-      "select job " +
-      "from "+JobImpl.class.getName()+" as job " +
-      "where job.execution = :execution " +
-      "  and job.state = '"+Task.STATE_SUSPENDED+"' "
-    );
-    query.setEntity("execution", execution);
-    List<JobImpl> jobs = query.list();
-    for (JobImpl job: jobs) {
+    // cascade resume to jobs
+    List<?> jobs = session.createCriteria(JobImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .add(Restrictions.eq("state", JobImpl.STATE_SUSPENDED))
+      .list();
+    for (JobImpl job : CollectionUtil.checkList(jobs, JobImpl.class)) {
       job.resume();
     }
 
-    // cascade suspend to tasks
-    query = session.createQuery(
-      "select task " +
-      "from "+TaskImpl.class.getName()+" as task " +
-      "where task.execution = :execution " +
-      "  and task.state = '"+Task.STATE_SUSPENDED+"' "
-    );
-    query.setEntity("execution", execution);
-    List<TaskImpl> tasks = query.list();
-    for (TaskImpl task: tasks) {
+    // cascade resume to tasks
+    List<?> tasks = session.createCriteria(TaskImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .add(Restrictions.eq("state", Task.STATE_SUSPENDED))
+      .list();
+    for (TaskImpl task : CollectionUtil.checkList(tasks, TaskImpl.class)) {
       task.resume();
     }
   }
@@ -340,45 +307,40 @@
     return (TaskImpl) session.get(TaskImpl.class, taskDbid);
   }
 
-
   public TaskImpl findTaskByExecution(Execution execution) {
-    Query query = session.createQuery(
-      "select task " +
-      "from "+TaskImpl.class.getName()+" as task " +
-      "where task.execution = :execution"
-    );
-    query.setEntity("execution", execution);
-    return (TaskImpl) query.uniqueResult();
+    return (TaskImpl) session.createCriteria(TaskImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .uniqueResult();
   }
-  
-  public JobImpl<?> findFirstAcquirableJob() {
-    Query query = session.getNamedQuery("findFirstAcquirableJob");
-    query.setTimestamp("now", Clock.getTime());
-    query.setMaxResults(1);
-    return (JobImpl<?>) query.uniqueResult();
+
+  public JobImpl findFirstAcquirableJob() {
+    return (JobImpl) session.getNamedQuery("findFirstAcquirableJob")
+      .setTimestamp("now", Clock.getTime())
+      .setMaxResults(1)
+      .uniqueResult();
   }
 
-  public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
-    Query query = session.getNamedQuery("findExclusiveJobs");
-    query.setTimestamp("now", Clock.getTime());
-    query.setEntity("processInstance", processInstance);
-    return query.list();
+  public List<JobImpl> findExclusiveJobs(Execution processInstance) {
+    List<?> exclusiveJobs = session.getNamedQuery("findExclusiveJobs")
+      .setTimestamp("now", Clock.getTime())
+      .setEntity("processInstance", processInstance)
+      .list();
+    return CollectionUtil.checkList(exclusiveJobs, JobImpl.class);
   }
 
-  public JobImpl<?> findFirstDueJob() {
-    Query query = session.getNamedQuery("findFirstDueJob");
-    query.setMaxResults(1);
-    return (JobImpl<?>) query.uniqueResult();
+  public JobImpl findFirstDueJob() {
+    return (JobImpl) session.getNamedQuery("findFirstDueJob")
+      .setMaxResults(1)
+      .uniqueResult();
   }
-  
+
   public List<StartProcessTimer> findStartProcessTimers(String processDefinitionName) {
-    Query query = session.createQuery(
-      "select spt from " + StartProcessTimer.class.getName() + " as spt " +
-      "where spt.signalName = :procDefName");
-    query.setString("procDefName", processDefinitionName);
-    return query.list();
+    List<?> timers = session.createCriteria(StartProcessTimer.class)
+      .add(Restrictions.eq("signalName", processDefinitionName))
+      .list();
+    return CollectionUtil.checkList(timers, StartProcessTimer.class);
   }
-  
+
   public ProcessInstanceQueryImpl createProcessInstanceQuery() {
     return new ProcessInstanceQueryImpl();
   }
@@ -394,11 +356,11 @@
   public HistoryActivityInstanceQueryImpl createHistoryActivityInstanceQuery() {
     return new HistoryActivityInstanceQueryImpl();
   }
-  
+
   public HistoryDetailQueryImpl createHistoryDetailQuery() {
     return new HistoryDetailQueryImpl();
   }
-  
+
   public JobQueryImpl createJobQuery() {
     return new JobQueryImpl();
   }
@@ -408,18 +370,11 @@
   }
 
   public List<HistoryComment> findCommentsByTaskId(String taskId) {
-    Long taskDbid = null;
-    try {
-      taskDbid = Long.parseLong(taskId);
-    } catch (Exception e) {
-      throw new JbpmException("invalid taskId: "+taskId);
-    }
-    return session.createQuery(
-      "select hc " +
-      "from "+HistoryCommentImpl.class.getName()+" as hc " +
-      "where hc.historyTask.dbid = :taskDbid " +
-      "order by hc.historyTaskIndex asc "
-    ).setLong("taskDbid", taskDbid)
-    .list();
+    List<?> comments = session.createCriteria(HistoryCommentImpl.class)
+      .createAlias("historyTask", "task")
+      .add(Restrictions.eq("task.dbid", Long.parseLong(taskId)))
+      .addOrder(Order.asc("historyTaskIndex"))
+      .list();
+    return CollectionUtil.checkList(comments, HistoryComment.class);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,19 +21,17 @@
  */
 package org.jbpm.pvm.internal.history.events;
 
-import java.io.Serializable;
-
 import org.hibernate.Session;
+
 import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.history.HistoryEvent;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
 
-
 /**
  * @author Tom Baeyens
  */
-public class ProcessInstanceCreate extends HistoryEvent implements Serializable {
+public class ProcessInstanceCreate extends HistoryEvent {
 
   private static final long serialVersionUID = 1L;
   

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -63,8 +63,8 @@
     return reply;
   }
 
-  public List<HistoryComment> getReplies() {
-    return (List) replies;
+  public List<? extends HistoryComment> getReplies() {
+    return replies;
   }
   
   // getters and setters //////////////////////////////////////////////////////

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -22,10 +22,8 @@
 package org.jbpm.pvm.internal.history.model;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.jbpm.api.history.HistoryTask;
@@ -33,7 +31,6 @@
 import org.jbpm.pvm.internal.util.Clock;
 import org.jbpm.pvm.internal.util.EqualsUtil;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,12 +27,14 @@
 import org.hibernate.Session;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
+
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.identity.Group;
 import org.jbpm.api.identity.User;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.id.DbidGenerator;
 import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
@@ -41,13 +43,14 @@
 
   protected Session session;
 
-  public String createUser(String userName, String givenName, String familyName, String businessEmail) {
+  public String createUser(String userName, String givenName, String familyName,
+    String businessEmail) {
     UserImpl user = new UserImpl(userName, givenName, familyName);
     user.setBusinessEmail(businessEmail);
-    
+
     long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
     user.setDbid(dbid);
-    
+
     session.save(user);
 
     return user.getId();
@@ -55,35 +58,36 @@
 
   public User findUserById(String userId) {
     return (User) session.createCriteria(UserImpl.class)
-        .add(Restrictions.eq("id", userId))
-        .uniqueResult();
+      .add(Restrictions.eq("id", userId))
+      .uniqueResult();
   }
 
   public List<User> findUsersById(String... userIds) {
-    List<User> users = session.createCriteria(UserImpl.class)
-        .add(Restrictions.in("id", userIds))
-        .list();
+    List<?> users = session.createCriteria(UserImpl.class)
+      .add(Restrictions.in("id", userIds))
+      .list();
     if (userIds.length != users.size()) {
       throw new JbpmException("not all users were found: " + Arrays.toString(userIds));
     }
-    return users;
+    return CollectionUtil.checkList(users, User.class);
   }
 
   public List<User> findUsers() {
-    return session.createCriteria(UserImpl.class).list();
+    List<?> users = session.createCriteria(UserImpl.class).list();
+    return CollectionUtil.checkList(users, User.class);
   }
 
   public void deleteUser(String userId) {
     // lookup the user
     User user = findUserById(userId);
 
-    // cascade the deletion to the memberships 
-    List<MembershipImpl> memberships = session.createCriteria(MembershipImpl.class)
-        .add(Restrictions.eq("user", user))
-        .list();
+    // cascade the deletion to the memberships
+    List<?> memberships = session.createCriteria(MembershipImpl.class)
+      .add(Restrictions.eq("user", user))
+      .list();
 
-    // delete the related memberships 
-    for (MembershipImpl membership : memberships) {
+    // delete the related memberships
+    for (Object membership : memberships) {
       session.delete(membership);
     }
 
@@ -106,63 +110,62 @@
       GroupImpl parentGroup = findGroupById(parentGroupId);
       group.setParent(parentGroup);
     }
-    
+
     session.save(group);
 
     return group.getId();
   }
 
   public List<User> findUsersByGroup(String groupId) {
-    return session.createCriteria(MembershipImpl.class)
-        .createAlias("group", "g")
-        .add(Restrictions.eq("g.id", groupId))
-        .setProjection(Projections.property("user"))
-        .list();
+    List<?> users = session.createCriteria(MembershipImpl.class)
+      .createAlias("group", "g")
+      .add(Restrictions.eq("g.id", groupId))
+      .setProjection(Projections.property("user"))
+      .list();
+    return CollectionUtil.checkList(users, User.class);
   }
 
   public GroupImpl findGroupById(String groupId) {
     return (GroupImpl) session.createCriteria(GroupImpl.class)
-        .add(Restrictions.eq("id", groupId))
-        .uniqueResult();
+      .add(Restrictions.eq("id", groupId))
+      .uniqueResult();
   }
 
   public List<Group> findGroupsByUserAndGroupType(String userId, String groupType) {
-    return session.createQuery("select distinct m.group"
-        + " from "
-        + MembershipImpl.class.getName()
-        + " as m where m.user.id = :userId"
-        + " and m.group.type = :groupType")
-        .setString("userId", userId)
-        .setString("groupType", groupType)
-        .list();
+    List<?> groups = session.getNamedQuery("findGroupsByUserAndGroupType")
+      .setString("userId", userId)
+      .setString("groupType", groupType)
+      .list();
+    return CollectionUtil.checkList(groups, Group.class);
   }
 
   public List<Group> findGroupsByUser(String userId) {
-    return session.createQuery("select distinct m.group"
-        + " from "
-        + MembershipImpl.class.getName()
-        + " as m where m.user.id = :userId").setString("userId", userId).list();
+    List<?> groups = session.getNamedQuery("findGroupsByUser")
+      .setParameter("userId", userId)
+      .list();
+    return CollectionUtil.checkList(groups, Group.class);
   }
 
   public List<Group> findGroups() {
-    return session.createCriteria(GroupImpl.class).list();
+    List<?> groups = session.createCriteria(GroupImpl.class).list();
+    return CollectionUtil.checkList(groups, Group.class);
   }
 
   public void deleteGroup(String groupId) {
     // look up the group
     GroupImpl group = findGroupById(groupId);
 
-    // cascade the deletion to the memberships 
-    List<MembershipImpl> memberships = session.createCriteria(MembershipImpl.class)
-        .add(Restrictions.eq("group", group))
-        .list();
+    // cascade the deletion to the memberships
+    List<?> memberships = session.createCriteria(MembershipImpl.class)
+      .add(Restrictions.eq("group", group))
+      .list();
 
-    // delete the related memberships 
-    for (MembershipImpl membership : memberships) {
+    // delete the related memberships
+    for (Object membership : memberships) {
       session.delete(membership);
     }
 
-    // delete the group 
+    // delete the group
     session.delete(group);
   }
 
@@ -189,11 +192,11 @@
 
   public void deleteMembership(String userId, String groupId, String role) {
     MembershipImpl membership = (MembershipImpl) session.createCriteria(MembershipImpl.class)
-        .createAlias("user", "u")
-        .createAlias("group", "g")
-        .add(Restrictions.eq("u.id", userId))
-        .add(Restrictions.eq("g.id", groupId))
-        .uniqueResult();
+      .createAlias("user", "u")
+      .createAlias("group", "g")
+      .add(Restrictions.eq("u.id", userId))
+      .add(Restrictions.eq("g.id", groupId))
+      .uniqueResult();
     session.delete(membership);
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,14 +24,12 @@
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.wire.Descriptor;
 
-
 /**
  * @author Tom Baeyens
  */
-public class CommandMessage extends MessageImpl<Object> {
+public class CommandMessage extends MessageImpl {
 
   private static final long serialVersionUID = 1L;
   
@@ -46,14 +44,9 @@
     setConfiguration(command);
   }
 
-  public Object execute(Environment environment) throws Exception {
+  protected void executeVoid(Environment environment) throws Exception {
     Command<?> command = (Command<?>) getConfiguration();
     command.execute(environment);
-    
-    DbSession dbSession = environment.get(DbSession.class);
-    dbSession.delete(this);
-
-    return null;
   }
 
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -14,7 +14,7 @@
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.wire.Descriptor;
 
-public abstract class JobImpl<T> implements Command<T>, Serializable, Job {
+public abstract class JobImpl implements Command<Boolean>, Serializable, Job {
 
   private static final long serialVersionUID = 1L;
   // private static final DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss,SSS");
@@ -28,8 +28,8 @@
   protected int dbversion;
 
   /** date until which the command should not be executed
-   * for async messages, this duedate should be set to null. */
-  protected Date duedate = null;
+   * for async messages, this due date should be set to null. */
+  protected Date dueDate;
   
   /** job state. */
   protected String state = STATE_WAITING;
@@ -148,16 +148,20 @@
   public String getLockOwner() {
     return lockOwner;
   }
-  /** @deprecated */
-  @Deprecated
   public Date getDueDate() {
-    return getDuedate();
+    return dueDate;
   }
+  public void setDueDate(Date dueDate) {
+    this.dueDate = dueDate;
+  }
+  @Deprecated
   public Date getDuedate() {
-    return duedate;
+    return getDueDate();
   }
+  /** @deprecated call {@link #setDueDate(Date)} instead */
+  @Deprecated
   public void setDuedate(Date duedate) {
-    this.duedate = duedate;
+    setDueDate(duedate);
   }
   public String getException() {
     return exception;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.pvm.internal.job;
 
+import org.jbpm.api.cmd.Environment;
 import org.jbpm.api.job.Message;
 import org.jbpm.pvm.internal.id.DbidGenerator;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -28,20 +29,28 @@
 /**
  * @author Tom Baeyens
  */
-public abstract class MessageImpl<T> extends JobImpl<T> implements Message {
+public abstract class MessageImpl extends JobImpl implements Message {
 
   private static final long serialVersionUID = 1L;
 
   public MessageImpl() {
   }
-  
+
   public String toString() {
-    return "message["+dbid+"]";
+    return "message[" + dbid + "]";
   }
-  
+
   public MessageImpl(ExecutionImpl execution) {
     this.execution = execution;
     this.processInstance = execution.getProcessInstance();
-    this.dbid = DbidGenerator.getDbidGenerator().getNextId(); 
+    this.dbid = DbidGenerator.getDbidGenerator().getNextId();
   }
+
+  public Boolean execute(Environment environment) throws Exception {
+    executeVoid(environment);
+    // always delete this message
+    return true;
+  }
+
+  protected abstract void executeVoid(Environment environment) throws Exception;
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/StartProcessTimer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/StartProcessTimer.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/StartProcessTimer.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -32,11 +32,9 @@
 import org.jbpm.pvm.internal.cal.CronExpression;
 import org.jbpm.pvm.internal.cal.Duration;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.session.RepositorySession;
 import org.jbpm.pvm.internal.util.Clock;
 
-
 /**
  * Job that starts a new process instance of a given process definition 
  * on a fixed duedate/periodic time.
@@ -51,26 +49,22 @@
 
   // Override execution logic of regular timer
   public Boolean execute(Environment environment) throws Exception {
-    
     if (LOG.isDebugEnabled()) {
       LOG.debug("Periodic start process triggered at " + Clock.getTime());
     }
-    
-    boolean processDefinitionExists = processDefinitionExists(environment);
-    boolean newDueDateCalculated = false;
-    
-    if (processDefinitionExists) {
+
+    // if process definition exists
+    if (processDefinitionExists(environment)) {
       startProcessInstance(environment);
-      newDueDateCalculated = calculateDueDate(environment);
-    } 
-    
-    if (!processDefinitionExists || !newDueDateCalculated) {
-      deleteThisJob(environment);
-    } else {
-      saveThisJob(environment);
+      // and a new date is appointed
+      if (calculateDueDate(environment)) {
+        // do not delete this timer
+        return false;
+      }
     }
-    
-    return null;
+
+    // delete timer otherwise
+    return true;
   }
   
   protected boolean processDefinitionExists(Environment environment) {
@@ -107,9 +101,9 @@
   protected boolean calculateDueDate(Environment environment) throws ParseException {
       
     if (getIntervalExpression() != null && Duration.isValidExpression(getIntervalExpression())) {
-      duedate = Duration.calculateDueDate(getIntervalExpression());
+      dueDate = Duration.calculateDueDate(getIntervalExpression());
     } else if (getIntervalExpression() != null &&  CronExpression.isValidExpression(getIntervalExpression())) {
-      duedate = new CronExpression(getIntervalExpression()).getNextValidTimeAfter(Clock.getTime());
+      dueDate = new CronExpression(getIntervalExpression()).getNextValidTimeAfter(Clock.getTime());
     } else {
       if (LOG.isDebugEnabled()) {
         LOG.debug("No next duedate calculated for start process job " +
@@ -119,41 +113,21 @@
     }
     
     if (LOG.isDebugEnabled()) {
-      LOG.debug("Next process start duedate: " + duedate);
+      LOG.debug("Next process start duedate: " + dueDate);
     }
     
     return true;
   }
   
-  protected void saveThisJob(Environment environment) {
-    DbSession dbSession = environment.get(DbSession.class);
-    if (dbSession == null) {
-      throw new JbpmException("no " + DbSession.class.getName() + " in environment"); 
-    }
-    dbSession.save(this);
-  }
-  
-  protected void deleteThisJob(Environment environment) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Deleting start process job for process definition with name " + getProcessDefinitionName());
-    }
-    
-    DbSession dbSession = environment.get(DbSession.class);
-    if (dbSession == null) {
-      throw new JbpmException("no " + DbSession.class.getName() + " in environment"); 
-    }
-    dbSession.delete(this);
-  }
-  
   @Override
   public void schedule() {
-    if (duedate == null && getIntervalExpression() != null) {
+    if (dueDate == null && getIntervalExpression() != null) {
       try {
         calculateDueDate(EnvironmentImpl.getCurrent());
       } catch (ParseException e) {
         throw new JbpmException("Cannot parse intervalExpression", e);
       }
-    } else if (duedate == null) {
+    } else if (dueDate == null) {
       throw new JbpmException("Cannot schedule start process timer: " +
                               "no duedate or intervalExpression set");
     }
@@ -165,7 +139,7 @@
     if (getProcessDefinitionName() == null) {
       throw new JbpmException("No process definition name set for start process timer");
     }
-    if (duedate == null && getIntervalExpression() == null) {
+    if (dueDate == null && getIntervalExpression() == null) {
       throw new JbpmException("No duedate or intervalExpression found for start process timer");
     }
   }
@@ -199,8 +173,8 @@
     if (getProcessDefinitionName() != null) {
       strb.append(getProcessDefinitionName());
     }
-    if (duedate != null) {
-      strb.append("| " + duedate);
+    if (dueDate != null) {
+      strb.append("| " + dueDate);
     }
     if (getIntervalExpression() != null) {
       strb.append("| " + getIntervalExpression());

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -34,7 +34,6 @@
 import org.jbpm.pvm.internal.jobexecutor.JobAddedNotification;
 import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
 import org.jbpm.pvm.internal.model.ObservableElement;
-import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.session.TimerSession;
 import org.jbpm.pvm.internal.tx.Transaction;
 import org.jbpm.pvm.internal.util.Clock;
@@ -48,7 +47,7 @@
  * @author Ronald Van Kuijk
  * @author Maciej Swiderski
  */
-public class TimerImpl extends JobImpl<Boolean> implements Timer {
+public class TimerImpl extends JobImpl implements Timer {
 
   private static final long serialVersionUID = 1L;
   private static final Log log = Log.getLog(TimerImpl.class.getName());
@@ -58,91 +57,88 @@
   protected String signalName;
   protected String eventName;
   protected String repeat;
-  
+
   public static final String EVENT_TIMER = "timer";
 
   public TimerImpl() {
   }
-  
+
   public void schedule() {
-    this.dbid = DbidGenerator.getDbidGenerator().getNextId(); 
+    this.dbid = DbidGenerator.getDbidGenerator().getNextId();
     TimerSession timerSession = EnvironmentImpl.getFromCurrent(TimerSession.class);
     timerSession.schedule(this);
   }
 
   public void setDueDateDescription(String dueDateDescription) {
     if (dueDateDescription != null) {
-      duedate = Duration.calculateDueDate(dueDateDescription);
+      dueDate = Duration.calculateDueDate(dueDateDescription);
     }
   }
 
   public Boolean execute(Environment environment) throws Exception {
-    if (log.isDebugEnabled()) log.debug("executing " + this);
-    
-    if (environment==null) {
+    if (log.isDebugEnabled())
+      log.debug("executing " + this);
+
+    if (environment == null) {
       throw new JbpmException("environment is null");
     }
-    
-    if (signalName!=null) {
-      if (log.isDebugEnabled()) log.debug("feeding timer signal "+signalName+" into "+execution);
-      
+
+    if (signalName != null) {
+      if (log.isDebugEnabled()) {
+        log.debug("feeding timer signal " + signalName + " into " + execution);
+      }
+
       // feed expiration signal
       execution.signal(signalName);
     }
-    
-    if (eventName!=null) {
+
+    if (eventName != null) {
       ObservableElement eventSource = execution.getActivity();
-      if (log.isDebugEnabled()) log.debug("firing event "+eventName+" into "+eventSource);
+      if (log.isDebugEnabled())
+        log.debug("firing event " + eventName + " into " + eventSource);
       execution.fire(eventName, eventSource);
     }
-    
-    boolean deleteThisJob = true;
+
     // if there is no repeat on this timer
-    if (repeat==null) {
-      // delete the job
-      if (log.isDebugEnabled()) log.debug("deleting " + this);
-      DbSession dbSession = environment.get(DbSession.class);
-      if (dbSession==null) {
-        throw new JbpmException("no "+DbSession.class.getName()+" in environment"); 
-      }
-      dbSession.delete(this);
+    if (repeat == null) {
+      // have the timer deleted
+      return true;
+    }
 
-    } else { // there is a repeat on this timer
-      deleteThisJob = false;
-      // suppose that it took the timer runner thread a very long time to execute the timers
-      // then the repeat action duedate could already have passed
-      do {
-        setDueDateDescription(repeat);
-      } while (duedate.getTime() <= Clock.getTime().getTime());
+    // suppose that it took the timer runner thread a very long time to execute the timers
+    // then the repeat action duedate could already have passed
+    do {
+      setDueDateDescription(repeat);
+    } while (dueDate.getTime() <= Clock.getTime().getTime());
 
-      if (log.isDebugEnabled()) log.debug("rescheduled "+this+" for "+formatDueDate(duedate));
-      
-      // release the lock on the timer
-      release();
-      
-      // notify the jobExecutor at the end of the transaction
-      JobExecutor jobExecutor = environment.get(JobExecutor.class);
-      if (jobExecutor!=null) {
-        Transaction transaction = environment.get(Transaction.class);
-        if (transaction==null) {
-          throw new JbpmException("no transaction in environment");
-        }
-        JobAddedNotification jobNotificator = new JobAddedNotification(jobExecutor);
-        transaction.registerSynchronization(jobNotificator);
+    if (log.isDebugEnabled())
+      log.debug("rescheduled " + this + " for " + formatDueDate(dueDate));
+
+    // release the lock on the timer
+    release();
+
+    // notify the jobExecutor at the end of the transaction
+    JobExecutor jobExecutor = environment.get(JobExecutor.class);
+    if (jobExecutor != null) {
+      Transaction transaction = environment.get(Transaction.class);
+      if (transaction == null) {
+        throw new JbpmException("no transaction in environment");
       }
+      JobAddedNotification jobNotificator = new JobAddedNotification(jobExecutor);
+      transaction.registerSynchronization(jobNotificator);
     }
-
-    return deleteThisJob;
+    // do not delete this timer
+    return false;
   }
-  
+
   public void validate() {
     if (getExecution() == null) {
       throw new JbpmException("timer has no execution specified");
     }
-    if ((getSignalName() == null) && (getEventName() == null)) {
+    if (getSignalName() == null && getEventName() == null) {
       throw new JbpmException("timer has no signalName or eventName specified");
     }
-    if (getDuedate() == null) {
+    if (getDueDate() == null) {
       throw new JbpmException("timer scheduled at null date");
     }
   }
@@ -152,8 +148,8 @@
     StringBuilder text = new StringBuilder();
     text.append("timer[");
     text.append(dbid);
-    if (duedate != null) {
-      text.append('|').append(formatDueDate(duedate));
+    if (dueDate != null) {
+      text.append('|').append(formatDueDate(dueDate));
     }
     if (signalName != null) {
       text.append('|').append(signalName);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -34,7 +34,6 @@
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -45,7 +44,7 @@
   private static final Log log = Log.getLog(AcquireJobsCmd.class.getName());
   private static final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
   
-  JobExecutor jobExecutor;
+  private JobExecutor jobExecutor;
 
   public AcquireJobsCmd(JobExecutor jobExecutor) {
     this.jobExecutor = jobExecutor;
@@ -55,23 +54,23 @@
     Collection<Long> acquiredJobDbids = new ArrayList<Long>();
 
     try {
-      Collection<JobImpl<?>> acquiredJobs = new ArrayList<JobImpl<?>>();
+      Collection<JobImpl> acquiredJobs = new ArrayList<JobImpl>();
       
       DbSession dbSession = environment.get(DbSession.class);
       if (log.isTraceEnabled()) log.trace("start querying first acquirable job...");
 
-      JobImpl<?> job = dbSession.findFirstAcquirableJob();
+      JobImpl job = dbSession.findFirstAcquirableJob();
 
       if (job!=null) {
         if (job.isExclusive()) {
           if (log.isTraceEnabled()) log.trace("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
-          List<JobImpl<?>> otherExclusiveJobs = dbSession.findExclusiveJobs(job.getProcessInstance());
+          List<JobImpl> otherExclusiveJobs = dbSession.findExclusiveJobs(job.getProcessInstance());
           acquiredJobs.addAll(otherExclusiveJobs);
         } else {
           acquiredJobs.add(job);
         }
 
-        for (JobImpl<?> acquiredJob: acquiredJobs) {
+        for (JobImpl acquiredJob: acquiredJobs) {
           long lockExpirationTime = System.currentTimeMillis()+jobExecutor.getLockMillis();
           if (log.isTraceEnabled()) log.trace("trying to obtain a lock for '"+acquiredJob+"' with exp "+timeFormat.format(new Date(lockExpirationTime)));
           acquiredJob.acquire(jobExecutor.getName(), new Date(lockExpirationTime));

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -29,8 +29,6 @@
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
-
-
 /**
  * @author Tom Baeyens
  */
@@ -40,17 +38,11 @@
 
   private static final Log log = Log.getLog(GetNextDueDateCmd.class.getName());
   
-  JobExecutor jobExecutor;
-
-  public GetNextDueDateCmd(JobExecutor jobExecutor) {
-    this.jobExecutor = jobExecutor;
-  }
-
   public Date execute(Environment environment) throws Exception {
     Date nextDueDate = null;
     if (log.isTraceEnabled()) log.trace("getting next due date...");
     DbSession dbSession = environment.get(DbSession.class);
-    JobImpl<?> job = dbSession.findFirstDueJob();
+    JobImpl job = dbSession.findFirstDueJob();
     if (job!=null) {
       nextDueDate = job.getDueDate();
     }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -75,7 +75,7 @@
     if (dbSession==null) {
       throw new JbpmException("no job-session configured to handle job");
     }
-    JobImpl<?> job = dbSession.get(JobImpl.class, jobDbid);
+    JobImpl job = dbSession.get(JobImpl.class, jobDbid);
     // serialize the stack trace
     StringWriter sw = new StringWriter();
     exception.printStackTrace(new PrintWriter(sw));

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -52,25 +52,25 @@
 
   // configuration parameters
   
-  CommandService commandService;
-  String name = "JobExecutor-"+getHostName();
-  int nbrOfThreads = 3;
-  int idleMillis = 5*1000; // default normal poll interval is 5 seconds
-  int idleMillisMax = 5*60*1000; // default max poll interval in case of continuous exceptions is 5 minutes
-  int historySize = 200;
-  int lockMillis = 30*60*1000; // default max lock time is 30 minutes
+  private CommandService commandService;
+  private String name = "JobExecutor-"+getHostName();
+  private int nbrOfThreads = 3;
+  private int idleMillis = 5*1000; // default normal poll interval is 5 seconds
+  private int idleMillisMax = 5*60*1000; // default max poll interval in case of continuous exceptions is 5 minutes
+  private int historySize = 200;
+  private int lockMillis = 30*60*1000; // default max lock time is 30 minutes
 
   // runtime state
 
-  Command<Collection<Long>> acquireJobsCommand;
-  Command<Date> nextDueDateCommand;
+  private Command<Collection<Long>> acquireJobsCommand;
+  private Command<Date> nextDueDateCommand;
   
-  boolean isActive;
+  private boolean isActive;
 
-  ExecutorService threadPool;
-  DispatcherThread dispatcherThread;
+  private ExecutorService threadPool;
+  private DispatcherThread dispatcherThread;
   
-  List<JobHistoryEntry> history = new ArrayList<JobHistoryEntry>();
+  private List<JobHistoryEntry> history = new ArrayList<JobHistoryEntry>();
   
   /** starts the {@link DispatcherThread} and {@link JobExecutorThread}s for this job executor */
   public synchronized void start() {
@@ -79,7 +79,7 @@
     }
     if (! isActive) {
       acquireJobsCommand = new AcquireJobsCmd(this);
-      nextDueDateCommand = new GetNextDueDateCmd(this);
+      nextDueDateCommand = new GetNextDueDateCmd();
       
       isActive = true;
       log.trace("starting thread pool for job executor '"+name+"'...");

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -32,7 +32,6 @@
 import org.jbpm.api.Configuration;
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
 
 /**
  * starts the job executor on init and closes the 
@@ -79,8 +78,9 @@
 
   private static final long serialVersionUID = 1L;
   
-  JobExecutor jobExecutor;
+  private JobExecutor jobExecutor;
   
+  @Override
   public void init() throws ServletException {
     String configurationResource = getInitParameter("jbpm.configuration.resource", "jbpm.cfg.xml");
     EnvironmentFactory environmentFactory = (EnvironmentFactory) new Configuration().setResource(configurationResource).buildProcessEngine();
@@ -91,6 +91,14 @@
     jobExecutor.start();
   }
   
+  @Override
+  public void destroy() {
+    if (jobExecutor != null) {
+      jobExecutor.stop(true);
+    }
+  }
+
+  @Override
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     PrintWriter out = response.getWriter();
     out.println("<html>");

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -15,8 +15,9 @@
 
 import java.util.List;
 
-import org.hibernate.Query;
 import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.job.Timer;
@@ -24,6 +25,7 @@
 import org.jbpm.pvm.internal.job.TimerImpl;
 import org.jbpm.pvm.internal.session.TimerSession;
 import org.jbpm.pvm.internal.tx.Transaction;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * Timers created with this service are committed at the end of the transaction,
@@ -77,12 +79,9 @@
   }
 
   public List<Timer> findTimersByExecution(Execution execution) {
-    Query query = session.createQuery(
-      "select timer " +
-      "from "+TimerImpl.class.getName()+" timer " +
-      "where timer.execution = :execution"
-    );
-    query.setEntity("execution", execution);
-    return query.list();
+    List<?> timers = session.createCriteria(TimerImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .list();
+    return CollectionUtil.checkList(timers, Timer.class);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.pvm.internal.model;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,7 +31,7 @@
 /**
  * @author Tom Baeyens
  */
-public class EventImpl extends ProcessElementImpl implements Serializable, Event {
+public class EventImpl extends ProcessElementImpl implements Event {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -639,7 +639,7 @@
     if (messageSession==null) {
       throw new JbpmException("no message-session configured to send asynchronous continuation message");
     }
-    MessageImpl<?> asyncMessage = operation.createAsyncMessage(this);
+    MessageImpl asyncMessage = operation.createAsyncMessage(this);
     setState(Execution.STATE_ASYNC);
     messageSession.send(asyncMessage);
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -90,10 +90,7 @@
   public void setDescription(String description) {
     this.description = description;
   }
-  public Map<String, Event> getEvents() {
-    return (Map) events;
+  public Map<String, ? extends Event> getEvents() {
+    return events;
   }
-  public void setEvents(Map<String, EventImpl> events) {
-    this.events = events;
-  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,7 +27,6 @@
 import java.util.List;
 import java.util.Set;
 
-import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.wire.Descriptor;
 
 /** 
@@ -39,7 +38,6 @@
 public class ProcessElementImpl implements Serializable {
 
   private static final long serialVersionUID = 1L;
-  private static final Log log = Log.getLog(ProcessElementImpl.class.getName());
 
   protected long dbid;
   protected int dbversion;
@@ -81,7 +79,7 @@
 
   public Set<String> getPropertyKeys() {
     if (properties==null) {
-      return Collections.EMPTY_SET;
+      return Collections.emptySet();
     }
     return properties.keys();
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -101,21 +101,8 @@
   protected Variable createVariableObject(String key, Object value, String typeName, boolean isHistoryEnabled) {
     log.debug("create variable '"+key+"' in '"+this+"' with value '"+value+"'");
     
-    Type type = null;
-    
-    if (type==null) {
-      TypeSet typeSet = EnvironmentImpl.getFromCurrent(TypeSet.class, false);
-      if (typeSet!=null) {
-        if (typeName!=null) {
-          type = typeSet.findTypeByName(typeName);
-        }
-        if (type==null) {
-          type = typeSet.findTypeByMatch(key, value);
-        }
-      }
-    }
-    
-    Variable variable = null;
+    Type type = findType(key, value, typeName);
+    Variable variable;
 
     if (type!=null) {
       Class<?> variableClass = type.getVariableClass();
@@ -154,6 +141,17 @@
     return variable;
   }
 
+  private static Type findType(String key, Object value, String typeName) {
+    TypeSet typeSet = EnvironmentImpl.getFromCurrent(TypeSet.class, false);
+    if (typeSet == null) return null;
+
+    Type type;
+    if (typeName == null || (type = typeSet.findTypeByName(typeName)) == null) {
+      type = typeSet.findTypeByMatch(key, value);
+    }
+    return type;
+  }
+
   public void setVariable(String key, Object value) {
     if (key==null) {
       throw new JbpmException("variableName is null");
@@ -301,12 +299,12 @@
     if (timerDefinition!=null) {
       timer.setEventName(timerDefinition.getEventName());
       timer.setSignalName(timerDefinition.getSignalName());
-      timer.setDuedate(timerDefinition.getDueDate());
+      timer.setDueDate(timerDefinition.getDueDate());
       timer.setDueDateDescription(timerDefinition.getDueDateDescription());
       
-      if (timer.getDuedate() == null && timerDefinition.getCronExpression() != null) {
+      if (timer.getDueDate() == null && timerDefinition.getCronExpression() != null) {
         try {
-          timer.setDuedate(new CronExpression(timerDefinition.getCronExpression()).getNextValidTimeAfter(Clock.getTime()));
+          timer.setDueDate(new CronExpression(timerDefinition.getCronExpression()).getNextValidTimeAfter(Clock.getTime()));
         } catch (ParseException pe) {
           throw new JbpmException("Can't parse cron expression " + timerDefinition.getCronExpression(), pe);
         }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -65,7 +65,7 @@
   
   public List<VariableOutDefinitionImpl> getVariableOutDefinitions() {
     if (variableOutDefinitions==null) {
-      return Collections.EMPTY_LIST;
+      return Collections.emptyList();
     }
     return variableOutDefinitions;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -49,7 +49,7 @@
 
   public Set<String> keys() {
     if (wireContext==null) {
-      return Collections.EMPTY_SET;
+      return Collections.emptySet();
     }
     return wireContext.keys();
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -41,7 +41,7 @@
   public static final AtomicOperation TRANSITION_END_ACTIVITY = new TransitionEndActivity();
 
   public abstract boolean isAsync(ExecutionImpl execution);
-  public abstract MessageImpl<?> createAsyncMessage(ExecutionImpl execution);
+  public abstract MessageImpl createAsyncMessage(ExecutionImpl execution);
   public abstract void perform(ExecutionImpl execution);
   
   public static AtomicOperation parseAtomicOperation(String text) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -34,7 +34,7 @@
   
   private static final long serialVersionUID = 1L;
   
-  private static Log log = Log.getLog(ExecuteActivity.class.getName());
+  private static final Log log = Log.getLog(ExecuteActivity.class.getName());
   
   public boolean isAsync(ExecutionImpl execution) {
     return execution.getActivity().isAsync();
@@ -72,7 +72,7 @@
     return "ExecuteActivity";
   }
 
-  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     ExecuteActivityMessage executeActivityMessage = new ExecuteActivityMessage(execution);
     if (execution.getActivity().getContinuation()==Continuation.EXCLUSIVE) {
       executeActivityMessage.setExclusive(true);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,12 +24,11 @@
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Tom Baeyens
  */
-public class ExecuteActivityMessage extends MessageImpl<Object> {
+public class ExecuteActivityMessage extends MessageImpl {
 
   private static final long serialVersionUID = 1L;
 
@@ -40,15 +39,10 @@
     super(execution);
   }
 
-  public Object execute(Environment environment) throws Exception {
+  protected void executeVoid(Environment environment) throws Exception {
     AsyncContinuations.restoreState(execution);
     
     execution.performAtomicOperationSync(AtomicOperation.EXECUTE_ACTIVITY);
-
-    DbSession dbSession = environment.get(DbSession.class);
-    dbSession.delete(this);
-
-    return null;
   }
 
   public String toString() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -32,7 +32,6 @@
 import org.jbpm.pvm.internal.model.ObservableElement;
 import org.jbpm.pvm.internal.model.ObservableElementImpl;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -126,7 +125,7 @@
     }
   }
 
-  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     return new ExecuteEventListenerMessage(execution);
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -32,12 +32,11 @@
 import org.jbpm.pvm.internal.model.ObservableElementImpl;
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.internal.model.TransitionImpl;
-import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Tom Baeyens
  */
-public class ExecuteEventListenerMessage extends MessageImpl<Object> {
+public class ExecuteEventListenerMessage extends MessageImpl {
 
   private static final String KEY_EVENT_COMPLETED_OPERATION = "ECO";
   private static final String KEY_EVENT_LISTENER_INDEX = "ELI";
@@ -105,7 +104,7 @@
     return parentLevel;
   }
 
-  public Object execute(Environment environment) throws Exception {
+  protected void executeVoid(Environment environment) throws Exception {
     Map<?, ?> asyncExecutionInfo = (Map<?, ?>) getConfiguration();
 
     String transitionSourceName = (String) asyncExecutionInfo.get(KEY_TRANSITION_SOURCE);
@@ -152,10 +151,5 @@
     execution.setState((String) asyncExecutionInfo.get(KEY_STATE));
 
     execution.performAtomicOperationSync(AtomicOperation.EXECUTE_EVENT_LISTENER);
-    
-    DbSession dbSession = environment.get(DbSession.class);
-    dbSession.delete(this);
-
-    return null;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,7 +25,6 @@
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.model.ActivityImpl;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -33,7 +32,7 @@
   
   private static final long serialVersionUID = 1L;
 
-  ActivityImpl activity;
+  private ActivityImpl activity;
 
   public MoveToChildActivity(ActivityImpl activity) {
     this.activity = activity;
@@ -49,7 +48,7 @@
     return false;
   }
 
-  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     return null;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -41,7 +41,7 @@
     propagatingExecution.performAtomicOperation(new Signal(null, null));
   }
 
-  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     return null;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -87,7 +87,7 @@
   }
 
   @Override
-  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     return null;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,12 +27,11 @@
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Tom Baeyens
  */
-public class SignalMessage extends MessageImpl<Object> {
+public class SignalMessage extends MessageImpl {
   
   private static final long serialVersionUID = 1L;
   
@@ -48,16 +47,11 @@
     this.parameters = parameters;
   }
 
-  public Object execute(Environment environment) throws Exception {
+  protected void executeVoid(Environment environment) throws Exception {
     execution.setState(Execution.STATE_ACTIVE_ROOT);
     
     Signal signal = new Signal(signalName, parameters);
     execution.performAtomicOperationSync(signal);
-    
-    DbSession dbSession = environment.get(DbSession.class);
-    dbSession.delete(this);
-
-    return null;
   }
 
   public String toString() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,9 +25,7 @@
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.model.ActivityImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ObservableElementImpl;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -59,7 +57,7 @@
     }
   }
 
-  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     throw new UnsupportedOperationException("please implement me");
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -86,7 +86,7 @@
     }
   }
   
-  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     throw new UnsupportedOperationException("please implement me");
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,12 +24,11 @@
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Tom Baeyens
  */
-public class TransitionStartActivityMessage extends MessageImpl<Object> {
+public class TransitionStartActivityMessage extends MessageImpl {
 
   private static final long serialVersionUID = 1L;
 
@@ -40,15 +39,10 @@
     super(execution);
   }
 
-  public Object execute(Environment environment) throws Exception {
+  protected void executeVoid(Environment environment) throws Exception {
     AsyncContinuations.restoreState(execution);
 
     execution.performAtomicOperationSync(AtomicOperation.TRANSITION_START_ACTIVITY);
-    
-    DbSession dbSession = environment.get(DbSession.class);
-    dbSession.delete(this);
-
-    return null;
   }
   
   public String toString() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -44,7 +44,7 @@
     execution.fire(Event.TAKE, transition, AtomicOperation.TRANSITION_START_ACTIVITY);
   }
 
-  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
+  public MessageImpl createAsyncMessage(ExecutionImpl execution) {
     return null;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -22,17 +22,17 @@
 package org.jbpm.pvm.internal.processengine;
 
 import org.hibernate.cfg.Configuration;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
+
 import org.jbpm.api.ProcessEngine;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cfg.ConfigurationImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.env.PvmEnvironment;
 import org.jbpm.pvm.internal.env.SpringContext;
 import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
 
 /**
  * this environment factory will see only the singleton beans.
@@ -42,7 +42,7 @@
  *
  * @author Andries Inze
  */
-public class SpringProcessEngine extends ProcessEngineImpl implements EnvironmentFactory, ProcessEngine {
+public class SpringProcessEngine extends ProcessEngineImpl {
 
   private static final Log log = Log.getLog(SpringProcessEngine.class.getName());
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,6 +27,7 @@
 import org.jbpm.api.Deployment;
 import org.jbpm.api.DeploymentQuery;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 
 /**
@@ -102,7 +103,7 @@
   }
 
   public List<Deployment> list() {
-    return (List<Deployment>) untypedList();
+    return CollectionUtil.checkList(untypedList(), Deployment.class);
   }
 
   public Deployment uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -29,6 +29,7 @@
 import org.jbpm.api.history.HistoryActivityInstance;
 import org.jbpm.api.history.HistoryActivityInstanceQuery;
 import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 
 /**
@@ -117,7 +118,7 @@
   }
 
   public List<HistoryActivityInstance> list() {
-    return (List) untypedList();
+    return CollectionUtil.checkList(untypedList(), HistoryActivityInstance.class);
   }
   
   public HistoryActivityInstance uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -29,6 +29,7 @@
 import org.jbpm.api.history.HistoryDetailQuery;
 import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 
 /**
@@ -88,7 +89,7 @@
   }
 
   public List<HistoryDetail> list() {
-    return (List) untypedList();
+    return CollectionUtil.checkList(untypedList(), HistoryDetail.class);
   }
   
   public HistoryDetail uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -28,6 +28,7 @@
 import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstanceQuery;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
@@ -101,7 +102,7 @@
   }
 
   public List<HistoryProcessInstance> list() {
-    return (List) untypedList();
+    return CollectionUtil.checkList(untypedList(), HistoryProcessInstance.class);
   }
   
   public HistoryProcessInstance uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,12 +25,12 @@
 import java.util.List;
 
 import org.hibernate.Query;
+
 import org.jbpm.api.history.HistoryTask;
 import org.jbpm.api.history.HistoryTaskQuery;
 import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
-import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -120,7 +120,7 @@
   }
 
   public List<HistoryTask> list() {
-    return (List) untypedList();
+    return CollectionUtil.checkList(untypedList(), HistoryTask.class);
   }
   
   public HistoryTask uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -29,6 +29,7 @@
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 
 /**
@@ -84,7 +85,7 @@
   }
 
   public List<Job> list() {
-    return (List<Job>) untypedList();
+    return CollectionUtil.checkList(untypedList(), Job.class);
   }
   
   public Job uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -36,6 +36,7 @@
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
 import org.jbpm.pvm.internal.repository.DeploymentProperty;
 import org.jbpm.pvm.internal.session.RepositorySession;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 
 /** returns partially initialized ProcessDefinitionImpl's that can only be exposed 
@@ -153,7 +154,7 @@
   }
   
   public List<ProcessDefinition> list() {
-    return (List<ProcessDefinition>) untypedList();
+    return CollectionUtil.checkList(untypedList(), ProcessDefinition.class);
   }
   
   public ProcessDefinition uniqueResult() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,6 +27,7 @@
 import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.ProcessInstanceQuery;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
@@ -45,7 +46,7 @@
   }
 
   public List<ProcessInstance> list() {
-    return (List<ProcessInstance>) untypedList();
+    return CollectionUtil.checkList(untypedList(), ProcessInstance.class);
   }
 
   public String hql() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -39,6 +39,7 @@
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.task.ParticipationImpl;
 import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
@@ -241,9 +242,9 @@
   }
 
   public List<Task> list() {
-    return (List<Task>) commandService.execute(this);
+    return CollectionUtil.checkList(untypedList(), Task.class);
   }
-  
+
   public Task uniqueResult() {
     return (Task) untypedUniqueResult();
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -31,7 +31,6 @@
 import org.jbpm.api.ProcessDefinitionQuery;
 import org.jbpm.api.RepositoryService;
 import org.jbpm.api.model.ActivityCoordinates;
-import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.cmd.CreateDeploymentQueryCmd;
 import org.jbpm.pvm.internal.cmd.CreateProcessDefinitionQueryCmd;
 import org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,6 +27,7 @@
 
 import org.hibernate.Query;
 import org.hibernate.Session;
+
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.NewDeployment;
 import org.jbpm.api.ProcessDefinition;
@@ -37,6 +38,7 @@
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
 import org.jbpm.pvm.internal.session.RepositorySession;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
@@ -78,8 +80,8 @@
         "  and execution.state != '"+ExecutionImpl.STATE_SUSPENDED+"'"   
       );
       query.setParameterList("processDefinitionIds", processDefinitionIds);
-      List<ExecutionImpl> executions = query.list();
-      for (ExecutionImpl execution: executions) {
+      List<?> executions = query.list();
+      for (ExecutionImpl execution: CollectionUtil.checkList(executions, ExecutionImpl.class)) {
         execution.suspend();
       }
     }
@@ -103,8 +105,8 @@
         "  and execution.state = '"+ExecutionImpl.STATE_SUSPENDED+"'"   
       );
       query.setParameterList("processDefinitionIds", processDefinitionIds);
-      List<ExecutionImpl> executions = query.list();
-      for (ExecutionImpl execution: executions) {
+      List<?> executions = query.list();
+      for (ExecutionImpl execution: CollectionUtil.checkList(executions, ExecutionImpl.class)) {
         execution.resume();
       }
     }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/BshScriptEngine.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/BshScriptEngine.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/BshScriptEngine.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -112,7 +112,7 @@
 		if ( ns == null )
 		{
 			// Create a global namespace for the interpreter
-			Map engineView = new ScriptContextEngineView( scriptContext );
+			Map<String, Object> engineView = new ScriptContextEngineView( scriptContext );
 			ns = new ExternalNameSpace(
 				null/*parent*/, "javax_script_context", engineView );
 
@@ -263,7 +263,7 @@
 	public <T> T getInterface( Class<T> clasz )
 	{
 		try {
-			return (T) getGlobal().getInterface( clasz );
+			return clasz.cast(getGlobal().getInterface( clasz ));
 		} catch ( UtilEvalError utilEvalError ) {
 			utilEvalError.printStackTrace();
 			return null;
@@ -296,7 +296,7 @@
 
 		try {
 			bsh.This bshThis = (bsh.This)thiz;
-			return (T) bshThis.getInterface( clasz );
+			return clasz.cast(bshThis.getInterface( clasz ));
 		} catch ( UtilEvalError utilEvalError ) {
 			utilEvalError.printStackTrace( System.err );
 			return null;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/GroovyScriptEngine.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/GroovyScriptEngine.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/GroovyScriptEngine.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -31,6 +31,7 @@
 package org.jbpm.pvm.internal.script;
 import java.io.*;
 import java.util.*;
+
 import javax.script.*;
 import groovy.lang.*;
 import org.codehaus.groovy.syntax.SyntaxException;
@@ -47,7 +48,7 @@
     private static boolean DEBUG = false;
 
     // script-string-to-generated Class map
-    private Map<String, Class> classMap;
+    private Map<String, Class<?>> classMap;
     // global closures map - this is used to simulate a single
     // global functions namespace 
     private Map<String, Closure> globalClosures;
@@ -64,8 +65,8 @@
     }
     
     public GroovyScriptEngine() {    
-        classMap = Collections.synchronizedMap(new HashMap<String, Class>());
-        globalClosures = Collections.synchronizedMap(new HashMap<String, Closure>());
+        classMap = new Hashtable<String, Class<?>>();
+        globalClosures = new Hashtable<String, Closure>();
         loader = new GroovyClassLoader(getParentLoader(),
                                        new CompilerConfiguration());
     }
@@ -148,7 +149,7 @@
     }
 
     // package-privates
-    Object eval(Class scriptClass, final ScriptContext ctx) throws ScriptException {
+    Object eval(Class<?> scriptClass, final ScriptContext ctx) throws ScriptException {
         //add context to bindings
         ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
         
@@ -246,11 +247,11 @@
         }
     }
 
-    Class getScriptClass(String script) 
+    Class<?> getScriptClass(String script) 
                          throws SyntaxException, 
                                 CompilationFailedException, 
                                 IOException {
-        Class clazz = classMap.get(script);
+        Class<?> clazz = classMap.get(script);
         if (clazz != null) {
             return clazz;
         }
@@ -261,10 +262,7 @@
         return clazz;
     }
 
-    //-- Internals only below this point
-
-    // invokes the specified method/function on the given object.
-    private Object invokeImpl(Object thiz, String name, Object... args) 
+    Object invokeImpl(Object thiz, String name, Object... args) 
              throws ScriptException, NoSuchMethodException  {
         if (name == null) {
             throw new NullPointerException("method name is null");
@@ -288,7 +286,7 @@
         return callGlobal(name, args, context);
     }
 
-    private Object callGlobal(String name, Object[] args, ScriptContext ctx) {
+    Object callGlobal(String name, Object[] args, ScriptContext ctx) {
         Closure closure = globalClosures.get(name);
         if (closure != null) {
             return closure.call(args);
@@ -313,7 +311,7 @@
         if (clazz == null || !clazz.isInterface()) {
             throw new IllegalArgumentException("interface Class expected");
         }
-        return (T) Proxy.newProxyInstance(
+        return clazz.cast(Proxy.newProxyInstance(
             clazz.getClassLoader(),
             new Class[] { clazz },
             new InvocationHandler() {
@@ -321,7 +319,7 @@
                                      throws Throwable {
                     return invokeImpl(thiz, m.getName(), args);
                 }
-            });
+            }));
     }
 
     // determine appropriate class loader to serve as parent loader
@@ -330,7 +328,7 @@
         // check whether thread context loader can "see" Groovy Script class
         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
         try {
-            Class c = ctxtLoader.loadClass("org.codehaus.groovy.Script");
+            Class<?> c = ctxtLoader.loadClass("org.codehaus.groovy.Script");
             if (c == Script.class) {
                 return ctxtLoader;
             }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/JuelScriptEngine.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/JuelScriptEngine.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/JuelScriptEngine.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -25,7 +25,6 @@
 import java.io.Reader;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.Properties;
 
 import javax.el.ArrayELResolver;
 import javax.el.BeanELResolver;
@@ -59,7 +58,7 @@
     implements Compilable
 {
   private ScriptEngineFactory factory;
-  private ExpressionFactory exprFactory;
+  ExpressionFactory exprFactory;
 
   public JuelScriptEngine(ScriptEngineFactory factory)
   {
@@ -162,7 +161,7 @@
     return elContext;
   }
 
-  private ELResolver makeResolver()
+  ELResolver makeResolver()
   {
     CompositeELResolver chain = new CompositeELResolver();
 
@@ -231,7 +230,7 @@
 
   private static Method getPrintMethod()
   {
-    Class myClass;
+    Class<?> myClass;
     try
     {
       myClass = JuelScriptEngine.class;
@@ -255,7 +254,7 @@
 
   private static Method getImportMethod()
   {
-    Class myClass;
+    Class<?> myClass;
     try
     {
       myClass = JuelScriptEngine.class;
@@ -277,11 +276,11 @@
 
   public static void importFunctions(ScriptContext ctx, String namespace, Object obj)
   {
-    Class clazz = null;
+    Class<?> clazz = null;
 
-    if (obj instanceof Class)
+    if (obj instanceof Class<?>)
     {
-      clazz = (Class)obj;
+      clazz = (Class<?>)obj;
     } else {
       if (obj instanceof String)
       {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptContextEngineView.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptContextEngineView.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptContextEngineView.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -84,7 +84,7 @@
 	 */
 	public boolean containsValue( Object value )
 	{
-		Set values = totalValueSet();
+		Set<Object> values = totalValueSet();
 		return values.contains( value );
 	}
 
@@ -208,7 +208,7 @@
 	 *
 	 * @return a set view of the keys contained in this map.
 	 */
-	public Set keySet()
+	public Set<String> keySet()
 	{
 		return totalKeySet();
 	}
@@ -220,7 +220,7 @@
 	 *
 	 * @return a collection view of the values contained in this map.
 	 */
-	public Collection values()
+	public Collection<Object> values()
 	{
 		return totalValueSet();
 	}
@@ -245,18 +245,18 @@
 		throw new Error("unimplemented");
 	}
 
-	private Set totalKeySet()
+	private Set<String> totalKeySet()
 	{
-		Set keys = new HashSet();
+		Set<String> keys = new HashSet<String>();
 		List<Integer> scopes = context.getScopes();
 		for ( int i : scopes ) {
 			keys.addAll( context.getBindings( i ).keySet() );
 		}
 		return Collections.unmodifiableSet(keys);
 	}
-	private Set totalValueSet()
+	private Set<Object> totalValueSet()
 	{
-		Set values = new HashSet();
+		Set<Object> values = new HashSet<Object>();
 		List<Integer> scopes = context.getScopes();
 		for ( int i : scopes ) {
 			values.addAll( context.getBindings( i ).values() );

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/XPathScriptEngine.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/XPathScriptEngine.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/XPathScriptEngine.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -151,7 +151,7 @@
   // Internals only below this point
 
   // find a variable of given qname in given context
-  private static Object findVariable(QName qname, ScriptContext ctx) {
+  static Object findVariable(QName qname, ScriptContext ctx) {
     String name;
     int scope;
 
@@ -178,23 +178,6 @@
     return null;
   }
 
-  private static void collectNamespaces(Map<String, String> map, Bindings scope) {
-    for (String key : scope.keySet()) {
-      if (key.startsWith(XMLNS_COLON)) {
-        Object uri = scope.get(key);
-        // collect all variables starting with "xmlns:" and
-        // collect the prefix to URI mappings.
-        String prefix = key.substring(XMLNS_COLON.length());
-        if (uri instanceof String) {
-          String tmp = (String) uri;
-          if (tmp.length() != 0) {
-            map.put(prefix, tmp);
-          }
-        }
-      }
-    }
-  }
-
   private static NamespaceContext makeNamespaceContext(ScriptContext ctx) {
     // namespace prefix-to-URI mappings
     final Map<String, String> namespaces = new HashMap<String, String>();
@@ -246,11 +229,11 @@
         return null;
       }
 
-      public Iterator getPrefixes(String namespaceURI) {
+      public Iterator<String> getPrefixes(String namespaceURI) {
         if (namespaceURI == null) {
           throw new IllegalArgumentException();
         }
-        List list = new ArrayList();
+        List<String> list = new ArrayList<String>();
         for (String prefix : namespaces.keySet()) {
           String uri = namespaces.get(prefix);
           if (namespaceURI.equals(uri)) {
@@ -262,12 +245,12 @@
     };
   }
 
-  private static XPathFunction makeXPathFunction(final Constructor ctr, int arity) {
+  private static XPathFunction makeXPathFunction(final Constructor<?> ctr, int arity) {
     if (ctr.getParameterTypes().length != arity) {
       return null;
     }
     return new XPathFunction() {
-
+      @SuppressWarnings("unchecked")
       public Object evaluate(List args) {
         try {
           return ctr.newInstance(args.toArray());
@@ -284,7 +267,7 @@
     if (Modifier.isStatic(modifiers) && numArgs == arity) {
       // static method. expose "as is".
       return new XPathFunction() {
-
+        @SuppressWarnings("unchecked")
         public Object evaluate(List args) {
           try {
             return method.invoke(null, args.toArray());
@@ -296,9 +279,9 @@
     } else if ((numArgs + 1) == arity) {
       // instance method. treat the first arg as 'this'
       return new XPathFunction() {
-
+        @SuppressWarnings("unchecked")
         public Object evaluate(List args) {
-          List tmp = args.subList(1, args.size());
+          List<?> tmp = args.subList(1, args.size());
           try {
             return method.invoke(args.get(0), tmp.toArray());
           } catch (Exception exp) {
@@ -313,7 +296,7 @@
 
   private static XPathFunction makeXPathFunction(final String funcName, final Invocable invocable) {
     return new XPathFunction() {
-
+      @SuppressWarnings("unchecked")
       public Object evaluate(List args) {
         try {
           return invocable.invokeFunction(funcName, args.toArray());
@@ -325,7 +308,7 @@
   }
 
   // make a XPathFunction from given object
-  private static XPathFunction makeXPathFunction(QName qname, Object obj, int arity) {
+  static XPathFunction makeXPathFunction(QName qname, Object obj, int arity) {
     if (obj == null) {
       return null;
     } else if (obj instanceof XPathFunction) {
@@ -334,9 +317,9 @@
     } else if (obj instanceof Method) {
       // a Method object. wrap as XPathFunction
       return makeXPathFunction((Method) obj, arity);
-    } else if (obj instanceof Constructor) {
+    } else if (obj instanceof Constructor<?>) {
       // a Constructor object. wrap as XPathFunction
-      return makeXPathFunction((Constructor) obj, arity);
+      return makeXPathFunction((Constructor<?>) obj, arity);
     } else if (obj instanceof Invocable) {
       // wrap a script function as XPathFunction. Using this,
       // scripts from other languages (for eg. JavaScript) can use
@@ -404,7 +387,7 @@
     }
     return null;
   }
-  private Object evalXPath(XPathExpression expr, final ScriptContext ctx) throws ScriptException {
+  Object evalXPath(XPathExpression expr, final ScriptContext ctx) throws ScriptException {
 
     try {
       Object resultType = getVariable(ctx, XPATH_RESULT_TYPE);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -94,13 +94,13 @@
   // job methods //////////////////////////////////////////////////////////////
 
   /** the first job to finish among eligible and non-locked jobs or null if none */
-  public JobImpl<?> findFirstAcquirableJob();
+  public JobImpl findFirstAcquirableJob();
 
   /** the list of jobs of the process instance that mustn't be concurrent */
-  public List<JobImpl<?>> findExclusiveJobs(Execution processInstance);
+  public List<JobImpl> findExclusiveJobs(Execution processInstance);
 
   /** the first job to finish among non-owned jobs or null if none */
-  public JobImpl<?> findFirstDueJob();
+  public JobImpl findFirstDueJob();
   
   /** returns a list of start process timers for the given process definition */
   public List<StartProcessTimer> findStartProcessTimers(String processDefinitionId);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,21 +24,19 @@
 import org.jbpm.api.Execution;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
-import org.jbpm.api.job.Job;
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.job.MessageImpl;
 
-
 /**
  * @author Tom Baeyens
  */
-public class AsyncCommandMessage extends MessageImpl<Object> {
+public class AsyncCommandMessage extends MessageImpl {
 
   private static final long serialVersionUID = 1L;
 
-  Command<?> command;
-  String userId;
+  private Command<?> command;
+  private String userId;
   
   public AsyncCommandMessage(Command<?> command) {
     this.command = command;
@@ -49,22 +47,23 @@
     this.userId = userId;
   }
 
-  public Object execute(Environment environmentInterface) throws Exception {
-    EnvironmentImpl environment = (EnvironmentImpl) environmentInterface;
+  protected void executeVoid(Environment environment) throws Exception {
     execution.setState(Execution.STATE_ACTIVE_ROOT);
 
-    if (userId!=null) {
-      environment.setAuthenticatedUserId(userId);
-    }
-    try {
-      CommandService commandService = environment.get(CommandService.class);
+    CommandService commandService = environment.get(CommandService.class);
+    if (userId == null) {
       commandService.execute(command);
-    } finally {
-      if (userId!=null) {
-        environment.setAuthenticatedUserId(null);
+    }
+    else {
+      EnvironmentImpl environmentImpl = (EnvironmentImpl) environment;
+      environmentImpl.setAuthenticatedUserId(userId);
+      try {
+        commandService.execute(command);
       }
+      finally {
+        environmentImpl.setAuthenticatedUserId(null);
+      }
     }
-    return null;
   }
   
   public String toString() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializeInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializeInterceptor.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializeInterceptor.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,6 +23,7 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
@@ -30,32 +31,38 @@
 import org.jbpm.api.cmd.Command;
 import org.jbpm.internal.log.Log;
 
-
 /**
  * @author Tom Baeyens
  */
 public class SerializeInterceptor extends Interceptor {
-  
+
   private static final Log log = Log.getLog(SerializeInterceptor.class.getName());
 
+  @SuppressWarnings("unchecked")
   public <T> T execute(Command<T> command) {
-    log.info("serializing command "+command);
+    log.info("serializing command " + command);
     Command<T> serializedCommand = (Command<T>) serialize(command);
     T returnValue = next.execute(serializedCommand);
-    T serializedReturnValue = (T) serialize(returnValue);
-    return serializedReturnValue;
+    return (T) serialize(returnValue);
   }
 
-  public Object serialize(Object o) {
+  private static Object serialize(Object o) {
     try {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       ObjectOutputStream oos = new ObjectOutputStream(baos);
       oos.writeObject(o);
+      oos.close();
+
       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
       ObjectInputStream ois = new ObjectInputStream(bais);
       return ois.readObject();
-    } catch (Exception e) {
+    }
+    catch (IOException e) {
       throw new JbpmException("serialization exception", e);
     }
+    catch (ClassNotFoundException e) {
+      // should not happen, class is already loaded
+      throw new AssertionError(e);
+    }
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,12 +21,10 @@
  */
 package org.jbpm.pvm.internal.task;
 
-import java.io.Serializable;
-
 /**
  * is a process role (aka participatingUser).
  */
-public class SwimlaneDefinitionImpl extends AssignableDefinitionImpl implements Serializable {
+public class SwimlaneDefinitionImpl extends AssignableDefinitionImpl {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.pvm.internal.task;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -30,7 +29,7 @@
 /**
  * defines a task and how the actor(s) must be calculated at runtime.
  */
-public class TaskDefinitionImpl extends AssignableDefinitionImpl implements Serializable {
+public class TaskDefinitionImpl extends AssignableDefinitionImpl {
   
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -34,9 +34,9 @@
 public class SpringCommandCallback implements TransactionCallback {
   
   CommandService next;
-  Command<Object> command;
+  Command<?> command;
 
-  public SpringCommandCallback(CommandService next, Command command) {
+  public SpringCommandCallback(CommandService next, Command<?> command) {
     this.next = next;
     this.command = command;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransaction.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransaction.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -27,11 +27,10 @@
 
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-
 /**
  * @author Tom Baeyens
  */
-public class SpringTransaction extends AbstractTransaction implements Transaction, Serializable {
+public class SpringTransaction extends AbstractTransaction implements Serializable {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -24,8 +24,6 @@
 import org.hibernate.transaction.JDBCTransaction;
 import org.hibernate.transaction.TransactionFactory;
 
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
 /**
  * Spring-aware implementation of the Hibernate TransactionFactory interface, aware of
  * Spring-synchronized transactions (in particular Spring-managed JTA transactions)

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -35,7 +35,7 @@
  * non thread safe (which is ok).
  * @author Tom Baeyens
  */
-public class StandardTransaction extends AbstractTransaction implements Transaction, Serializable {
+public class StandardTransaction extends AbstractTransaction implements Serializable {
 
   private static final long serialVersionUID = 1L; 
   private static Log log = Log.getLog(StandardTransaction.class.getName());

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,11 +23,9 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.Command;
-import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.svc.Interceptor;
 
-
 /** calls setRollbackOnly on the transaction in the environment 
  * in case an exception occurs during execution of the command.
  * 
@@ -35,8 +33,6 @@
  */
 public class StandardTransactionInterceptor extends Interceptor {
   
-  private static final Log log = Log.getLog(StandardTransactionInterceptor.class.getName());
-  
   public <T> T execute(Command<T> command) {
     EnvironmentImpl environment = EnvironmentImpl.getCurrent();
     if (environment==null) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -30,7 +30,6 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
 import org.jbpm.pvm.internal.repository.DeploymentObjectInputStream;
 import org.jbpm.pvm.internal.tx.DeserializedObject;

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/CollectionUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/CollectionUtil.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/CollectionUtil.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -0,0 +1,115 @@
+/*
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class CollectionUtil {
+
+  /** Indicates whether collection elements should be actually checked. */
+  private static final boolean DEBUG = false;
+
+  private CollectionUtil() {
+    // hide default constructor to prevent instantiation
+  }
+
+  /**
+   * Ensures that all elements of the given collection can be cast to a desired type.
+   * 
+   * @param collection the collection to check
+   * @param type the desired type
+   * @return a collection of the desired type
+   * @throws ClassCastException if an element cannot be cast to the desired type
+   */
+  @SuppressWarnings("unchecked")
+  public static <E> Collection<E> checkCollection(Collection<?> collection, Class<E> type) {
+    if (DEBUG) {
+      Collection<E> copy = new ArrayList<E>(collection.size());
+      for (Object element : collection) {
+        copy.add(type.cast(element));
+      }
+      return copy;
+    }
+    return (Collection<E>) collection;
+  }
+
+  /**
+   * Ensures that all elements of the given list can be cast to a desired type.
+   * 
+   * @param list the list to check
+   * @param type the desired type
+   * @return a list of the desired type
+   * @throws ClassCastException if an element cannot be cast to the desired type
+   */
+  @SuppressWarnings("unchecked")
+  public static <E> List<E> checkList(List<?> list, Class<E> type) {
+    if (DEBUG) {
+      List<E> copy = new ArrayList<E>(list.size());
+      for (Object element : list) {
+        copy.add(type.cast(element));
+      }
+      return copy;
+    }
+    return (List<E>) list;
+  }
+
+  /**
+   * Ensures that all elements of the given set can be cast to a desired type.
+   * 
+   * @param list the set to check
+   * @param type the desired type
+   * @return a set of the desired type
+   * @throws ClassCastException if an element cannot be cast to the desired type
+   */
+  @SuppressWarnings("unchecked")
+  public static <E> Set<E> checkSet(Set<?> set, Class<E> type) {
+    if (DEBUG) {
+      Set<E> copy = new HashSet<E>();
+      for (Object element : set) {
+        copy.add(type.cast(element));
+      }
+      return copy;
+    }
+    return (Set<E>) set;
+  }
+
+  @SuppressWarnings("unchecked")
+  public static <K, V> Map<K, V> checkMap(Map<?, ?> map, Class<K> keyType, Class<V> valueType) {
+    if (DEBUG) {
+      Map<K, V> copy = new HashMap<K, V>();
+      for (Map.Entry<?, ?> entry : map.entrySet()) {
+        copy.put(keyType.cast(entry.getKey()), valueType.cast(entry.getValue()));
+      }
+      return copy;
+    }
+    return (Map<K, V>) map;
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/CollectionUtil.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,39 +21,55 @@
  */
 package org.jbpm.pvm.internal.util;
 
-public abstract class EqualsUtil {
+public class EqualsUtil {
 
+  private EqualsUtil() {
+    // hide default constructor to prevent instantiation
+  }
+
+  /**
+   * hack to support comparing hibernate proxies against the real objects. since it falls back
+   * to ==, clients do not need to override {@link Object#hashCode()}.
+   * 
+   * @deprecated hack does not work
+   * @see <a href="https://jira.jboss.org/jira/browse/JBPM-2489">JBPM-2489</a>   
+   */
+  @Deprecated
   public static boolean equals(Object thisObject, Object otherObject) {
-    if ( (thisObject==null) || (otherObject==null) ) return false;
-    
+    if ((thisObject == null) || (otherObject == null))
+      return false;
+
     if (isProxy(otherObject)) {
       return otherObject.equals(thisObject);
-    } else {
-      return otherObject==thisObject;
     }
+    else {
+      return otherObject == thisObject;
+    }
   }
 
-  static boolean isInitialized = false;
-  static boolean isHibernateInClasspth = true;
-  static Class<?> hibernateProxyClass = null;
-  
-  static boolean isProxy(Object otherObject) {
+  private static boolean isInitialized;
+  private static boolean isHibernateInClasspath = true;
+  private static Class<?> hibernateProxyClass;
+
+  private static boolean isProxy(Object otherObject) {
     boolean isProxy = false;
-    if (!isInitialized) initializeHibernateProxyClass();
+    if (!isInitialized)
+      initializeHibernateProxyClass();
 
-    if (isHibernateInClasspth) {
+    if (isHibernateInClasspath) {
       return hibernateProxyClass.isAssignableFrom(otherObject.getClass());
     }
     return isProxy;
   }
 
-  static synchronized void initializeHibernateProxyClass() {
+  private static synchronized void initializeHibernateProxyClass() {
     try {
       ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
       hibernateProxyClass = classLoader.loadClass("org.hibernate.proxy.HibernateProxy");
-    } catch (ClassNotFoundException e) {
-      isHibernateInClasspth = false;
     }
+    catch (ClassNotFoundException e) {
+      isHibernateInClasspath = false;
+    }
     isInitialized = true;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -31,14 +31,18 @@
 /**
  * @author Tom Baeyens
  */
-public abstract class StringUtil {
+public class StringUtil {
   
+  private StringUtil() {
+    // hide default constructor to prevent instantiation
+  }
+  
   public static List<String> tokenize(String text, String delimiter) {
     if (delimiter==null) {
       throw new JbpmException("delimiter is null");
     }
     if (text==null) {
-      return Collections.EMPTY_LIST;
+      return Collections.emptyList();
     }
     
     List<String> pieces = new ArrayList<String>();

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -640,9 +640,7 @@
       if (descriptors!=null) {
         Descriptor descriptor = descriptors.get(objectName);
         if (descriptor!=null) {
-          if (wireEvent==null) {
-            wireEvent = new WireObjectEventInfo(eventName, objectName, object);
-          }
+          wireEvent = new WireObjectEventInfo(eventName, objectName, object);
           descriptor.fire(eventName, wireEvent);
         }
       }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -23,11 +23,10 @@
 
 import java.util.List;
 
-import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
 import org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
 
-/** parses a descriptor for creating a {@link JobExecutor}.
+/** parses a descriptor for creating a {@link List}.
  * 
  * See schema docs for more details.
  * 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,6 +21,9 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.util.Listener;
 import org.jbpm.pvm.internal.wire.Descriptor;
@@ -28,18 +31,13 @@
 import org.jbpm.pvm.internal.wire.WireDefinition;
 import org.jbpm.pvm.internal.wire.WireException;
 
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-
-import java.net.URL;
-
 /**
  * @author Tom Baeyens
  */
 public class HibernateSessionFactoryDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
-  private static final Log log = Log.getLog(HibernateSessionFactoryDescriptor.class.getName());
+  static final Log log = Log.getLog(HibernateSessionFactoryDescriptor.class.getName());
   
   String configurationName;
   Descriptor configurationDescriptor;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -32,7 +32,7 @@
  *
  * @see Descriptor
  */
-public class ShortDescriptor extends AbstractDescriptor implements Descriptor {
+public class ShortDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -12,7 +12,7 @@
  *
  * @see Descriptor
  */
-public class StringDescriptor extends AbstractDescriptor implements Descriptor {
+public class StringDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2010-06-24 06:06:27 UTC (rev 6435)
@@ -207,7 +207,7 @@
     <discriminator column="CLASS_" />
     <version name="dbversion" column="DBVERSION_" />
 
-    <property name="duedate" column="DUEDATE_" type="timestamp" index="IDX_JOBDUEDATE"  />
+    <property name="dueDate" column="DUEDATE_" type="timestamp" index="IDX_JOBDUEDATE"  />
     <property name="state" column="STATE_" />
     <property name="isExclusive" column="ISEXCLUSIVE_" />
     <property name="lockOwner" column="LOCKOWNER_" />
@@ -260,7 +260,7 @@
     <![CDATA[
      select t
      from org.jbpm.pvm.internal.job.TimerImpl as t
-     order by duedate asc
+     order by dueDate asc
     ]]>
   </query>
 
@@ -276,7 +276,7 @@
      select job
      from org.jbpm.pvm.internal.job.JobImpl as job
      where job.retries = 0 
-     order by duedate asc
+     order by dueDate asc
     ]]>
   </query>
 
@@ -285,19 +285,11 @@
     <![CDATA[
      select job
      from org.jbpm.pvm.internal.job.JobImpl as job
-     where ( ( (job.lockExpirationTime is null)
-               or (job.lockExpirationTime <= :now) 
-             )
-             and 
-             ( (job.duedate is null)
-               or (job.duedate <= :now) 
-             ) 
-             and 
-             ( job.retries > 0 ) 
-             and 
-             ( job.state != 'suspended' ) 
-           )
-     order by job.duedate asc
+     where (job.lockExpirationTime is null or job.lockExpirationTime <= :now)
+       and (job.dueDate is null or job.dueDate <= :now) 
+       and job.retries > 0 
+       and job.state != 'suspended' 
+     order by job.dueDate asc
     ]]>
   </query>
 
@@ -310,10 +302,8 @@
        and job.isExclusive = true 
        and job.retries > 0 
        and job.state != 'suspended'
-       and ( (job.duedate is null)
-             or (job.duedate <= :now) 
-           )
-     order by job.duedate asc
+       and (job.dueDate is null or job.dueDate <= :now)
+     order by job.dueDate asc
     ]]>
   </query>
   
@@ -324,7 +314,7 @@
      where job.lockOwner is null
        and job.retries > 0 
        and job.state != 'suspended'
-     order by job.duedate asc
+     order by job.dueDate asc
     ]]>
   </query>
   
@@ -356,4 +346,12 @@
     ]]>
   </query>
 
+  <query name="findProcessInstanceIds">
+    <![CDATA[
+     select processInstance.id
+     from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
+     where processInstance.processDefinitionId = :processDefinitionId
+       and processInstance.parent is null
+    ]]>
+  </query>
 </hibernate-mapping>
\ No newline at end of file

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml	2010-06-24 06:06:27 UTC (rev 6435)
@@ -56,5 +56,25 @@
                  foreign-key="FK_GROUP_PARENT"
                  index="IDX_GROUP_PARENT"/>
   </class>
-  
+
+  <query name="findGroupsByUser">
+    <![CDATA[
+    select distinct g
+    from org.jbpm.pvm.internal.identity.impl.MembershipImpl m
+      join m.user u
+      join m.group g
+    where u.id = :userId
+    ]]>
+  </query>
+
+  <query name="findGroupsByUserAndGroupType">
+    <![CDATA[
+    select distinct g
+    from org.jbpm.pvm.internal.identity.impl.MembershipImpl m
+      join m.user u
+      join m.group g
+    where u.id = :userId
+      and g.type = :groupType
+    ]]>
+  </query>
 </hibernate-mapping>
\ No newline at end of file

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -160,7 +160,7 @@
     
     Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
     long expectedTimerDueDate = processStartTime + (5 * 60 * 60 * 1000); // expected = 5 hours in ms
-    assertEquals(expectedTimerDueDate, timerJob.getDuedate().getTime());
+    assertEquals(expectedTimerDueDate, timerJob.getDueDate().getTime());
     
     managementService.executeJob(timerJob.getId());
     assertProcessInstanceEnded(pi);
@@ -174,7 +174,7 @@
     
     Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
     Date expectedDueDate = DateUtils.getDateAtMidnight(10, Calendar.OCTOBER, 2099);
-    assertEquals(expectedDueDate.getTime(), timerJob.getDuedate().getTime());
+    assertEquals(expectedDueDate.getTime(), timerJob.getDueDate().getTime());
     
     managementService.executeJob(timerJob.getId());
     assertProcessInstanceEnded(pi);
@@ -188,7 +188,7 @@
     CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
     
     Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
-    assertEquals(DateUtils.getDate(20, Calendar.JANUARY, 2010, 0, 2, 0).getTime(), timerJob.getDuedate().getTime()); 
+    assertEquals(DateUtils.getDate(20, Calendar.JANUARY, 2010, 0, 2, 0).getTime(), timerJob.getDueDate().getTime()); 
     
     managementService.executeJob(timerJob.getId());
     assertProcessInstanceEnded(pi);
@@ -202,13 +202,10 @@
     CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
     
     Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
-    assertEquals(DateUtils.getDate(22, Calendar.JANUARY, 2010, 23, 0, 0).getTime(), timerJob.getDuedate().getTime());
+    assertEquals(DateUtils.getDate(22, Calendar.JANUARY, 2010, 23, 0, 0).getTime(), timerJob.getDueDate().getTime());
     
     managementService.executeJob(timerJob.getId());
     assertProcessInstanceEnded(pi);
   }
-  
- 
 
-
 }

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/startevent/TimerStartEventTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/startevent/TimerStartEventTest.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/startevent/TimerStartEventTest.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -164,7 +164,7 @@
     // After deployment, there should be one job in the database that starts a new process instance
     Job startProcessTimer = managementService.createJobQuery().uniqueResult();
     assertNotNull(startProcessTimer);
-    assertEquals(DateUtils.getDateAtMidnight(10, Calendar.OCTOBER, 2099).getTime(), startProcessTimer.getDuedate().getTime());
+    assertEquals(DateUtils.getDateAtMidnight(10, Calendar.OCTOBER, 2099).getTime(), startProcessTimer.getDueDate().getTime());
     
     ProcessInstanceQuery procInstQuery = executionService.createProcessInstanceQuery()
                             .processDefinitionId(findProcessDefinitionId("timerStartFixedDueDate"));
@@ -186,7 +186,7 @@
     // After deployment, there should be one job in the database that starts a new process instance
     Job startProcessTimer = managementService.createJobQuery().uniqueResult();
     assertNotNull(startProcessTimer);
-    assertEquals(DateUtils.getDate(10, Calendar.OCTOBER, 2099, 10, 0, 0).getTime(), startProcessTimer.getDuedate().getTime());
+    assertEquals(DateUtils.getDate(10, Calendar.OCTOBER, 2099, 10, 0, 0).getTime(), startProcessTimer.getDueDate().getTime());
     
     // Triggering the job should start a new process instance of the deployed process definition
     ProcessInstanceQuery procInstQuery = executionService.createProcessInstanceQuery()
@@ -200,7 +200,7 @@
     
     // Since a timeCycle was used, the job should have been recreated with a new duedate
     startProcessTimer = managementService.createJobQuery().uniqueResult();
-    assertEquals(DateUtils.getDate(10, Calendar.OCTOBER, 2099, 20, 0, 0).getTime(), startProcessTimer.getDuedate().getTime());
+    assertEquals(DateUtils.getDate(10, Calendar.OCTOBER, 2099, 20, 0, 0).getTime(), startProcessTimer.getDueDate().getTime());
     
     
     // So we need to manually delete it
@@ -214,7 +214,7 @@
     // After deployment, there should be one job in the database that starts a new process instance
     Job startProcessTimer = managementService.createJobQuery().uniqueResult();
     assertNotNull(startProcessTimer);
-    assertEquals(DateUtils.getDate(10, Calendar.OCTOBER, 2099, 22, 0, 0).getTime(), startProcessTimer.getDuedate().getTime());
+    assertEquals(DateUtils.getDate(10, Calendar.OCTOBER, 2099, 22, 0, 0).getTime(), startProcessTimer.getDueDate().getTime());
     
     // Triggering the job should start a new process instance of the deployed process definition
     ProcessInstanceQuery procInstQuery = executionService.createProcessInstanceQuery()
@@ -228,7 +228,7 @@
     
     // Since a timeCycle was used, the job should have been recreated with a new duedate
     startProcessTimer = managementService.createJobQuery().uniqueResult();
-    assertEquals(DateUtils.getDate(11, Calendar.OCTOBER, 2099, 22, 0, 0).getTime(), startProcessTimer.getDuedate().getTime());
+    assertEquals(DateUtils.getDate(11, Calendar.OCTOBER, 2099, 22, 0, 0).getTime(), startProcessTimer.getDueDate().getTime());
     
     // So we need to manually delete it
     managementService.deleteJob(Long.valueOf(startProcessTimer.getId()));

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.test.identity;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -63,17 +64,12 @@
     identityService.createMembership("jeffyu", redhatGroupId);
 
     List<Group> groups = identityService.findGroupsByUser("jeffyu");
-    assertTrue(groups.size() > 0);
-
     Set<String> groupNames = new HashSet<String>(); 
     for (Group group : groups) {
       groupNames.add(group.getName());
     }
     
-    Set<String> expectedGroupNames = new HashSet<String>();
-    expectedGroupNames.add("redhat");
-    
-    assertEquals(expectedGroupNames, groupNames);
+    assertEquals(Collections.singleton("redhat"), groupNames);
 
     identityService.deleteUser("jeffyu");
     identityService.deleteGroup(redhatGroupId);
@@ -86,17 +82,12 @@
     identityService.createMembership("johndoe", redhatGroupId, "developer");
 
     List<Group> groups = identityService.findGroupsByUserAndGroupType("johndoe", "unit");
-    assertTrue(groups.size() > 0);
-
     Set<String> groupNames = new HashSet<String>(); 
     for (Group group : groups) {
       groupNames.add(group.getName());
     }
     
-    Set<String> expectedGroupNames = new HashSet<String>();
-    expectedGroupNames.add("redhat");
-    
-    assertEquals(expectedGroupNames, groupNames);
+    assertEquals(Collections.singleton("redhat"), groupNames);
 
     identityService.deleteUser("johndoe");
     identityService.deleteGroup(redhatGroupId);

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -3,11 +3,13 @@
 import java.util.List;
 
 import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.TaskService;
 import org.jbpm.api.model.OpenExecution;
 import org.jbpm.api.task.Assignable;
 import org.jbpm.api.task.AssignmentHandler;
 import org.jbpm.api.task.Participation;
 import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.test.JbpmTestCase;
 
 public class AssignmentHandlerTest extends JbpmTestCase {
@@ -99,7 +101,8 @@
     public void assign(Assignable assignable, OpenExecution execution) throws Exception {
       // retrieve the participations
       Task task = (Task) assignable;
-      List<Participation> participations = taskService.getTaskParticipations(task.getId());
+      List<Participation> participations = EnvironmentImpl.getFromCurrent(TaskService.class)
+        .getTaskParticipations(task.getId());
 
       // If the participations list is not empty, assign task to default user
       if (!participations.isEmpty()) {

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java	2010-06-24 03:39:54 UTC (rev 6434)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java	2010-06-24 06:06:27 UTC (rev 6435)
@@ -50,7 +50,7 @@
 
     taskService.addTaskComment(taskId, "i'll clean up the mess");
     
-    List<HistoryComment> taskComments = taskService.getTaskComments(taskId);
+    List<? extends HistoryComment> taskComments = taskService.getTaskComments(taskId);
     assertEquals("what a party yesterday", taskComments.get(0).getMessage());
     assertEquals("i'll clean up the mess", taskComments.get(1).getMessage());
     



More information about the jbpm-commits mailing list