[jbpm-commits] JBoss JBPM SVN: r6751 - in jbpm4/trunk/modules/pvm/src: main/java/org/jbpm/pvm/internal/hibernate and 23 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Oct 9 06:16:54 EDT 2010


Author: alex.guizar at jboss.com
Date: 2010-10-09 06:16:53 -0400 (Sat, 09 Oct 2010)
New Revision: 6751

Modified:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.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/GetHistoryVariableNamesCmd.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/GetSubTasksCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.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/hibernate/QuerySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.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/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/query/AbstractQuery.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/RepositorySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
Log:
address unused imports, unneeded casts and raw type references

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -51,7 +51,7 @@
     DbSession dbSession = environment.get(DbSession.class);
 
     if (taskId != null) {
-      TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, Long.parseLong(taskId));
+      TaskImpl task = dbSession.get(TaskImpl.class, Long.parseLong(taskId));
       if (task == null) {
         throw new JbpmException("task " + taskId + " was not found");
       }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,7 +27,6 @@
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.id.PropertyImpl;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -85,7 +85,7 @@
       }
     }
 
-    DeploymentImpl deployment = (DeploymentImpl) dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
+    DeploymentImpl deployment = dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
     if (log.isDebugEnabled()) {
       log.debug("deleting deployment " + deploymentId);
     }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,26 +21,20 @@
  */
 package org.jbpm.pvm.internal.cmd;
 
-import java.util.HashSet;
 import java.util.Set;
 
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
 /**
- * Command responsible for retrieving variable names stored as history records for given process instance id
- *
- *
+ * Command responsible for retrieving variable names stored as history records for given process
+ * instance id.
+ * 
  * @author Maciej Swiderski
- *
  */
 public class GetHistoryVariableNamesCmd implements Command<Set<String>> {
 
-  /**
-   *
-   */
   private static final long serialVersionUID = 1L;
 
   private String processInstanceId;
@@ -49,7 +43,6 @@
     this.processInstanceId = processInstanceId;
   }
 
-  @SuppressWarnings("unchecked")
   public Set<String> execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
 
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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,8 +27,6 @@
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.api.task.Participation;
 import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.ParticipationImpl;
-import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -26,8 +26,6 @@
 import org.jbpm.api.cmd.Environment;
 import org.jbpm.api.task.Task;
 import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * @author Tom Baeyens
@@ -36,7 +34,7 @@
 
   private static final long serialVersionUID = 1L;
 
-  String parentTaskId;
+  private String parentTaskId;
 
   public GetSubTasksCmd(String parentTaskId) {
     this.parentTaskId = parentTaskId;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -56,7 +56,7 @@
     DbSession dbSession = environment.get(DbSession.class);
 
     if (taskDbid != null) {
-      TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, taskDbid);
+      TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
       if (task == null) {
         throw new JbpmException("task " + taskDbid + " was not found");
       }

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -32,24 +32,24 @@
 
 import org.hibernate.Criteria;
 import org.hibernate.LockMode;
-import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
 import org.hibernate.metadata.ClassMetadata;
 
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
-import org.jbpm.api.job.Timer;
 import org.jbpm.api.history.HistoryComment;
+import org.jbpm.api.job.Timer;
 import org.jbpm.api.task.Participation;
 import org.jbpm.api.task.Task;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
-import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
 import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
 import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
@@ -59,9 +59,9 @@
 import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
 import org.jbpm.pvm.internal.identity.impl.UserImpl;
 import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.lob.Lob;
 import org.jbpm.pvm.internal.job.StartProcessTimer;
 import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.lob.Lob;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
 import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
@@ -513,23 +513,21 @@
 
 
   public void initializeSchemaVersion() {
-    PropertyImpl property = (PropertyImpl) session.createQuery(
-        "select property " +
-        "from " + PropertyImpl.class.getName() + " as property " +
-        "where property.key = '" + PropertyImpl.DB_VERSION_KEY + "'"
-    ).uniqueResult();
+    PropertyImpl property = (PropertyImpl) session.createCriteria(PropertyImpl.class)
+      .add(Restrictions.eq("key", PropertyImpl.DB_VERSION_KEY))
+      .uniqueResult();
 
     if (log.isDebugEnabled()) {
-      log.debug("version of jbpm library: " + ProcessEngineImpl.JBPM_LIBRARY_VERSION);
+      log.debug("jbpm library version: " + ProcessEngineImpl.JBPM_LIBRARY_VERSION);
     }
 
     if (property == null) {
-      log.info("version of jbpm db schema: none");
-
-    } else {
+      log.info("jbpm db schema version: none");
+    }
+    else {
       String dbSchemaVersion = property.getValue();
       if (log.isDebugEnabled()) {
-        log.debug("version of jbpm db schema: " + dbSchemaVersion);
+        log.debug("jbpm db schema version: " + dbSchemaVersion);
       }
       if (!ProcessEngineImpl.JBPM_LIBRARY_VERSION.equals(dbSchemaVersion)) {
         throw new JbpmException("jBPM runtime version " + ProcessEngineImpl.JBPM_LIBRARY_VERSION
@@ -540,12 +538,11 @@
 
   /** query. */
   public Set<String> findHistoryVariableNames(String processInstanceId) {
-    String hql = "select hv.variableName from " + HistoryVariableImpl.class.getName() + " hv where hv.processInstanceId = '" + processInstanceId + "'";
-
-    Query query = session.createQuery(hql);
-    Set<String> historyVariables = new HashSet<String>(query.list());
-
-    return historyVariables;
+    List<?> variableNames = session.createCriteria(HistoryVariableImpl.class)
+      .add(Restrictions.eq("processInstanceId", processInstanceId))
+      .setProjection(Projections.property("variableName"))
+      .list();
+    return new HashSet<String>(CollectionUtil.checkList(variableNames, String.class));
   }
 
   public List<Participation> findParticipants(String taskId, String swimlaneId) {
@@ -556,7 +553,7 @@
     } else if (swimlaneId != null) {
       criteria.add(Restrictions.eq("swimlane.dbid", Long.parseLong(swimlaneId)));
     } else {
-      throw new JbpmException("no task nor swimlane specified");
+      throw new JbpmException("neither task nor swimlane specified");
     }
 
     List<?> participations = criteria.list();
@@ -573,42 +570,35 @@
 
   // repository
   public List<ExecutionImpl> findExecutionsForSupend(Set<String> processDefinitionIds) {
-    Query query = session.createQuery(
-      "select execution " +
-      "from " + ExecutionImpl.class.getName() + " as execution " +
-      "where execution.processDefinitionId in (:processDefinitionIds) " +
-      "  and execution.state != '" + ExecutionImpl.STATE_SUSPENDED + "'"
-    );
-    query.setParameterList("processDefinitionIds", processDefinitionIds);
-    return query.list();
+    List<?> executions = session.createCriteria(ExecutionImpl.class)
+      .add(Restrictions.in("processDefinitionId", processDefinitionIds))
+      .add(Restrictions.ne("state", ExecutionImpl.STATE_SUSPENDED))
+      .list();
+    return CollectionUtil.checkList(executions, ExecutionImpl.class);
   }
 
   public List<ExecutionImpl> findExecutionsForResume(Set<String> processDefinitionIds) {
-    Query query = session.createQuery(
-      "select execution " +
-      "from " + ExecutionImpl.class.getName() + " as execution " +
-      "where execution.processDefinitionId in (:processDefinitionIds) " +
-      "  and execution.state = '" + ExecutionImpl.STATE_SUSPENDED + "'"
-    );
-    query.setParameterList("processDefinitionIds", processDefinitionIds);
-    return query.list();
+    List<?> executions = session.createCriteria(ExecutionImpl.class)
+      .add(Restrictions.in("processDefinitionId", processDefinitionIds))
+      .add(Restrictions.eq("state", ExecutionImpl.STATE_SUSPENDED))
+      .list();
+    return CollectionUtil.checkList(executions, ExecutionImpl.class);
   }
 
-  public DeploymentProperty findDeploymentPropertyByProcessDefinitionId(String processDefinitionId) {
-    DeploymentProperty deploymentProperty = (DeploymentProperty) session.createQuery(
-      "select deploymentProperty " +
-      "from " + DeploymentProperty.class.getName() + " as deploymentProperty " +
-      "where deploymentProperty.key = '" + DeploymentImpl.KEY_PROCESS_DEFINITION_ID + "' " +
-      "  and deploymentProperty.stringValue = '" + processDefinitionId + "' "
-    ).setMaxResults(1).uniqueResult();
-    return deploymentProperty;
+  public DeploymentProperty findDeploymentPropertyByProcessDefinitionId(
+    String processDefinitionId) {
+    return (DeploymentProperty) session.createCriteria(DeploymentProperty.class)
+      .add(Restrictions.eq("key", DeploymentImpl.KEY_PROCESS_DEFINITION_ID))
+      .add(Restrictions.eq("stringValue", processDefinitionId))
+      .setMaxResults(1)
+      .uniqueResult();
   }
 
   public List<Long> findDeploymentDbids() {
-    return session.createQuery("select dbid from " +
-        DeploymentImpl.class.getName() + " as deployment ")
-        .setReadOnly(true)
-        .list();
+    List<?> deploymentIds = session.createCriteria(DeploymentImpl.class)
+      .setProjection(Projections.property("dbid"))
+      .list();
+    return CollectionUtil.checkList(deploymentIds, Long.class);
   }
 
   // query

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -28,7 +28,9 @@
 import java.util.List;
 import java.util.Map;
 
-import org.jbpm.api.Deployment;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
 import org.jbpm.api.ProcessDefinition;
 import org.jbpm.api.QueryOperator;
 import org.jbpm.api.identity.Group;
@@ -48,16 +50,14 @@
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.internal.query.QueryCondition;
 import org.jbpm.pvm.internal.query.QueryProperty;
-import org.jbpm.pvm.internal.session.QuerySession;
-import org.jbpm.pvm.internal.session.RepositorySession;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
 import org.jbpm.pvm.internal.repository.DeploymentProperty;
-import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.session.QuerySession;
+import org.jbpm.pvm.internal.session.RepositorySession;
 import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 
-import org.hibernate.Session;
-import org.hibernate.Query;
-
 /**
  * query session implementation for hibernate.
  *
@@ -108,13 +108,13 @@
         }
 
         // where
-        Map params = new HashMap();
-        this.appendWhereClause(buff, queryProperty, params, false);
+        Map<String, Object> params = new HashMap<String, Object>();
+        appendWhereClause(buff, queryProperty, params, false);
 
         // order by
-        this.appendOrderClause(buff, queryProperty);
+        appendOrderClause(buff, queryProperty);
 
-        return this.executeQuery(buff.toString(), params, queryProperty);
+        return executeQuery(buff.toString(), params, queryProperty);
     }
 
     protected Object queryTask(QueryProperty queryProperty) {
@@ -149,7 +149,7 @@
             log.debug("setting parameter candidateUserId: " + candidate);
         }
 
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
 
         if (groups.isEmpty()) {
             buff.append(" and participant.userId = :candidateUserId ");
@@ -187,7 +187,7 @@
             return result;
         }
 
-        List<Long> taskIds = (List<Long>) result;
+        List<Long> taskIds = CollectionUtil.checkList((List<?>) result, Long.class);
         if (taskIds.isEmpty()) {
             return Collections.EMPTY_LIST;
         }
@@ -219,7 +219,7 @@
                 .append(" as task ");
         }
 
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         this.appendWhereClause(buff, queryProperty, params, false);
 
         // order by
@@ -254,7 +254,7 @@
             .append("and versionProperty.objectName = idProperty.objectName ")
             .append("and versionProperty.deployment = deployment ");
 
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         this.appendWhereClause(buff, queryProperty, params, true);
 
         // order by
@@ -263,33 +263,27 @@
         String hql = buff.toString();
         log.debug(hql);
 
-        RepositorySession repositorySession = EnvironmentImpl.getFromCurrent(RepositorySession.class);
-
         Query query = session.createQuery(hql).setProperties(params);
-
         if (queryProperty.getResultType() == QueryProperty.RESULT_TYPE_PAGE_UNIQUE
                 || queryProperty.getResultType() == QueryProperty.RESULT_TYPE_PAGE_COUNT) {
              query.setFirstResult(queryProperty.getFirstResult())
                   .setMaxResults(queryProperty.getMaxResults());
         }
 
+        RepositorySession repositorySession = EnvironmentImpl.getFromCurrent(RepositorySession.class);
         if (queryProperty.getResultType() == QueryProperty.RESULT_TYPE_UNIQUE
                 || queryProperty.getResultType() == QueryProperty.RESULT_TYPE_PAGE_UNIQUE) {
             Object result = query.uniqueResult();
-            if (result == null) {
-                return null;
-            }
-            return getProcessDefinition(repositorySession, result);
+            if (result == null) return null;
+            return getProcessDefinition(repositorySession, (Map<?, ?>) result);
         } else {
-            Object result = query.list();
-            List<?> propertyMaps = (List<?>) result;
-            if (propertyMaps.isEmpty()) {
-                return Collections.EMPTY_LIST;
-            }
+            List<?> result = query.list();;
+            if (result.isEmpty()) return Collections.EMPTY_LIST;
 
             List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();
-            for (Object propertyObject : propertyMaps) {
-                ProcessDefinitionImpl processDefinition = getProcessDefinition(repositorySession, propertyObject);
+            for (Map<?, ?> propertyMap : CollectionUtil.checkList(result, Map.class)) {
+                ProcessDefinitionImpl processDefinition =
+                  getProcessDefinition(repositorySession, propertyMap);
                 processDefinitions.add(processDefinition);
             }
             return processDefinitions;
@@ -310,7 +304,7 @@
         }
 
         // where
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         boolean alreadyAddWhere = false;
 
         if (queryProperty.hasCondition("tookLessThen")) {
@@ -383,7 +377,7 @@
         }
 
         // where
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         boolean alreadyAddWhere = false;
 
         if (queryProperty.hasCondition("timeBefore")) {
@@ -432,7 +426,7 @@
         }
 
         // where
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         boolean alreadyAddWhere = false;
 
         if (queryProperty.hasCondition("endedBefore")) {
@@ -483,7 +477,7 @@
         }
 
         // where
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         boolean alreadyAddWhere = false;
 
         if (queryProperty.hasCondition("processInstanceId")) {
@@ -555,7 +549,8 @@
 
     // ~ ======================================================================
 
-    protected void appendWhereClause(StringBuilder buff, QueryProperty queryProperty, Map params, boolean originalAlreadyAddWhere) {
+    protected void appendWhereClause(StringBuilder buff, QueryProperty queryProperty,
+      Map<String, Object> params, boolean originalAlreadyAddWhere) {
         // where
         boolean alreadyAddWhere = originalAlreadyAddWhere;
         for (Map.Entry<String, QueryCondition> entry : queryProperty.getConditions().entrySet()) {
@@ -629,8 +624,8 @@
         }
     }
 
-    private static ProcessDefinitionImpl getProcessDefinition(RepositorySession repositorySession, Object propertyObject) {
-        Map<?, ?> propertyMap = (Map<?, ?>) propertyObject;
+    private static ProcessDefinitionImpl getProcessDefinition(RepositorySession repositorySession,
+      Map<?, ?> propertyMap) {
         String deploymentId = propertyMap.get("deploymentDbid").toString();
         String objectName = (String)propertyMap.get("objectName");
         return (ProcessDefinitionImpl) repositorySession.getObject(deploymentId, objectName);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -46,9 +46,8 @@
 
   public void process() {
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-    Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
-    HistoryActivityInstanceImpl historyActivityInstance = (HistoryActivityInstanceImpl)
-        dbSession.get(getHistoryActivityInstanceClass(), historyActivityInstanceDbId);
+    HistoryActivityInstanceImpl historyActivityInstance = dbSession.get(getHistoryActivityInstanceClass(),
+      execution.getHistoryActivityInstanceDbid());
     updateHistoryActivityInstance(historyActivityInstance);
     dbSession.update(historyActivityInstance);
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -36,11 +36,11 @@
 
   public void process() {
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-    HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
-        dbSession.get(HistoryProcessInstanceImpl.class, execution.getDbid());
-    historyProcessInstanceImpl.setEndTime(Clock.getTime());
-    historyProcessInstanceImpl.setState(execution.getState());
-    historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());
-    dbSession.update(historyProcessInstanceImpl);
+    HistoryProcessInstanceImpl historyProcessInstance =
+      dbSession.get(HistoryProcessInstanceImpl.class, execution.getDbid());
+    historyProcessInstance.setEndTime(Clock.getTime());
+    historyProcessInstance.setState(execution.getState());
+    historyProcessInstance.setEndActivityName(execution.getActivityName());
+    dbSession.update(historyProcessInstance);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -46,9 +46,8 @@
 
   public void process() {
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-    Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
-    HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
-      dbSession.get(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
+    HistoryTaskInstanceImpl historyTaskInstance = dbSession.get(HistoryTaskInstanceImpl.class,
+      execution.getHistoryActivityInstanceDbid());
     historyTaskInstance.setEndTime(Clock.getTime());
     historyTaskInstance.setTransitionName(outcome);
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -53,9 +53,8 @@
     super.updateHistoryActivityInstance(historyActivityInstance);
 
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-    Long historyTaskInstanceId = execution.getHistoryActivityInstanceDbid();
-    HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) dbSession
-      .get(HistoryTaskInstanceImpl.class, historyTaskInstanceId);
+    HistoryTaskInstanceImpl historyTaskInstance = dbSession.get(HistoryTaskInstanceImpl.class,
+      execution.getHistoryActivityInstanceDbid());
     historyTaskInstance.setEndTime(Clock.getTime());
     historyTaskInstance.setTransitionName(outcome);
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -39,15 +39,14 @@
 
   private static final long serialVersionUID = 1L;
 
-  Variable variable;
+  private Variable<?> variable;
   
-  public VariableCreate(Variable variable) {
+  public VariableCreate(Variable<?> variable) {
     this.variable = variable;
   }
 
   public void process() {
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-    
     dbSession.save(variable);
 
     HistoryProcessInstanceImpl historyProcessInstance = null;
@@ -68,7 +67,7 @@
     dbSession.save(historyVariable);
   }
 
-  public Variable getVariable() {
+  public Variable<?> getVariable() {
     return variable;
   }
   

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -35,9 +35,9 @@
 
   private static final long serialVersionUID = 1L;
 
-  Variable variable;
+  private Variable<?> variable;
   
-  public VariableUpdate(Variable variable) {
+  public VariableUpdate(Variable<?> variable) {
     this.variable = variable;
   }
 
@@ -48,7 +48,7 @@
     historyVariable.updated(variable);
   }
 
-  public Variable getVariable() {
+  public Variable<?> getVariable() {
     return variable;
   }
   

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -54,7 +54,8 @@
   protected HistoryVariableImpl() {
   }
   
-  public HistoryVariableImpl(HistoryProcessInstanceImpl historyProcessInstance, HistoryTaskImpl historyTask, Variable variable) {
+  public HistoryVariableImpl(HistoryProcessInstanceImpl historyProcessInstance,
+    HistoryTaskImpl historyTask, Variable<?> variable) {
     this.dbid = variable.getDbid();
 
     this.historyProcessInstance = historyProcessInstance;
@@ -70,7 +71,7 @@
     this.value = variable.getTextValue();
   }
   
-  public void updated(Variable variable) {
+  public void updated(Variable<?> variable) {
     String newValue = variable.getTextValue();
     if ( (value==null && newValue!=null)
          || (value!=null && (!value.equals(newValue)))

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,33 +21,10 @@
  */
 package org.jbpm.pvm.internal.id;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
-import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
-import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
-import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
-import org.jbpm.pvm.internal.identity.impl.GroupImpl;
-import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
-import org.jbpm.pvm.internal.identity.impl.UserImpl;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.lob.Lob;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
-import org.jbpm.pvm.internal.repository.DeploymentImpl;
-import org.jbpm.pvm.internal.repository.DeploymentProperty;
 import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.ParticipationImpl;
-import org.jbpm.pvm.internal.task.SwimlaneImpl;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.type.Variable;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -55,8 +32,6 @@
 
   private static final long serialVersionUID = 1L;
 
-  private static Log log = Log.getLog(InitializePropertiesCmd.class.getName());
-
   long blocksize;
 
   public InitializePropertiesCmd(long blocksize) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -22,7 +22,6 @@
 package org.jbpm.pvm.internal.id;
 
 import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
@@ -109,7 +108,7 @@
   }
 
   protected static PropertyImpl getProperty(DbSession dbSession, String key) {
-    return (PropertyImpl) dbSession.get(PropertyImpl.class, key);
+    return dbSession.get(PropertyImpl.class, key);
   }
 
   public static void setDbVersionTo41(DbSession dbSession) {

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -22,7 +22,6 @@
 import org.jbpm.pvm.internal.job.TimerImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.session.TimerSession;
-import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
  * Timers created with this service are committed at the end of the transaction,

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -101,7 +101,7 @@
   protected <S> Variable<S> createVariableObject(String key, Object value, String typeName,
     boolean isHistoryEnabled) {
     // if type does not actually match S, there is a configuration error
-    // and Variable.isStorable will eventually throw an exception
+    // and Variable.supports() will eventually throw an exception
     @SuppressWarnings("unchecked")
     Type<S> type = (Type<S>) findType(key, value, typeName);
     Variable<S> variable;
@@ -112,10 +112,12 @@
         log.trace("creating " + type + " variable '" + key + "'");
         variable = variableClass.newInstance();
       }
-      catch (Exception e) {
-        throw new JbpmException("couldn't instantiate variable instance class '"
-          + variableClass.getName() + "'");
+      catch (InstantiationException e) {
+        throw new JbpmException("failed to instantiate " + variableClass, e);
       }
+      catch (IllegalAccessException e) {
+        throw new JbpmException(getClass() + " has no access to " + variableClass, e);
+      }
       Converter<?, S> converter = type.getConverter();
       if (converter != null) variable.setConverter(converter);
     }
@@ -169,8 +171,8 @@
   }
 
   private <S> void setVariableNoCheck(String key, Object value) {
-    // if type does not actually match S, there is a configuration error
-    // and Variable.isStorable will eventually throw an exception
+    // if variable does not actually store S, there is a configuration error
+    // and Variable.supports() will eventually throw an exception
     @SuppressWarnings("unchecked")
     Variable<S> variable = (Variable<S>) getVariableObject(key);
 

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,7 +27,6 @@
 import java.util.List;
 
 import org.jbpm.pvm.internal.el.Expression;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
 
 /**
  * @author Tom Baeyens

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,9 +21,6 @@
  */
 package org.jbpm.pvm.internal.query;
 
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -157,44 +154,6 @@
     return QueryOperator.EQUALS;
   }
 
-  /**
-   * Transforms given string (<code>parameter</code>) to an array of given type (<code>clazz</code>).
-   * <code>parameter</code> will be split using separator ',' (comma).
-   * Array will be populated based on split string by creating new instance of class <code>clazz</code>
-   * using its constructor that accepts String argument.
-   * All exceptions will be silently skipped.
-   */
-  @SuppressWarnings("unchecked")
-  protected <T> T[] transformToArray(String paramStr, Class<T> clazz) {
-    String[] parameters = paramStr.split(",");
-    if (clazz == String.class) {
-      return (T[]) parameters;
-    }
-
-    T[] ids = (T[]) Array.newInstance(clazz, parameters.length);
-    try {
-      Constructor<T> constructor = clazz.getConstructor(String.class);
-      for (int i = 0; i < parameters.length; i++) {
-        try {
-          ids[i] = (T) constructor.newInstance(parameters[i]);
-        }
-        catch (InstantiationException e) {
-          throw new JbpmException("failed to instantiate " + clazz, e);
-        }
-        catch (IllegalAccessException e) {
-          throw new JbpmException(getClass() + " has no access to " + constructor);
-        }
-        catch (InvocationTargetException e) {
-          throw new JbpmException(constructor + " threw exception", e.getCause());
-        }
-      }
-      return ids;
-    }
-    catch (NoSuchMethodException e) {
-      throw new JbpmException("string constructor not found in " + clazz, e);
-    }
-  }
-
   protected void appendWhereClauseWithOperator(String where, String namedParam, StringBuilder hql) {
     QueryOperator operator = getOperator(namedParam);
     switch (operator) {

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -29,7 +29,6 @@
 import org.jbpm.api.QueryOperator;
 import org.jbpm.api.TaskQuery;
 import org.jbpm.api.task.Task;
-import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.session.QuerySession;
 import org.jbpm.pvm.internal.task.TaskImpl;
@@ -59,7 +58,6 @@
 public class TaskQueryImpl extends AbstractQuery implements TaskQuery {
 
   private static final long serialVersionUID = 1L;
-  private static final Log log = Log.getLog(TaskQueryImpl.class.getName());
 
   protected boolean unassigned;
   protected String[] assignee;

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-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -29,7 +29,6 @@
 import org.jbpm.api.NewDeployment;
 import org.jbpm.api.ProcessDefinition;
 import org.jbpm.api.ProcessDefinitionQuery;
-import org.jbpm.api.RepositoryService;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
@@ -37,8 +36,8 @@
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 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.session.DbSession;
+import org.jbpm.pvm.internal.session.RepositorySession;
 import org.jbpm.pvm.internal.util.CollectionUtil;
 
 /**
@@ -101,7 +100,7 @@
   }
 
   public DeploymentImpl getDeployment(String deploymentId) {
-    return (DeploymentImpl) dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
+    return dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
   }
 
   public Object getObject(String deploymentId, String objectName) {
@@ -116,7 +115,7 @@
       if (log.isTraceEnabled()) {
         log.trace("loading deployment " + deploymentId + " from db");
       }
-      DeploymentImpl deployment = (DeploymentImpl) dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
+      DeploymentImpl deployment = dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
       deployerManager.deploy(deployment);
       object = repositoryCache.get(deploymentId, objectName);
       if (object == null) {
@@ -199,7 +198,6 @@
    * Checks if every entry in the repositoryCache is still valid.
    * If the entry is not found in the database, it is deleted from the cache.
    */
-  @SuppressWarnings("unchecked")
   private void validateRepositoryCache() {
     log.trace("Validating repository cache ... ");
     Set<Long> dbIds = new HashSet<Long>(dbSession.findDeploymentDbids());

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -79,7 +79,7 @@
   }
 
   public Set<Entry<String, Object>> entrySet() {
-    return Collections.EMPTY_SET;
+    return Collections.emptySet();
   }
 
   public boolean isEmpty() {
@@ -87,7 +87,7 @@
   }
 
   public Set<String> keySet() {
-    return Collections.EMPTY_SET;
+    return Collections.emptySet();
   }
 
   public int size() {
@@ -95,6 +95,6 @@
   }
 
   public Collection<Object> values() {
-    return Collections.EMPTY_SET;
+    return Collections.emptySet();
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.pvm.internal.session;
 
-import org.jbpm.api.Deployment;
 import org.jbpm.pvm.internal.query.QueryProperty;
 
 /**

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -28,7 +28,6 @@
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
-import java.util.StringTokenizer;
 import java.util.TimeZone;
 
 import org.jbpm.pvm.internal.cal.BusinessCalendarImpl;
@@ -42,7 +41,6 @@
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,16 +21,15 @@
  */
 package org.jbpm.pvm.internal.wire.binding;
 
+import org.w3c.dom.Element;
+
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.svc.ManagementServiceImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -22,9 +22,11 @@
 package org.jbpm.pvm.internal.wire.binding;
 
 import java.io.File;
+import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.List;
 
+import org.w3c.dom.Element;
+
 import org.jbpm.pvm.internal.stream.FileStreamInput;
 import org.jbpm.pvm.internal.stream.ResourceStreamInput;
 import org.jbpm.pvm.internal.stream.StreamInput;
@@ -33,6 +35,7 @@
 import org.jbpm.pvm.internal.type.Matcher;
 import org.jbpm.pvm.internal.type.Type;
 import org.jbpm.pvm.internal.type.TypeMapping;
+import org.jbpm.pvm.internal.type.Variable;
 import org.jbpm.pvm.internal.type.matcher.ClassNameMatcher;
 import org.jbpm.pvm.internal.type.matcher.HibernateLongIdMatcher;
 import org.jbpm.pvm.internal.type.matcher.HibernateStringIdMatcher;
@@ -44,12 +47,12 @@
 import org.jbpm.pvm.internal.wire.descriptor.TypesDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
 
-/** parses a descriptor for Boolean.TRUE.
- *
+/**
+ * parses a types descriptor.
+ * 
  * See schema docs for more details.
- *
+ * 
  * @author Tom Baeyens
  */
 public class TypesBinding extends WireDescriptorBinding {
@@ -63,12 +66,13 @@
     if (element.hasAttribute("file")) {
       String fileName = element.getAttribute("file");
       File file = new File(fileName);
-      if (file.exists() && file.isFile()) {
+      if (file.isFile()) {
         streamSource = new FileStreamInput(file);
         parser.importStream(streamSource, element, parse);
-      } else {
-        parse.addProblem("file "+fileName+" isn't a file", element);
       }
+      else {
+        parse.addProblem(fileName + " is not a normal file", element);
+      }
     }
 
     if (element.hasAttribute("resource")) {
@@ -84,24 +88,23 @@
         URL url = new URL(urlText);
         streamSource = new UrlStreamInput(url);
         parser.importStream(streamSource, element, parse);
-      } catch (Exception e) {
-        parse.addProblem("couldn't open url "+urlText, e);
       }
+      catch (MalformedURLException e) {
+        parse.addProblem("bad url", e, element);
+      }
     }
 
     TypesDescriptor typesDescriptor = new TypesDescriptor();
-
-    List<Element> typeElements = XmlUtil.elements(element, "type");
-    for (Element typeElement: typeElements) {
+    for (Element typeElement : XmlUtil.elements(element, "type")) {
       TypeMapping typeMapping = parseTypeMapping(typeElement, parse, parser);
       typesDescriptor.addTypeMapping(typeMapping);
     }
     return typesDescriptor;
   }
 
-  protected TypeMapping parseTypeMapping(Element element, Parse parse, Parser parser) {
+  protected <S> TypeMapping parseTypeMapping(Element element, Parse parse, Parser parser) {
     TypeMapping typeMapping = new TypeMapping();
-    Type type = new Type();
+    Type<S> type = new Type<S>();
     typeMapping.setType(type);
 
     // type name
@@ -109,96 +112,127 @@
       type.setName(element.getAttribute("name"));
     }
 
-    String hibernateSessionFactoryName = XmlUtil.attribute(element, "hibernate-session-factory");
-
-    // first we get the matcher
-    Matcher matcher = null;
+    // first get the matcher
     if (element.hasAttribute("class")) {
       String className = element.getAttribute("class");
 
       // if type="serializable"
       if ("serializable".equals(className)) {
-        matcher = new SerializableMatcher();
-
+        typeMapping.setMatcher(new SerializableMatcher());
+      }
       // if type="hibernatable"
-      } else if ("hibernatable".equals(className)) {
+      else if ("hibernatable".equals(className)) {
         if (element.hasAttribute("id-type")) {
           String idType = element.getAttribute("id-type");
+          String sessionFactoryName = XmlUtil.attribute(element, "hibernate-session-factory");
+
           if ("long".equalsIgnoreCase(idType)) {
-            matcher = new HibernateLongIdMatcher(hibernateSessionFactoryName);
-          } else if ("string".equalsIgnoreCase(idType)) {
-            matcher = new HibernateStringIdMatcher(hibernateSessionFactoryName);
-          } else {
-            parse.addProblem("id-type was not 'long' or 'string': "+idType, element);
+            typeMapping.setMatcher(new HibernateLongIdMatcher(sessionFactoryName));
           }
-        } else {
+          else if ("string".equalsIgnoreCase(idType)) {
+            typeMapping.setMatcher(new HibernateStringIdMatcher(sessionFactoryName));
+          }
+          else {
+            parse.addProblem("id-type was not 'long' or 'string': " + idType, element);
+          }
+        }
+        else {
           parse.addProblem("id-type is required in a persistable type", element);
         }
-
-      // otherwise, we expect type="some.java.ClassName"
-      } else {
-        matcher = new ClassNameMatcher(className);
       }
-
-    } else {
+      // otherwise, type must be a fully qualified class name
+      else {
+        typeMapping.setMatcher(new ClassNameMatcher(className));
+      }
+    }
+    else {
       // look for the matcher element
       Element matcherElement = XmlUtil.element(element, "matcher");
       Element matcherObjectElement = XmlUtil.element(matcherElement);
-      if (matcherObjectElement!=null) {
-        try {
-          Descriptor descriptor = (Descriptor) parser.parseElement(matcherObjectElement, parse);
-          matcher = (Matcher) WireContext.create(descriptor);
-        } catch (ClassCastException e) {
-          parse.addProblem("matcher is not a "+Matcher.class.getName()+": "+(matcher!=null ? matcher.getClass().getName() : "null"), element);
+      if (matcherObjectElement != null) {
+        Descriptor descriptor = (Descriptor) parser.parseElement(matcherObjectElement, parse);
+        Object obj = WireContext.create(descriptor);
+        if (obj instanceof Matcher) {
+          typeMapping.setMatcher((Matcher) obj);
         }
-      } else {
-        parse.addProblem("no matcher specified in "+XmlUtil.toString(element), element);
+        else {
+          parse.addProblem(obj + " is not a matcher", element);
+        }
       }
+      else {
+        parse.addProblem("no matcher specified in " + XmlUtil.toString(element), element);
+      }
     }
 
-    typeMapping.setMatcher(matcher);
-
     // parsing the converter
-    Converter converter = null;
     if (element.hasAttribute("converter")) {
       String converterClassName = element.getAttribute("converter");
       try {
-        Class<?> converterClass = ReflectUtil.classForName(converterClassName);
-        converter = (Converter) converterClass.newInstance();
-      } catch (Exception e) {
-        parse.addProblem("couldn't instantiate converter "+converterClassName, element);
+        Class<?> clazz = ReflectUtil.classForName(converterClassName);
+        if (Converter.class.isAssignableFrom(clazz)) {
+          @SuppressWarnings("unchecked")
+          Class<? extends Converter<?, S>> converterClass = (Class<? extends Converter<?, S>>) clazz;
+          try {
+            type.setConverter(converterClass.newInstance());
+          }
+          catch (InstantiationException e) {
+            parse.addProblem("failed to instantiate " + converterClass, e, element);
+          }
+          catch (IllegalAccessException e) {
+            parse.addProblem(getClass() + " has no access to " + converterClass, e, element);
+          }
+        }
+        else {
+          parse.addProblem(clazz + " is not a converter", element);
+        }
       }
-    } else {
+      catch (ClassNotFoundException e) {
+        parse.addProblem("converter class not found: " + converterClassName, e, element);
+      }
+    }
+    else {
       // look for the matcher element
       Element converterElement = XmlUtil.element(element, "converter");
       Element converterObjectElement = XmlUtil.element(converterElement);
-      if (converterObjectElement!=null) {
-        try {
-          converter = (Converter) parser.parseElement(converterObjectElement, parse);
-        } catch (ClassCastException e) {
-          parse.addProblem("converter is not a "+Converter.class.getName()+": "+(converter!=null ? converter.getClass().getName() : "null"), element);
+      if (converterObjectElement != null) {
+        Object obj = parser.parseElement(converterObjectElement, parse);
+        if (obj instanceof Converter<?, ?>) {
+          // if converter does not actually produce S, there is a configuration error
+          // and Converter.supports() will eventually throw an exception
+          @SuppressWarnings("unchecked")
+          Converter<?, S> converter = (Converter<?, S>) obj;
+          type.setConverter(converter);
         }
+        else {
+          parse.addProblem(obj + " is not a converter", element);
+        }
       }
     }
 
-    type.setConverter(converter);
-
     // parsing the variable class
-
-    Class<?> variableClass = null;
     if (element.hasAttribute("variable-class")) {
       String variableClassName = element.getAttribute("variable-class");
       try {
-        variableClass = ReflectUtil.classForName(variableClassName);
-      } catch (Exception e) {
-        parse.addProblem("couldn't instantiate variable-class "+variableClassName, e);
+        Class<?> clazz = ReflectUtil.classForName(variableClassName);
+        if (Variable.class.isAssignableFrom(clazz)) {
+          // if variable class does not actually store S, there is a configuration error
+          // and Variable.supports() will eventually throw an exception
+          @SuppressWarnings("unchecked")
+          Class<? extends Variable<S>> variableClass = (Class<? extends Variable<S>>) clazz;
+          type.setVariableClass(variableClass);
+        }
+        else {
+          parse.addProblem(clazz + " is not a variable", element);
+        }
       }
-    } else {
-      parse.addProblem("variable-class is required on a type: "+XmlUtil.toString(element), element);
+      catch (ClassNotFoundException e) {
+        parse.addProblem("variable class not found: " + variableClassName, e, element);
+      }
     }
+    else {
+      parse.addProblem("variable-class is required on a type", element);
+    }
 
-    type.setVariableClass(variableClass);
-
     return typeMapping;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,17 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
  */
-public class CharacterDescriptor extends AbstractDescriptor implements Descriptor {
+public class CharacterDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 
-  String text;
+  private String text;
 
   public CharacterDescriptor() {
   }
@@ -42,17 +41,10 @@
   }
 
   public Object construct(WireContext factory) {
-    if (text==null) {
-      return null;
-    }
-    return new Character( text.charAt(0) );
+    return text != null ? new Character(text.charAt(0)) : null;
   }
 
   public void setValue(Character value) {
-    if (value==null) {
-      text = null;
-    } else {
-      text = value.toString();
-    }
+    text = value != null ? value.toString() : null;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -15,11 +15,10 @@
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.WireException;
 
-
 /**
  * @author Tom Baeyens
  */
-public class CollectionDescriptor extends AbstractDescriptor implements Descriptor {
+public class CollectionDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 
@@ -29,63 +28,73 @@
   protected List<Descriptor> valueDescriptors;
   protected boolean isSynchronized;
 
-  protected CollectionDescriptor() { }
+  protected CollectionDescriptor() {
+  }
 
-  public CollectionDescriptor(String defaultImplClassName) {
-    this.className = defaultImplClassName;
+  public CollectionDescriptor(String defaultClassName) {
+    this.className = defaultClassName;
   }
 
   public Object construct(WireContext wireContext) {
-    Object object = null;
+    Object object;
     try {
       // instantiate
       Class<?> clazz = ReflectUtil.classForName(className);
-      object = clazz.newInstance();
+      try {
+        object = clazz.newInstance();
+      }
+      catch (InstantiationException e) {
+        throw new WireException("failed to instantiate " + clazz, e);
+      }
+      catch (IllegalAccessException e) {
+        throw new WireException(getClass() + " has no access to " + clazz, e);
+      }
+    }
+    catch (ClassNotFoundException e) {
+      throw new WireException("collection class not found: " + className, e);
+    }
 
-      if (isSynchronized) {
-        if (object instanceof SortedSet) {
-          object = Collections.synchronizedSortedSet((SortedSet) object);
-        } else if (object instanceof SortedMap) {
-          object = Collections.synchronizedSortedMap((SortedMap) object);
-        } else if (object instanceof Set) {
-          object = Collections.synchronizedSet((Set) object);
-        } else if (object instanceof Map) {
-          object = Collections.synchronizedMap((Map) object);
-        } else if (object instanceof List) {
-          object = Collections.synchronizedList((List) object);
-        } else if (object instanceof Collection) {
-          object = Collections.synchronizedCollection((Collection) object);
-        }
+    if (isSynchronized) {
+      if (object instanceof SortedSet<?>) {
+        object = Collections.synchronizedSortedSet((SortedSet<?>) object);
       }
-
-    } catch (Exception e) {
-      throw new WireException("couldn't create '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
+      else if (object instanceof SortedMap<?, ?>) {
+        object = Collections.synchronizedSortedMap((SortedMap<?, ?>) object);
+      }
+      else if (object instanceof Set<?>) {
+        object = Collections.synchronizedSet((Set<?>) object);
+      }
+      else if (object instanceof Map<?, ?>) {
+        object = Collections.synchronizedMap((Map<?, ?>) object);
+      }
+      else if (object instanceof List<?>) {
+        object = Collections.synchronizedList((List<?>) object);
+      }
+      else if (object instanceof Collection<?>) {
+        object = Collections.synchronizedCollection((Collection<?>) object);
+      }
     }
     return object;
   }
 
   public void initialize(Object object, WireContext wireContext) {
+    // collection created via Class.newInstance
+    @SuppressWarnings("unchecked")
     Collection<Object> collection = (Collection<Object>) object;
-    try {
-      if (valueDescriptors!=null) {
-        for(Descriptor descriptor: valueDescriptors) {
-          Object element = wireContext.create(descriptor, true);
-          log.trace("adding element "+element+" to collection");
-          collection.add(element);
-        }
+    if (valueDescriptors != null) {
+      for (Descriptor descriptor : valueDescriptors) {
+        Object element = wireContext.create(descriptor, true);
+        log.trace("adding element " + element + " to collection");
+        collection.add(element);
       }
-    } catch (WireException e) {
-      throw e;
-    } catch (Exception e) {
-      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
     }
   }
 
   public void addValueDescriptors(List<Descriptor> otherValueDescriptors) {
-    if (valueDescriptors==null) {
+    if (valueDescriptors == null) {
       valueDescriptors = new ArrayList<Descriptor>();
     }
-    if (otherValueDescriptors!=null) {
+    if (otherValueDescriptors != null) {
       valueDescriptors.addAll(otherValueDescriptors);
     }
   }
@@ -93,18 +102,23 @@
   public String getClassName() {
     return className;
   }
+
   public void setClassName(String className) {
     this.className = className;
   }
+
   public List<Descriptor> getValueDescriptors() {
     return valueDescriptors;
   }
+
   public void setValueDescriptors(List<Descriptor> valueDescriptors) {
     this.valueDescriptors = valueDescriptors;
   }
+
   public boolean isSynchronized() {
     return isSynchronized;
   }
+
   public void setSynchronized(boolean isSynchronized) {
     this.isSynchronized = isSynchronized;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -1,15 +1,14 @@
 package org.jbpm.pvm.internal.wire.descriptor;
 
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.WireException;
 
-public class ContextRefDescriptor extends AbstractDescriptor implements Descriptor {
+public class ContextRefDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
   
-  String contextName;
+  private String contextName;
 
   public Object construct(WireContext wireContext) {
     if (contextName==null) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,17 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
  */
-public class DoubleDescriptor extends AbstractDescriptor implements Descriptor {
+public class DoubleDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 
-  Double doubleVal;
+  private Double doubleVal;
 
   public DoubleDescriptor() {
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,19 +21,17 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
-
 /**
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
  */
-public class FloatDescriptor extends AbstractDescriptor implements Descriptor {
+public class FloatDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 
-  Double doubleVal;
+  private Double doubleVal;
 
   public FloatDescriptor() {
   }
@@ -43,17 +41,10 @@
   }
 
   public Object construct(WireContext factory) {
-    if (doubleVal==null) {
-      return null;
-    }
-    return new Float(doubleVal.floatValue());
+    return doubleVal != null ? new Float(doubleVal) : null;
   }
 
   public void setValue(Float value) {
-    if (value==null) {
-      doubleVal = null;
-    } else {
-      doubleVal = new Double(value);
-    }
+    doubleVal = value != null ? new Double(value) : null;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -25,10 +25,10 @@
 
 import org.jbpm.pvm.internal.history.HistorySession;
 import org.jbpm.pvm.internal.history.HistorySessionChain;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.WireDefinition;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -36,18 +36,22 @@
 
   private static final long serialVersionUID = 1L;
   
-  CollectionDescriptor listDescriptor = new ListDescriptor();
+  private ListDescriptor listDescriptor = new ListDescriptor();
 
   public Object construct(WireContext wireContext) {
-    List<HistorySession> historySessions = (List<HistorySession>) wireContext.create(listDescriptor, false);
-    if (historySessions.size()==1) {
+    List<?> historySessions = (List<?>) wireContext.create(listDescriptor, false);
+    switch (historySessions.size()) {
+    case 0:
+      return null;
+    case 1:
       return historySessions.get(0);
-    } 
-    return new HistorySessionChain(historySessions);
+    default:
+      return new HistorySessionChain(CollectionUtil.checkList(historySessions, HistorySession.class));
+    }
   }
 
   public void add(CollectionDescriptor otherListDescriptor) {
-    this.listDescriptor.addValueDescriptors(otherListDescriptor.getValueDescriptors());
+    listDescriptor.addValueDescriptors(otherListDescriptor.getValueDescriptors());
   }
   
   public Class<?> getType(WireDefinition wireDefinition) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,15 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
- * <p>This {@link Descriptor} specifies an Integer.</p>
+ * <p>This specifies an Integer.</p>
  *
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
- *
- * @see Descriptor
  */
-public class IntegerDescriptor extends AbstractDescriptor implements Descriptor {
+public class IntegerDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 
@@ -46,17 +43,10 @@
   }
 
   public Object construct(WireContext factory) {
-    if (longVal==null) {
-      return null;
-    }
-    return new Integer(longVal.intValue());
+    return longVal != null ? new Integer(longVal.intValue()) : null;
   }
 
   public void setValue(Integer value) {
-    if (value==null) {
-      longVal = null;
-    } else {
-      longVal = new Long(value);
-    }
+    longVal = value != null ? new Long(value) : value;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -30,10 +30,9 @@
  */
 public class JobExecutorDescriptor extends ObjectDescriptor {
   private static final long serialVersionUID = 1L;
-  private static final Log log = Log.getLog(JobExecutorDescriptor.class.getName());
-
+  static final Log log = Log.getLog(JobExecutorDescriptor.class.getName());
   
-  private boolean autoStart = false;
+  private boolean autoStart;
 
   public JobExecutorDescriptor() {
     super(JobExecutor.class.getName());

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,14 +21,13 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
  */
-public class LongDescriptor extends AbstractDescriptor implements Descriptor {
+public class LongDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -6,7 +6,6 @@
 
 import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireException;
 
 /**
  *
@@ -38,25 +37,19 @@
   }
 
   public void initialize(Object object, WireContext wireContext) {
-    Map<Object,Object> map = (Map<Object,Object>) object;
-    try {
-      if (keyDescriptors!=null) {
-        for (int i=0; i<keyDescriptors.size(); i++) {
-          Descriptor keyDescriptor = keyDescriptors.get(i);
-          Descriptor valueDescriptor = valueDescriptors.get(i);
-          Object key = wireContext.create(keyDescriptor, true);
-          Object value = wireContext.create(valueDescriptor, true);
-          map.put(key, value);
-        }
+    // map created via Class.newInstance
+    @SuppressWarnings("unchecked")
+    Map<Object, Object> map = (Map<Object, Object>) object;
+    if (keyDescriptors != null) {
+      for (int i = 0; i < keyDescriptors.size(); i++) {
+        Descriptor keyDescriptor = keyDescriptors.get(i);
+        Descriptor valueDescriptor = valueDescriptors.get(i);
+        Object key = wireContext.create(keyDescriptor, true);
+        Object value = wireContext.create(valueDescriptor, true);
+        map.put(key, value);
       }
-    } catch (WireException e) {
-      throw e;
-    } catch (Exception e) {
-      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
     }
   }
-  
-  
 
   public List<Descriptor> getKeyDescriptors() {
     return keyDescriptors;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,15 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
- * <p>This {@link Descriptor} creates a <code>null</code> object.</p>
+ * <p>This descriptor creates a <code>null</code> object.</p>
  *
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
- *
- * @see Descriptor
  */
-public class NullDescriptor extends AbstractDescriptor implements Descriptor {
+public class NullDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -2,11 +2,10 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
- * <p>This {@link Descriptor} specifies a reference to an object.
+ * <p>This descriptor specifies a reference to an object.
  * The object referenced should be declared somewhere else in the wireContext.</p>
  *
  * <p>The constructed object is the referenced object.</p>
@@ -16,12 +15,12 @@
  * @author Tom Baeyens
  * @author Guillaume Porcher (documentation)
  */
-public class ReferenceDescriptor extends AbstractDescriptor implements Descriptor {
+public class ReferenceDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
 
-  String text = null;
-  String type = null;
+  private String text;
+  private String type;
 
   // TODO add a refExpression that is evaluated with el
   // the base referenced descriptor always should have delayedInitialization = false;
@@ -48,7 +47,7 @@
   }
 
   public boolean isDelayedInitializationAllowed() {
-    return (init == INIT_EAGER || init == INIT_LAZY);
+    return init == INIT_EAGER || init == INIT_LAZY;
   }
   public void setValue(String objectName) {
     this.text = objectName;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -28,6 +28,8 @@
 
   protected long dbid;
   protected int dbversion;
+
+  private static final long serialVersionUID = 1L;
   
   public long getDbid() {
     return dbid;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -2,13 +2,11 @@
 
 import java.lang.reflect.Field;
 
-import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.util.ReflectUtil;
 import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.WireException;
 
-
 /**
  * injects another object into a field.
  *
@@ -78,6 +76,4 @@
   public synchronized void setDescriptor(Descriptor valueDescriptor) {
     this.descriptor = valueDescriptor;
   }
-
-  private static Log log = Log.getLog(FieldOperation.class.getName());
 }

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,7 +27,6 @@
 import org.jbpm.pvm.activities.TestConsoleTestCase;
 import org.jbpm.pvm.activities.WaitState;
 import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.client.ClientProcessDefinition;
 
 public class EventListenerTest extends TestConsoleTestCase {
@@ -52,7 +51,7 @@
       .endActivity()
     .endProcess();
 
-    ClientExecution execution = processDefinition.startProcessInstance();
+    processDefinition.startProcessInstance();
     
     assertEquals("leaving a", testConsole.getLine(0));
     assertEquals("second message while leaving a", testConsole.getLine(1));

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -26,13 +26,11 @@
 import org.jbpm.pvm.activities.AutomaticActivity;
 import org.jbpm.pvm.activities.WaitState;
 import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.client.ClientProcessDefinition;
 import org.jbpm.pvm.internal.client.ClientProcessInstance;
 
 public class ObjectExecutionModeTest extends TestCase {
 
-  
   public void testObjectExecutionMode(){
     ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
     .startProcess("loan")

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -1,10 +1,10 @@
 
 package org.jbpm.pvm.internal.cal;
 
-import java.util.*;
-import junit.framework.*;
-import org.jbpm.pvm.internal.model.*;
+import java.util.Date;
 
+import junit.framework.TestCase;
+
 public class BusinessCalendarTest extends TestCase {
   public void testSubstract() {
     BusinessCalendarImpl businessCalendar = new BusinessCalendarImpl();

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -2,6 +2,7 @@
 package org.jbpm.pvm.internal.el;
 
 import java.util.*;
+
 import junit.framework.*;
 import org.jbpm.pvm.internal.model.*;
 import org.jbpm.pvm.internal.env.*;
@@ -21,31 +22,23 @@
     }
 
     public void testMap() {
-        Map map = new HashMap();
-        map.put("key", "value");
-
         Expression expr = Expression.create("#{map.key}");
         ExecutionImpl executionImpl = new ExecutionImpl();
-        executionImpl.setVariable("map", map);
+        executionImpl.setVariable("map", Collections.singletonMap("key", "value"));
         assertEquals("value", expr.evaluate(executionImpl));
     }
 
     public void testList() {
-        List list = new ArrayList();
-        list.add("value");
-
         Expression expr = Expression.create("#{list[0]}");
         ExecutionImpl executionImpl = new ExecutionImpl();
-        executionImpl.setVariable("list", list);
+        executionImpl.setVariable("list", Arrays.asList("value"));
         assertEquals("value", expr.evaluate(executionImpl));
     }
 
     public void testArray() {
-        String[] array = new String[]{"value"};
-
         Expression expr = Expression.create("#{array[0]}");
         ExecutionImpl executionImpl = new ExecutionImpl();
-        executionImpl.setVariable("array", array);
+        executionImpl.setVariable("array", new String[] {"value"});
         assertEquals("value", expr.evaluate(executionImpl));
     }
 
@@ -69,13 +62,9 @@
     }
 
     public void testFunction() {
-        List list = new ArrayList();
-        list.add("1");
-        list.add("2");
-
         Expression expr = Expression.create("#{length(list)}");
         ExecutionImpl executionImpl = new ExecutionImpl();
-        executionImpl.setVariable("list", list);
+        executionImpl.setVariable("list", Arrays.asList("1", "2"));
         assertEquals(2, expr.evaluate(executionImpl));
     }
 

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,19 +21,17 @@
  */
 package org.jbpm.pvm.internal.expr;
 
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
-import java.util.HashMap;
 import java.util.Map;
+
 import org.jbpm.pvm.activities.WaitState;
 import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-
 import org.jbpm.pvm.internal.el.Expression;
 import org.jbpm.pvm.internal.el.UelValueExpression;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.test.JbpmTestCase;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -86,14 +84,11 @@
         Expression.LANGUAGE_UEL_VALUE);
     UelValueExpression uve = ((UelValueExpression) expression);
 
-    Map response = new HashMap();
-    List resultSet = new ArrayList();
     int[] array = new int[]{0, 1, 2, 3};
+    List<?> resultSet = Collections.singletonList(array);
+    Map<?, ?> response = Collections.singletonMap("resultSet", resultSet);
 
-    response.put("resultSet", resultSet);
-    resultSet.add(array);
     execution.setVariable("response", response);
-
     assertEquals(Boolean.TRUE, uve.evaluate(execution));
   }
 

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -37,7 +37,7 @@
  */
 public class DbidGeneratorTest extends TestCase {
 
-  private static Log log = Log.getLog(DbidGeneratorTest.class.getName());
+  static Log log = Log.getLog(DbidGeneratorTest.class.getName());
 
   public void testDbidGenerator() {
     ProcessEngine processEngine = new Configuration().buildProcessEngine();
@@ -72,7 +72,7 @@
           DbidGenerator dbidGenerator = environment.get(DbidGenerator.class);
           for (int i=10020; i<20020; i++) {
             assertEquals(i, dbidGenerator.getNextId());
-            if ((i%1000) == 0) {
+            if (i%1000 == 0) {
               log.debug("just got dbid "+i+"...");
             }
           }

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -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;
@@ -185,8 +184,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>();
+    protected static Map<String, Integer> dayMap = new HashMap<String, Integer>();
     static {
         monthMap.put("JAN", new Integer(0));
         monthMap.put("FEB", new Integer(1));
@@ -210,21 +209,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 
@@ -259,13 +258,12 @@
         Calendar testDateCal = Calendar.getInstance();
         testDateCal.setTime(date);
         testDateCal.set(Calendar.MILLISECOND, 0);
+
         Date originalDate = testDateCal.getTime();
-        
         testDateCal.add(Calendar.SECOND, -1);
         
         Date timeAfter = getTimeAfter(testDateCal.getTime());
-        
-        return ((timeAfter != null) && (timeAfter.equals(originalDate)));
+        return timeAfter != null && timeAfter.equals(originalDate);
     }
     
     /**
@@ -377,25 +375,25 @@
         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;
@@ -525,7 +523,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.",
@@ -635,8 +633,8 @@
             } else {
                 throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i);
             }
-            TreeSet set = getSet(type);
-            set.add(new Integer(val));
+            TreeSet<Integer> set = getSet(type);
+            set.add(Integer.valueOf(val));
             i++;
             return i;
         }
@@ -647,8 +645,8 @@
             } else {
                 throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
             }
-            TreeSet set = getSet(type);
-            set.add(new Integer(val));
+            TreeSet<Integer> set = getSet(type);
+            set.add(Integer.valueOf(val));
             i++;
             return i;
         }
@@ -669,8 +667,8 @@
                         i);
             }
 
-            TreeSet set = getSet(type);
-            set.add(new Integer(val));
+            TreeSet<Integer> set = getSet(type);
+            set.add(Integer.valueOf(val));
             i++;
             return i;
         }
@@ -788,7 +786,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 "?";
@@ -799,10 +797,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(",");
@@ -814,7 +810,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 "?";
@@ -825,10 +821,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(",");
@@ -859,7 +853,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)) {
@@ -958,7 +952,7 @@
         }
     }
 
-    protected TreeSet getSet(int type) {
+    protected TreeSet<Integer> getSet(int type) {
         switch (type) {
             case SECOND:
                 return seconds;
@@ -1004,7 +998,7 @@
     }
 
     protected int getMonthNumber(String s) {
-        Integer integer = (Integer) monthMap.get(s);
+        Integer integer = monthMap.get(s);
 
         if (integer == null) {
             return -1;
@@ -1014,7 +1008,7 @@
     }
 
     protected int getDayOfWeekNumber(String s) {
-        Integer integer = (Integer) dayMap.get(s);
+        Integer integer = dayMap.get(s);
 
         if (integer == null) {
             return -1;
@@ -1048,7 +1042,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);
@@ -1057,9 +1051,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);
             }
@@ -1073,9 +1067,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) {
@@ -1094,9 +1088,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) {
@@ -1162,7 +1156,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);
@@ -1193,14 +1187,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++;
                 }
                 
@@ -1217,7 +1211,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;
@@ -1260,7 +1254,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;
@@ -1304,11 +1298,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;
@@ -1364,9 +1358,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) {
@@ -1391,7 +1385,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...
             }
@@ -1448,7 +1442,7 @@
     }
     
     protected boolean isLeapYear(int year) {
-        return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
+        return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
     }
 
     protected int getLastDayOfMonth(int monthNum, int year) {

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -416,7 +416,7 @@
         }
 
         Date eTime = getEndTime();
-        if (eTime != null && startTime != null && eTime.before(startTime)) {
+        if (eTime != null && eTime.before(startTime)) {
             throw new IllegalArgumentException(
                 "End time cannot be before start time");
         }

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -23,26 +23,14 @@
 
 import junit.framework.TestCase;
 
-import org.hibernate.Session;
 import org.hibernate.StaleStateException;
-
-import org.jbpm.api.Configuration;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.Environment;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.cmd.CommandService;
-
 import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;
 
-
 /**
  * @author Huisheng Xu
  */
 public class RetryInterceptorTest extends TestCase {
 
-  private static Log log = Log.getLog(RetryInterceptorTest.class.getName());
-
   public void testShouldRetryStaleStateException() {
     RetryInterceptor retryInterceptor = new RetryInterceptor();
     retryInterceptor.setTargetExceptionClass(StaleStateException.class);

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 
 import org.jbpm.pvm.internal.xml.Problem;
@@ -44,27 +45,22 @@
       "</objects>"
     );
 
-    List<Object> values = (List<Object>) wireContext.get("l");
-    // make a copy so that we can compare 2 ArrayLists
-    values = new ArrayList<Object>(values);
-
-    List<Object> expected = new ArrayList<Object>(3);
+    List<Object> expected = new ArrayList<Object>();
     expected.add(Boolean.TRUE);
     expected.add("v");
     expected.add(null);
 
-    assertEquals(expected, values);
+    assertEquals(expected, wireContext.get("l"));
   }
 
   public void testCustomListType() {
     WireContext wireContext = createWireContext(
       "<objects>" +
-      "  <list name='l' class='java.util.LinkedList' />" +
+      "  <list name='l' class='" + LinkedList.class.getName() + "' />" +
       "</objects>"
     );
-    Object l = wireContext.get("l");
-    assertNotNull(l);
-    assertEquals("java.util.LinkedList", l.getClass().getName());
+
+    assertSame(LinkedList.class, wireContext.get("l").getClass());
   }
 
   public void testInvalidListType() {
@@ -84,7 +80,8 @@
         "</objects>"
     );
 
-    assertTextPresent("class "+HashSet.class.getName()+" is not a "+List.class.getName(), problems.get(0).getMsg());
+    assertTextPresent("class " + HashSet.class.getName() + " is not a " + List.class.getName(),
+      problems.get(0).getMsg());
   }
 
   public void testProblemUnknownValue() {
@@ -103,7 +100,7 @@
   public static class TextElement {
     String text;
   }
-  
+
   public void testElementsWithInitialization() {
     WireContext wireContext = createWireContext(
       "<objects>" +
@@ -126,8 +123,10 @@
       "  </list>" +
       "</objects>"
     );
+
+    @SuppressWarnings("unchecked")
     List<TextElement> l = (List<TextElement>) wireContext.get("l");
-    assertEquals(l.toString(), 3, l.size());
+    assertEquals(3, l.size());
     assertEquals("a", l.get(0).text);
     assertEquals("b", l.get(1).text);
     assertEquals("c", l.get(2).text);

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -36,7 +36,7 @@
       "</objects>"
     );
 
-    Map m = (Map) wireContext.get("m");
+    Map<?, ?> m = (Map<?, ?>) wireContext.get("m");
     assertEquals(m.toString(), 2, m.size());
     assertNull(m.get(Boolean.TRUE));
     assertEquals(new Long(5), m.get("a"));
@@ -107,7 +107,7 @@
       "</objects>"
     );
 
-    Map m = (Map) wireContext.get("m");
+    Map<?, ?> m = (Map<?, ?>) wireContext.get("m");
     assertEquals(m.toString(), 2, m.size());
     assertEquals("null", m.get("true"));
     assertEquals("5", m.get("a"));

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -71,7 +71,7 @@
       "</objects>"
     );
 
-    List l = (List) wireContext.get("l");
+    List<?> l = (List<?>) wireContext.get("l");
     assertNotNull(l);
 
     Object o = wireContext.get("o");
@@ -97,7 +97,7 @@
       "</objects>"
     );
 
-    Map m = (Map) wireContext.get("m");
+    Map<?, ?> m = (Map<?, ?>) wireContext.get("m");
     assertNotNull(m);
 
     Object o = wireContext.get("o");
@@ -116,7 +116,7 @@
       "</objects>"
     );
 
-    Set s = (Set) wireContext.get("s");
+    Set<?> s = (Set<?>) wireContext.get("s");
     assertNotNull(s);
 
     Object o = wireContext.get("o");

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -19,7 +19,7 @@
       "</objects>"
     );
     
-    Set s = (Set) wireContext.get("s");
+    Set<?> s = (Set<?>) wireContext.get("s");
     assertEquals(s.toString(), 4, s.size());
     assertTrue(s.contains(Boolean.TRUE));
     assertTrue(s.contains(""));

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,16 +21,13 @@
  */
 package org.jbpm.pvm.internal.wire.binding;
 
-import java.util.List;
-import org.jbpm.test.BaseJbpmTestCase;
 import org.jbpm.pvm.internal.tx.JtaTransaction;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.jbpm.pvm.internal.xml.Bindings;
-import org.jbpm.pvm.internal.xml.Problem;
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Bindings;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.test.BaseJbpmTestCase;
 
-
 /**
  * @author Huisheng Xu
  */

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2010-10-09 10:16:53 UTC (rev 6751)
@@ -26,14 +26,17 @@
 import javax.transaction.Synchronization;
 
 import org.hibernate.Session;
+import org.hibernate.criterion.Order;
+
 import org.jbpm.api.JbpmException;
-import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
+import org.jbpm.api.cmd.VoidCommand;
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
 import org.jbpm.pvm.internal.tx.Transaction;
+import org.jbpm.pvm.internal.util.CollectionUtil;
 import org.jbpm.test.JbpmTestCase;
 
 /**
@@ -49,33 +52,38 @@
   }
 
   public void testCommit() {
-    commandService.execute(new Command<Object>() {
-      public Object execute(Environment environment) {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
+
+      protected void executeVoid(Environment environment) {
         Session session = environment.get(Session.class);
         session.save(new HistoryCommentImpl("if i only had the time to write code"));
-        return null;
       }
     });
 
-    commandService.execute(new Command<Object>() {
-      public Object execute(Environment environment) {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
+
+      protected void executeVoid(Environment environment) {
         Session session = environment.get(Session.class);
-        List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
-        assertEquals("if i only had the time to write code", comments.get(0).getMessage());
-        session.delete(comments.get(0));
-        return null;
+        HistoryCommentImpl comment =
+          (HistoryCommentImpl) session.createCriteria(HistoryCommentImpl.class).uniqueResult();
+        assertEquals("if i only had the time to write code", comment.getMessage());
+        session.delete(comment);
       }
     });
   }
 
   public static class MyOwnRuntimeException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
   }
 
   public void testRollbackRuntimeException() {
     try {
-      commandService.execute(new Command<Object>() {
+      commandService.execute(new VoidCommand() {
+        private static final long serialVersionUID = 1L;
 
-        public Object execute(Environment environment) {
+        protected void executeVoid(Environment environment) {
           Session session = environment.get(Session.class);
           session.save(new HistoryCommentImpl("if i only had the time to write code"));
           throw new MyOwnRuntimeException();
@@ -86,25 +94,27 @@
       // OK
     }
 
-    commandService.execute(new Command<Object>() {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
 
-      public Object execute(Environment environment) {
+      protected void executeVoid(Environment environment) {
         Session session = environment.get(Session.class);
-        List<HistoryDetailImpl> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
+        List<?> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
         assertEquals(0, comments.size());
-        return null;
       }
     });
   }
 
   public static class MyOwnCheckedException extends Exception {
+    private static final long serialVersionUID = 1L;
   }
 
   public void testRollbackCheckedException() {
     try {
-      commandService.execute(new Command<Object>() {
+      commandService.execute(new VoidCommand() {
+        private static final long serialVersionUID = 1L;
 
-        public Object execute(Environment environment) throws Exception {
+        protected void executeVoid(Environment environment) throws Exception {
           Session session = environment.get(Session.class);
           session.save(new HistoryCommentImpl("if i only had the time to write code"));
           throw new MyOwnCheckedException();
@@ -116,13 +126,13 @@
       assertSame(MyOwnCheckedException.class, e.getCause().getClass());
     }
 
-    commandService.execute(new Command<Object>() {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
 
-      public Object execute(Environment environment) {
+      protected void executeVoid(Environment environment) {
         Session session = environment.get(Session.class);
-        List<HistoryDetailImpl> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
+        List<?> comments = session.createCriteria(HistoryDetailImpl.class).list();
         assertEquals(0, comments.size());
-        return null;
       }
     });
   }
@@ -139,28 +149,30 @@
   }
 
   public void testSuccessfulSynchronization() {
-    commandService.execute(new Command<Object>() {
-      public Object execute(Environment environment) throws Exception {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
+
+      protected void executeVoid(Environment environment) throws Exception {
         Session session = environment.get(Session.class);
         session.save(new HistoryCommentImpl("a) if i only had the time to write code"));
         Transaction transaction = environment.get(Transaction.class);
         SuccessfulSynchronization successfulSynchronization = new SuccessfulSynchronization();
         transaction.registerSynchronization(successfulSynchronization);
-        return null;
       }
     });
 
-    commandService.execute(new Command<Object>() {
-      public Object execute(Environment environment) {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
+
+      protected void executeVoid(Environment environment) {
         Session session = environment.get(Session.class);
-        List<HistoryCommentImpl> comments = session.createQuery(
-          "from " + HistoryCommentImpl.class.getName()+" as hc " +
-          "order by hc.message asc ").list();
+        List<HistoryCommentImpl> comments = CollectionUtil.checkList(session.createCriteria(HistoryCommentImpl.class)
+          .addOrder(Order.asc("message"))
+          .list(), HistoryCommentImpl.class);
         assertEquals("a) if i only had the time to write code", comments.get(0).getMessage());
         assertEquals("b) hello from before completion", comments.get(1).getMessage());
         session.delete(comments.get(0));
         session.delete(comments.get(1));
-        return null;
       }
     });
   }
@@ -179,15 +191,15 @@
 
   public void testUnsuccessfulSynchronization() {
     try {
-      commandService.execute(new Command<Object>() {
+      commandService.execute(new VoidCommand() {
+        private static final long serialVersionUID = 1L;
 
-        public Object execute(Environment environment) throws Exception {
+        protected void executeVoid(Environment environment) throws Exception {
           Session session = environment.get(Session.class);
           session.save(new HistoryCommentImpl("a) if i only had the time to write code"));
           Transaction transaction = environment.get(Transaction.class);
           UnsuccessfulSynchronization unsuccessfulSynchronization = new UnsuccessfulSynchronization();
           transaction.registerSynchronization(unsuccessfulSynchronization);
-          return null;
         }
       });
       fail("expected exception");
@@ -199,15 +211,14 @@
     // caused
     // the previous transaction to rollback
 
-    commandService.execute(new Command<Object>() {
+    commandService.execute(new VoidCommand() {
+      private static final long serialVersionUID = 1L;
 
-      public Object execute(Environment environment) {
+      protected void executeVoid(Environment environment) {
         Session session = environment.get(Session.class);
-        List<HistoryDetailImpl> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
+        List<?> comments = session.createCriteria(HistoryDetailImpl.class).list();
         assertEquals(0, comments.size());
-        return null;
       }
     });
   }
-
 }



More information about the jbpm-commits mailing list