[jbpm-commits] JBoss JBPM SVN: r3705 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/db and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 23 02:10:21 EST 2009


Author: alex.guizar at jboss.com
Date: 2009-01-23 02:10:21 -0500 (Fri, 23 Jan 2009)
New Revision: 3705

Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
   jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
   jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
   jbpm3/trunk/modules/core/src/test/resources/log4j.xml
Log:
JBPM-1812 remove hbm2ddl.auto property, set to 'create' in hsqldb only
support for custom table creation

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -42,7 +42,7 @@
   private static final long serialVersionUID = 1L;
   private static final Log log = LogFactory.getLog(EventCallback.class);
 
-  private static Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
+  private static final Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
 
   public void processStart() {
     registerNotification(Event.EVENTTYPE_PROCESS_START);
@@ -92,8 +92,10 @@
           Semaphore eventSemaphore = getEventSemaphore(event);
           eventSemaphore.release();
         }
+        else {
+          log.warn("not sending '" + event + "' notification, transaction is " + statusToString(status));
+        }
       }
-
     };
     JbpmContext.getCurrentJbpmContext()
         .getSession()
@@ -101,6 +103,44 @@
         .registerSynchronization(notification);
   }
 
+  private static String statusToString(int status) {
+    String text;
+    switch (status) {
+    case Status.STATUS_ACTIVE:
+      text = "active";
+      break;
+    case Status.STATUS_COMMITTED:
+      text = "committed";
+      break;
+    case Status.STATUS_COMMITTING:
+      text = "committing";
+      break;
+    case Status.STATUS_MARKED_ROLLBACK:
+      text = "marked for rollback";
+      break;
+    case Status.STATUS_NO_TRANSACTION:
+      text = "absent";
+      break;
+    case Status.STATUS_PREPARED:
+      text = "prepared";
+      break;
+    case Status.STATUS_PREPARING:
+      text = "preparing";
+      break;
+    case Status.STATUS_ROLLEDBACK:
+      text = "rolled back";
+      break;
+    case Status.STATUS_ROLLING_BACK:
+      text = "rolling back";
+      break;
+    case Status.STATUS_UNKNOWN:
+    default:
+      text = "in unknown status";
+      break;
+    }
+    return text;
+  }
+
   public static void waitForEvent(String event) {
     waitForEvent(event, DEFAULT_TIMEOUT);
   }
@@ -134,11 +174,14 @@
   }
 
   public static void clear() {
-    for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
-      int permits = entry.getValue().drainPermits();
-      if (permits != 0) {
-        log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
+    synchronized (eventSemaphores) {
+      for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
+        int permits = entry.getValue().drainPermits();
+        if (permits != 0) {
+          log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
+        }
       }
+      eventSemaphores.clear();
     }
   }
 }
\ No newline at end of file

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -249,8 +249,7 @@
  * </tr>
  * </table>
  */
-public class JbpmConfiguration implements Serializable
-{
+public class JbpmConfiguration implements Serializable {
 
   private static final long serialVersionUID = 1L;
 
@@ -269,54 +268,47 @@
     }
   }
 
-  public JbpmConfiguration(ObjectFactory objectFactory)
-  {
+  public JbpmConfiguration(ObjectFactory objectFactory) {
     this.objectFactory = objectFactory;
   }
 
-  public static JbpmConfiguration getInstance()
-  {
+  public static JbpmConfiguration getInstance() {
     return getInstance(null);
   }
 
-  public static JbpmConfiguration getInstance(String resource)
-  {
-    if (resource == null)
-    {
+  public static JbpmConfiguration getInstance(String resource) {
+    if (resource == null) {
       resource = "jbpm.cfg.xml";
     }
     JbpmConfiguration instance = null;
-    synchronized (instances)
-    {
+    synchronized (instances) {
       instance = instances.get(resource);
-      if (instance == null)
-      {
-        if (defaultObjectFactory != null)
-        {
-          log.debug("creating jbpm configuration from given default object factory '" + defaultObjectFactory + "'");
+      if (instance == null) {
+        if (defaultObjectFactory != null) {
+          log.debug("creating jbpm configuration from given default object factory '"
+              + defaultObjectFactory
+              + "'");
           instance = new JbpmConfiguration(defaultObjectFactory);
         }
-        else
-        {
-          try
-          {
+        else {
+          try {
             log.info("using jbpm configuration resource '" + resource + "'");
             InputStream jbpmCfgXmlStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
             /*
-             * if a custom resource is specified, but not found in the classpath log a warning
+             * if a custom resource is specified, but not found in the classpath, log a warning
              * (otherwise, users who want to load custom stuff will be confused if the resource is
              * not found and not loaded, without any notice)
              */
-            if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource))
-            {
+            if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource)) {
               log.warn("jbpm configuration resource '" + resource + "' is not available");
             }
             ObjectFactory objectFactory = parseObjectFactory(jbpmCfgXmlStream);
             instance = createJbpmConfiguration(objectFactory);
           }
-          catch (RuntimeException e)
-          {
-            throw new JbpmException("couldn't parse jbpm configuration from resource '" + resource + "'", e);
+          catch (RuntimeException e) {
+            throw new JbpmException("couldn't parse jbpm configuration from resource '"
+                + resource
+                + "'", e);
           }
         }
         instances.put(resource, instance);
@@ -325,29 +317,24 @@
     return instance;
   }
 
-  public static boolean hasInstance(String resource)
-  {
+  public static boolean hasInstance(String resource) {
     boolean hasInstance = false;
-    if (resource == null)
-    {
+    if (resource == null) {
       resource = "jbpm.cfg.xml";
     }
-    if ((instances != null) && (instances.containsKey(resource)))
-    {
+    if ((instances != null) && (instances.containsKey(resource))) {
       hasInstance = true;
     }
     return hasInstance;
   }
 
-  protected static ObjectFactory parseObjectFactory(InputStream inputStream)
-  {
+  protected static ObjectFactory parseObjectFactory(InputStream inputStream) {
     log.debug("loading defaults in jbpm configuration");
     ObjectFactoryParser objectFactoryParser = new ObjectFactoryParser();
     ObjectFactoryImpl objectFactoryImpl = new ObjectFactoryImpl();
     objectFactoryParser.parseElementsFromResource("org/jbpm/default.jbpm.cfg.xml", objectFactoryImpl);
 
-    if (inputStream != null)
-    {
+    if (inputStream != null) {
       log.debug("loading specific configuration...");
       objectFactoryParser.parseElementsStream(inputStream, objectFactoryImpl);
     }
@@ -358,31 +345,26 @@
   /**
    * create an ObjectFacotory from an XML string.
    */
-  public static JbpmConfiguration parseXmlString(String xml)
-  {
+  public static JbpmConfiguration parseXmlString(String xml) {
     log.debug("creating jbpm configuration from xml string");
     InputStream inputStream = null;
-    if (xml != null)
-    {
+    if (xml != null) {
       inputStream = new ByteArrayInputStream(xml.getBytes());
     }
     ObjectFactory objectFactory = parseObjectFactory(inputStream);
     return createJbpmConfiguration(objectFactory);
   }
 
-  protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory)
-  {
+  protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory) {
     JbpmConfiguration jbpmConfiguration = new JbpmConfiguration(objectFactory);
 
-    // now we make the bean jbpm.configuration always availble
-    if (objectFactory instanceof ObjectFactoryImpl)
-    {
+    // make the bean jbpm.configuration always available
+    if (objectFactory instanceof ObjectFactoryImpl) {
       ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl) objectFactory;
       ObjectInfo jbpmConfigurationInfo = new ValueInfo("jbpmConfiguration", jbpmConfiguration);
       objectFactoryImpl.addObjectInfo(jbpmConfigurationInfo);
 
-      if (getHideStaleObjectExceptions(objectFactory))
-      {
+      if (getHideStaleObjectExceptions(objectFactory)) {
         StaleObjectLogConfigurer.hideStaleObjectExceptions();
       }
     }
@@ -390,77 +372,63 @@
     return jbpmConfiguration;
   }
 
-  private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory)
-  {
-    if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions"))
-    {
+  private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory) {
+    if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions")) {
       return true;
     }
     Object object = objectFactory.createObject("jbpm.hide.stale.object.exceptions");
     return object instanceof Boolean ? ((Boolean) object).booleanValue() : true;
   }
 
-  public static JbpmConfiguration parseInputStream(InputStream inputStream)
-  {
+  public static JbpmConfiguration parseInputStream(InputStream inputStream) {
     ObjectFactory objectFactory = parseObjectFactory(inputStream);
     log.debug("creating jbpm configuration from input stream");
     return createJbpmConfiguration(objectFactory);
   }
 
-  public static JbpmConfiguration parseResource(String resource)
-  {
+  public static JbpmConfiguration parseResource(String resource) {
     InputStream inputStream = null;
     log.debug("creating jbpm configuration from resource '" + resource + "'");
-    if (resource != null)
-    {
+    if (resource != null) {
       inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
     }
     ObjectFactory objectFactory = parseObjectFactory(inputStream);
     return createJbpmConfiguration(objectFactory);
   }
 
-  public JbpmContext createJbpmContext()
-  {
+  public JbpmContext createJbpmContext() {
     return createJbpmContext(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public JbpmContext createJbpmContext(String name)
-  {
+  public JbpmContext createJbpmContext(String name) {
     JbpmContext jbpmContext = (JbpmContext) objectFactory.createObject(name);
     jbpmContext.jbpmConfiguration = this;
     jbpmContextCreated(jbpmContext);
     return jbpmContext;
   }
 
-  public ServiceFactory getServiceFactory(String serviceName)
-  {
+  public ServiceFactory getServiceFactory(String serviceName) {
     return getServiceFactory(serviceName, JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName)
-  {
+  public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName) {
     ServiceFactory serviceFactory = null;
     JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try
-    {
+    try {
       serviceFactory = jbpmContext.getServices().getServiceFactory(serviceName);
     }
-    finally
-    {
+    finally {
       jbpmContext.close();
     }
     return serviceFactory;
   }
 
-  public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition)
-  {
+  public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
     ProcessClassLoaderFactory factory = null;
-    if (Configs.hasObject("jbpm.processClassLoader"))
-    {
+    if (Configs.hasObject("jbpm.processClassLoader")) {
       factory = (ProcessClassLoaderFactory) Configs.getObject("jbpm.processClassLoader");
     }
-    else
-    {
+    else {
       factory = new DefaultProcessClassLoaderFactory();
     }
     return factory.getProcessClassLoader(processDefinition);
@@ -469,158 +437,104 @@
   /**
    * gives the jbpm domain model access to configuration information via the current JbpmContext.
    */
-  public static class Configs
-  {
+  public static class Configs {
 
-    private Configs()
-    {
+    private Configs() {
       // hide default constructor to prevent instantiation
     }
 
-    public static ObjectFactory getObjectFactory()
-    {
+    public static ObjectFactory getObjectFactory() {
       ObjectFactory objectFactory = null;
       JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
-      if (jbpmContext != null)
-      {
+      if (jbpmContext != null) {
         objectFactory = jbpmContext.objectFactory;
       }
-      else
-      {
+      else {
         objectFactory = getInstance().objectFactory;
       }
       return objectFactory;
     }
 
-    public static void setDefaultObjectFactory(ObjectFactory objectFactory)
-    {
+    public static void setDefaultObjectFactory(ObjectFactory objectFactory) {
       defaultObjectFactory = objectFactory;
     }
 
-    public static boolean hasObject(String name)
-    {
+    public static boolean hasObject(String name) {
       ObjectFactory objectFactory = getObjectFactory();
       return objectFactory.hasObject(name);
     }
 
-    public static synchronized Object getObject(String name)
-    {
+    public static synchronized Object getObject(String name) {
       ObjectFactory objectFactory = getObjectFactory();
       return objectFactory.createObject(name);
     }
 
-    public static String getString(String name)
-    {
+    public static String getString(String name) {
       return (String) getObject(name);
     }
 
-    public static long getLong(String name)
-    {
+    public static long getLong(String name) {
       return ((Long) getObject(name)).longValue();
     }
 
-    public static int getInt(String name)
-    {
+    public static int getInt(String name) {
       return ((Integer) getObject(name)).intValue();
     }
 
-    public static boolean getBoolean(String name)
-    {
+    public static boolean getBoolean(String name) {
       return ((Boolean) getObject(name)).booleanValue();
     }
   }
 
-  public void cleanSchema()
-  {
+  public void cleanSchema() {
     cleanSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public void cleanSchema(String jbpmContextName)
-  {
-    JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try
-    {
-      Services services = jbpmContext.getServices();
-      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services
-          .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-      persistenceServiceFactory.cleanSchema();
-    }
-    finally
-    {
-      jbpmContext.close();
-    }
+  public void cleanSchema(String jbpmContextName) {
+    DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
+    persistenceServiceFactory.cleanSchema();
   }
 
-  public void createSchema()
-  {
+  public void createSchema() {
     createSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public void createSchema(String jbpmContextName)
-  {
-    JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try
-    {
-      Services services = jbpmContext.getServices();
-      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services
-          .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-      persistenceServiceFactory.createSchema();
-    }
-    finally
-    {
-      jbpmContext.close();
-    }
+  public void createSchema(String jbpmContextName) {
+    DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
+    persistenceServiceFactory.createSchema();
   }
 
-  public void dropSchema()
-  {
+  public void dropSchema() {
     dropSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public void dropSchema(String jbpmContextName)
-  {
-    log.warn("Dropping schema: " + jbpmContextName);
-    JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try
-    {
-      Services services = jbpmContext.getServices();
-      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services
-          .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-      persistenceServiceFactory.dropSchema();
-    }
-    finally
-    {
-      jbpmContext.close();
-    }
+  public void dropSchema(String jbpmContextName) {
+    DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
+    persistenceServiceFactory.dropSchema();
   }
 
-  public void close()
-  {
+  public void close() {
     close(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public void close(String jbpmContextName)
-  {
+  public void close(String jbpmContextName) {
     // stop job executor
-    if (jobExecutor != null)
-    {
+    if (jobExecutor != null) {
       jobExecutor.stop();
     }
 
     JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try
-    {
+    try {
       // close service factories
-      Map<String, ServiceFactory> serviceFactories = jbpmContext.getServices().getServiceFactories();
-      if (serviceFactories != null)
-      {
+      Map<String, ServiceFactory> serviceFactories = jbpmContext.getServices()
+          .getServiceFactories();
+      if (serviceFactories != null) {
         for (ServiceFactory serviceFactory : serviceFactories.values()) {
           serviceFactory.close();
         }
       }
     }
-    finally
-    {
+    finally {
       jbpmContext.close();
     }
 
@@ -628,13 +542,10 @@
     jbpmContextStacks.remove();
 
     // remove from configurations map
-    synchronized (instances)
-    {
+    synchronized (instances) {
       Iterator<JbpmConfiguration> iter = instances.values().iterator();
-      while (iter.hasNext())
-      {
-        if (this == iter.next())
-        {
+      while (iter.hasNext()) {
+        if (this == iter.next()) {
           iter.remove();
           break;
         }
@@ -642,95 +553,78 @@
     }
   }
 
-  static JbpmConfiguration getCurrentJbpmConfiguration()
-  {
+  static JbpmConfiguration getCurrentJbpmConfiguration() {
     JbpmConfiguration currentJbpmConfiguration = null;
     List<JbpmConfiguration> stack = getJbpmConfigurationStack();
-    if (!stack.isEmpty())
-    {
+    if (!stack.isEmpty()) {
       currentJbpmConfiguration = stack.get(stack.size() - 1);
     }
     return currentJbpmConfiguration;
   }
 
-  static List<JbpmConfiguration> getJbpmConfigurationStack()
-  {
+  static List<JbpmConfiguration> getJbpmConfigurationStack() {
     return jbpmConfigurationsStacks.get();
   }
 
-  synchronized void pushJbpmConfiguration()
-  {
+  synchronized void pushJbpmConfiguration() {
     getJbpmConfigurationStack().add(this);
   }
 
-  synchronized void popJbpmConfiguration()
-  {
+  synchronized void popJbpmConfiguration() {
     getJbpmConfigurationStack().remove(this);
   }
 
-  public JbpmContext getCurrentJbpmContext()
-  {
+  public JbpmContext getCurrentJbpmContext() {
     JbpmContext currentJbpmContext = null;
     List<JbpmContext> stack = getJbpmContextStack();
-    if (!stack.isEmpty())
-    {
+    if (!stack.isEmpty()) {
       currentJbpmContext = stack.get(stack.size() - 1);
     }
     return currentJbpmContext;
   }
 
-  List<JbpmContext> getJbpmContextStack()
-  {
+  List<JbpmContext> getJbpmContextStack() {
     return jbpmContextStacks.get();
   }
 
-  void pushJbpmContext(JbpmContext jbpmContext)
-  {
+  void pushJbpmContext(JbpmContext jbpmContext) {
     getJbpmContextStack().add(jbpmContext);
   }
 
-  void popJbpmContext(JbpmContext jbpmContext)
-  {
+  void popJbpmContext(JbpmContext jbpmContext) {
     List<JbpmContext> stack = getJbpmContextStack();
-    if (stack.isEmpty())
-    {
-      throw new JbpmException("closed JbpmContext more than once... check your try-finally's around JbpmContexts blocks");
+    if (stack.isEmpty()) {
+      throw new JbpmException(
+          "closed JbpmContext more than once... check your try-finally's around JbpmContexts blocks");
     }
     JbpmContext popped = stack.remove(stack.size() - 1);
-    if (jbpmContext != popped)
-    {
+    if (jbpmContext != popped) {
       stack.remove(jbpmContext); // prevent context from remaining in the stack
-      throw new JbpmException("closed JbpmContext in some order that differs from creation... check your try-finally's around JbpmContexts blocks");
+      throw new JbpmException(
+          "closed JbpmContext in some order that differs from creation... check your try-finally's around JbpmContexts blocks");
     }
   }
 
-  void jbpmContextCreated(JbpmContext jbpmContext)
-  {
+  void jbpmContextCreated(JbpmContext jbpmContext) {
     pushJbpmConfiguration();
     pushJbpmContext(jbpmContext);
   }
 
-  void jbpmContextClosed(JbpmContext jbpmContext)
-  {
+  void jbpmContextClosed(JbpmContext jbpmContext) {
     popJbpmConfiguration();
     popJbpmContext(jbpmContext);
   }
 
-  public void startJobExecutor()
-  {
+  public void startJobExecutor() {
     getJobExecutor().start();
   }
 
-  public synchronized JobExecutor getJobExecutor()
-  {
-    if (jobExecutor == null)
-    {
-      try
-      {
+  public synchronized JobExecutor getJobExecutor() {
+    if (jobExecutor == null) {
+      try {
         jobExecutor = (JobExecutor) this.objectFactory.createObject("jbpm.job.executor");
       }
-      catch (ClassCastException e)
-      {
+      catch (ClassCastException e) {
         throw new JbpmException("jbpm configuration object under key 'jbpm.job.executor' is not a "
             + JobExecutor.class.getName(), e);
       }

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -38,7 +38,6 @@
 import org.jbpm.JbpmContext;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.job.Job;
 import org.jbpm.job.executor.JobExecutor;
 import org.jbpm.logging.log.ProcessLog;
 import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -81,8 +80,8 @@
     Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
     JbpmSchema jbpmSchema = new JbpmSchema(configuration);
 
-    Map<String, Integer> jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
-    for (Map.Entry<String, Integer> entry : jbpmTablesRecordCount.entrySet()) {
+    Map<String, Integer> recordCountPerTable = jbpmSchema.getRecordCountPerTable();
+    for (Map.Entry<String, Integer> entry : recordCountPerTable.entrySet()) {
       // String tableName = entry.getKey();
       Integer count = entry.getValue();
 
@@ -246,14 +245,10 @@
     return timerCount.intValue();
   }
 
-  protected Job getJob() {
-    return (Job) session.createQuery("from org.jbpm.job.Job").uniqueResult();
-  }
-
   protected void processJobs(long maxWait) {
     commitAndCloseSession();
-    startJobExecutor();
     try {
+      startJobExecutor();
       waitForJobs(maxWait);
     }
     finally {

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -48,6 +48,8 @@
 import org.hibernate.engine.Mapping;
 import org.hibernate.mapping.ForeignKey;
 import org.hibernate.mapping.Table;
+import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
+import org.hibernate.tool.hbm2ddl.TableMetadata;
 import org.hibernate.util.JDBCExceptionReporter;
 import org.jbpm.JbpmException;
 
@@ -58,79 +60,61 @@
 
   private static final long serialVersionUID = 1L;
 
-  Configuration configuration = null;
-  Settings settings;
-  String[] createSql = null;
-  String[] dropSql = null;
-  String[] cleanSql = null;
+  final Configuration configuration;
+  final Settings settings;
 
   ConnectionProvider connectionProvider = null;
   Connection connection = null;
 
-  private Statement statement;
-
   public JbpmSchema(Configuration configuration) {
     this.configuration = configuration;
     this.settings = configuration.buildSettings();
   }
 
   public String[] getCreateSql() {
-    if (createSql == null) {
-      createSql = configuration.generateSchemaCreationScript(settings.getDialect());
-    }
-    return createSql;
+    return configuration.generateSchemaCreationScript(settings.getDialect());
   }
 
   public String[] getDropSql() {
-    if (dropSql == null) {
-      dropSql = configuration.generateDropSchemaScript(settings.getDialect());
-    }
-    return dropSql;
+    return configuration.generateDropSchemaScript(settings.getDialect());
   }
 
   public String[] getCleanSql() {
-    if (cleanSql == null) {
-      Dialect dialect = settings.getDialect();
-      String catalog = settings.getDefaultCatalogName();
-      String schema = settings.getDefaultSchemaName();
-      Mapping mapping = configuration.buildMapping();
+    Dialect dialect = settings.getDialect();
+    String catalog = settings.getDefaultCatalogName();
+    String schema = settings.getDefaultSchemaName();
+    Mapping mapping = configuration.buildMapping();
 
-      // loop over all foreign key constraints
-      List<String> dropForeignKeysSql = new ArrayList<String>();
-      List<String> createForeignKeysSql = new ArrayList<String>();
-      List<String> deleteSql = new ArrayList<String>();
+    // loop over all foreign key constraints
+    List<String> dropForeignKeysSql = new ArrayList<String>();
+    List<String> createForeignKeysSql = new ArrayList<String>();
+    List<String> deleteSql = new ArrayList<String>();
 
-      Iterator<?> iter = configuration.getTableMappings();
-      while (iter.hasNext()) {
-        Table table = (Table) iter.next();
+    for (Iterator<?> ti = configuration.getTableMappings(); ti.hasNext();) {
+      Table table = (Table) ti.next();
+      if (!table.isPhysicalTable()) continue;
 
-        if (table.isPhysicalTable()) {
-          Iterator<?> subIter = table.getForeignKeyIterator();
-          while (subIter.hasNext()) {
-            ForeignKey fk = (ForeignKey) subIter.next();
+      for (Iterator<?> fki = table.getForeignKeyIterator(); fki.hasNext();) {
+        ForeignKey fk = (ForeignKey) fki.next();
+        if (!fk.isPhysicalConstraint()) continue;
 
-            if (fk.isPhysicalConstraint()) {
-              // collect the drop foreign key constraint sql
-              String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
-              dropForeignKeysSql.add(sqlDropString);
+        // collect the drop foreign key sql
+        String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
+        dropForeignKeysSql.add(sqlDropString);
 
-              // and collect the create foreign key constraint sql
-              String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
-              createForeignKeysSql.add(sqlCreateString);
-            }
-          }
-          deleteSql.add("DELETE FROM " + table.getName());
-        }
+        // and collect the create foreign key sql
+        String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
+        createForeignKeysSql.add(sqlCreateString);
       }
+      deleteSql.add("DELETE FROM " + table.getName());
+    }
 
-      // glue
-      // - drop foreign key constraints
-      // - delete contents of all tables
-      // - create foreign key constraints
-      // together to form the clean script
-      cleanSql = concat(dropForeignKeysSql, deleteSql, createForeignKeysSql);
-    }
-    return cleanSql;
+    // glue
+    // - drop foreign key constraints
+    // - delete contents of all tables
+    // - create foreign key constraints
+    // together to form the clean script
+    return concat(dropForeignKeysSql, deleteSql, createForeignKeysSql);
   }
 
   private static String[] concat(List<?>... lists) {
@@ -148,45 +132,33 @@
     return array;
   }
 
-  public boolean hasJbpmTables() {
-    return (getJbpmTables().size() > 0);
-  }
-
-  public List<String> getJbpmTables() {
-    // delete all the data in the jbpm tables
-    List<String> jbpmTableNames = new ArrayList<String>();
-    Iterator<?> iter = configuration.getTableMappings();
-    while (iter.hasNext()) {
+  public List<String> getTableNames() {
+    List<String> tableNames = new ArrayList<String>();
+    for (Iterator<?> iter = configuration.getTableMappings(); iter.hasNext();) {
       Table table = (Table) iter.next();
-
       if (table.isPhysicalTable()) {
-        jbpmTableNames.add(table.getName());
+        tableNames.add(table.getName());
       }
     }
-    return jbpmTableNames;
+    return tableNames;
   }
 
-  public Map<String, Integer> getJbpmTablesRecordCount() {
+  public Map<String, Integer> getRecordCountPerTable() {
     Map<String, Integer> recordCounts = new HashMap<String, Integer>();
     try {
       createConnection();
-
-      statement = connection.createStatement();
-      for (String tableName : getJbpmTables()) {
+      Statement statement = connection.createStatement();
+      for (String tableName : getTableNames()) {
         String sql = "SELECT COUNT(*) FROM " + tableName;
-        try {
-          ResultSet resultSet = statement.executeQuery(sql);
-          resultSet.next();
-          recordCounts.put(tableName, resultSet.getInt(1));
-          resultSet.close();
-        }
-        catch (SQLException e) {
-          throw new JbpmException("could not execute sql '" + sql + "'", e);
-        }
+        ResultSet resultSet = statement.executeQuery(sql);
+        resultSet.next();
+        recordCounts.put(tableName, resultSet.getInt(1));
+        resultSet.close();
       }
+      statement.close();
     }
     catch (SQLException e) {
-      throw new JbpmException("database connection failed", e);
+      throw new JbpmException("could not count records", e);
     }
     finally {
       closeConnection();
@@ -195,16 +167,30 @@
   }
 
   public void dropSchema() {
-    execute(getDropSql());
+    try {
+      execute(getDropSql());
+    }
+    catch (SQLException e) {
+      throw new JbpmException("could not drop schema", e);
+    }
   }
 
   public void createSchema() {
-    execute(getCreateSql());
+    try {
+      execute(getCreateSql());
+    }
+    catch (SQLException e) {
+      throw new JbpmException("could not create schema", e);
+    }
   }
 
   public void cleanSchema() {
-    if (!getJbpmTables().isEmpty())
+    try {
       execute(getCleanSql());
+    }
+    catch (SQLException e) {
+      throw new JbpmException("could not clean schema", e);
+    }
   }
 
   public void saveSqlScripts(String dir, String prefix) {
@@ -229,6 +215,73 @@
     return result;
   }
 
+  public boolean tableExists(String tableName) {
+    Table table = findTableMapping(tableName);
+    try {
+      createConnection();
+      return getTableMetadata(table) != null;
+    }
+    catch (SQLException e) {
+      throw new JbpmException("could not tell whether table exists: " + tableName, e);
+    }
+    finally {
+      closeConnection();
+    }
+  }
+
+  public void createTable(String tableName) {
+    Table table = findTableMapping(tableName);
+    String sql = table.sqlCreateString(settings.getDialect(), configuration.buildMapping(),
+        settings.getDefaultCatalogName(), settings.getDefaultSchemaName());
+    try {
+      execute(sql);
+    }
+    catch (SQLException e) {
+      throw new JbpmException("could not create table: " + tableName, e);
+    }
+  }
+
+  public void updateTable(String tableName) {
+    Table table = findTableMapping(tableName);
+    try {
+      createConnection();
+      Iterator<?> sqls = table.sqlAlterStrings(settings.getDialect(), configuration.buildMapping(),
+          getTableMetadata(table), settings.getDefaultCatalogName(),
+          settings.getDefaultSchemaName());
+
+      Statement statement = connection.createStatement();
+      while (sqls.hasNext()) {
+        String sql = (String) sqls.next();
+        statement.executeUpdate(sql);
+      }
+      statement.close();
+    }
+    catch (SQLException e) {
+      throw new JbpmException("could not update table: " + tableName, e);
+    }
+    finally {
+      closeConnection();
+    }
+  }
+
+  private Table findTableMapping(String tableName) {
+    for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
+      Table table = (Table) i.next();
+      if (tableName.equals(table.getName())) {
+        return table;
+      }
+    }
+    throw new JbpmException("no mapping found for table: " + tableName);
+  }
+
+  private TableMetadata getTableMetadata(Table table) throws SQLException {
+    DatabaseMetadata databaseMetadata = new DatabaseMetadata(connection, settings.getDialect());
+    return databaseMetadata.getTableMetadata(table.getName(),
+        table.getSchema() == null ? settings.getDefaultSchemaName() : table.getSchema(),
+        table.getCatalog() == null ? settings.getDefaultCatalogName() : table.getCatalog(),
+        table.isQuoted());
+  }
+
   public static void main(String[] args) {
     if ((args == null) || (args.length == 0)) {
       syntax();
@@ -295,40 +348,32 @@
     }
   }
 
-  void execute(String[] sqls) {
+  void execute(String... sqls) throws SQLException {
     boolean showSql = settings.isShowSqlEnabled();
     try {
       createConnection();
-
-      statement = connection.createStatement();
+      Statement statement = connection.createStatement();
       for (String sql : sqls) {
-        if (showSql)
-          log.debug(sql);
-        try {
-          statement.executeUpdate(sql);
-        }
-        catch (SQLException e) {
-          throw new JbpmException("could not execute '" + sql + "'", e);
-        }
+        if (showSql) System.out.println(sql);
+        statement.executeUpdate(sql);
       }
+      statement.close();
     }
-    catch (SQLException e) {
-      throw new JbpmException("database connection failed", e);
-    }
     finally {
       closeConnection();
     }
   }
 
+  void createConnection() throws SQLException {
+    connectionProvider = settings.getConnectionProvider();
+    connection = connectionProvider.getConnection();
+    if (!connection.getAutoCommit()) {
+      connection.commit();
+      connection.setAutoCommit(true);
+    }
+  }
+
   void closeConnection() {
-    if (statement != null) {
-      try {
-        statement.close();
-      }
-      catch (SQLException e) {
-        log.debug("could not close " + statement, e);
-      }
-    }
     if (connection != null) {
       try {
         JDBCExceptionReporter.logAndClearWarnings(connection);
@@ -343,15 +388,6 @@
     }
   }
 
-  void createConnection() throws SQLException {
-    connectionProvider = settings.getConnectionProvider();
-    connection = connectionProvider.getConnection();
-    if (!connection.getAutoCommit()) {
-      connection.commit();
-      connection.setAutoCommit(true);
-    }
-  }
-
   public Properties getProperties() {
     return configuration.getProperties();
   }

Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml	2009-01-23 07:10:21 UTC (rev 3705)
@@ -17,10 +17,6 @@
     <!-- # common settings                 # -->
     <!-- ################################### -->
 
-    <!-- Automatic schema creation (begin) -->
-    <property name="hibernate.hbm2ddl.auto">update</property>
-    <!-- Automatic schema creation (end) -->
-
     <!-- Simple memory-only cache -->
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
 
@@ -35,4 +31,3 @@
     <!-- Additional mappings defined per module go here -->
     <mapping resource="hibernate.extra.hbm.xml" />
     <mapping resource="hibernate.identity.hbm.xml" />
-    

Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml	2009-01-23 07:10:21 UTC (rev 3705)
@@ -9,3 +9,6 @@
     <property name="hibernate.connection.password"></property>
     <!-- JDBC connection properties (end) -->
 
+    <!-- Automatic schema creation (begin) -->
+    <property name="hibernate.hbm2ddl.auto">create</property>
+    <!-- Automatic schema creation (end) -->

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -21,10 +21,11 @@
  */
 package org.jbpm.context.exe;
 
+import org.hibernate.cfg.Configuration;
 import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
 import org.jbpm.context.def.ContextDefinition;
 import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.JbpmSchema;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -32,18 +33,20 @@
 
 public class CustomVariableLongIdDbTest extends AbstractDbTestCase {
 
+  private static final String CUSTOM_TABLE = "JBPM_TEST_CUSTOMLONGID";
+
   protected JbpmConfiguration getJbpmConfiguration() {
     if (jbpmConfiguration == null) {
       jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
-      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-      try {
-        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
-            .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-        persistenceServiceFactory.getConfiguration().addClass(CustomLongClass.class);
+      DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+
+      Configuration configuration = factory.getConfiguration();
+      configuration.addClass(CustomLongClass.class);
+
+      JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+      if (!jbpmSchema.tableExists(CUSTOM_TABLE)) {
+        jbpmSchema.createTable(CUSTOM_TABLE);
       }
-      finally {
-        jbpmContext.close();
-      }
     }
     return jbpmConfiguration;
   }
@@ -77,7 +80,8 @@
     }
     finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
-      if (customLongObject != null) session.delete(customLongObject);
+      if (customLongObject != null)
+        session.delete(customLongObject);
     }
   }
 }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -21,10 +21,11 @@
  */
 package org.jbpm.context.exe;
 
+import org.hibernate.cfg.Configuration;
 import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
 import org.jbpm.context.def.ContextDefinition;
 import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.JbpmSchema;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -32,18 +33,20 @@
 
 public class CustomVariableStringIdDbTest extends AbstractDbTestCase {
 
+  private static final String CUSTOM_TABLE = "JBPM_TEST_CUSTOMSTRINGID";
+
   protected JbpmConfiguration getJbpmConfiguration() {
     if (jbpmConfiguration == null) {
       jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
-      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-      try {
-        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
-            .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-        persistenceServiceFactory.getConfiguration().addClass(CustomStringClass.class);
+      DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+
+      Configuration configuration = factory.getConfiguration();
+      configuration.addClass(CustomStringClass.class);
+
+      JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+      if (!jbpmSchema.tableExists(CUSTOM_TABLE)) {
+        jbpmSchema.createTable(CUSTOM_TABLE);
       }
-      finally {
-        jbpmContext.close();
-      }
     }
     return jbpmConfiguration;
   }
@@ -77,7 +80,8 @@
     }
     finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
-      if (customStringObject != null) session.delete(customStringObject);
+      if (customStringObject != null)
+        session.delete(customStringObject);
     }
   }
 }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -25,13 +25,12 @@
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
-import java.util.TimerTask;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.hibernate.Criteria;
 import org.hibernate.criterion.Restrictions;
 import org.jbpm.context.exe.ContextInstance;
 import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.ActionHandler;
 import org.jbpm.graph.def.Event;
 import org.jbpm.graph.def.Node;
@@ -39,14 +38,12 @@
 import org.jbpm.graph.exe.ExecutionContext;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.job.Timer;
-import org.jbpm.job.executor.JobExecutorThread;
 import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.util.CollectionUtil;
 import org.jbpm.util.DateDbTestUtil;
 
 public class TimerDbTest extends AbstractDbTestCase {
 
-  private static Log log = LogFactory.getLog(Timer.class);
-
   static boolean isNoOpExecuted = false;
 
   protected void setUp() throws Exception {
@@ -182,9 +179,9 @@
     try {
       Node node = processDefinition.getNode("sometask");
 
-      List actions = node.getEvent(Event.EVENTTYPE_NODE_ENTER).getActions();
+      List<Action> actions = node.getEvent(Event.EVENTTYPE_NODE_ENTER).getActions();
       assertEquals(1, actions.size());
-      
+
       actions = node.getEvent(Event.EVENTTYPE_NODE_LEAVE).getActions();
       assertEquals(1, actions.size());
 
@@ -193,7 +190,6 @@
       jbpmContext.save(processInstance);
 
       newTransaction();
-
       assertEquals(1, getTimerCount());
     }
     finally {
@@ -251,7 +247,7 @@
       processInstance = saveAndReload(processInstance);
       assertEquals(1, getTimerCount());
       processInstance.signal();
-      
+
       newTransaction();
 
       assertEquals(1, getTimerCount());
@@ -285,13 +281,13 @@
 
       processInstance = saveAndReload(processInstance);
 
-      List timersByName = session.createCriteria(Timer.class)
-          .add(Restrictions.eq("name", "reminder"))
-          .list();
+      Criteria criteria = session.createCriteria(Timer.class).add(
+          Restrictions.eq("name", "reminder"));
+      List<Timer> timersByName = CollectionUtil.checkList(criteria.list(), Timer.class);
       assertNotNull(timersByName);
       assertEquals(1, timersByName.size());
 
-      Timer timer = (Timer) timersByName.get(0);
+      Timer timer = timersByName.get(0);
       assertEquals("geftem-eu-shuppe-oender-ze-konte", timer.getAction()
           .getActionDelegation()
           .getClassName());
@@ -328,7 +324,7 @@
       newTransaction();
 
       Timer timer = (Timer) jobSession.getFirstAcquirableJob(null);
-      
+
       assertNotNull(timer);
       Date date = timer.getDueDate();
       assertNotNull(date);
@@ -340,10 +336,11 @@
 
       newTransaction();
 
-      List timers = session.createQuery("from org.jbpm.job.Timer").list();
+      Criteria criteria = session.createCriteria(Timer.class);
+      List<Timer> timers = CollectionUtil.checkList(criteria.list(), Timer.class);
       assertEquals(1, timers.size());
-      timer = (Timer) timers.get(0);
 
+      timer = timers.get(0);
       assertEquals(origDueDate + 5000, timer.getDueDate().getTime());
 
       processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
@@ -374,7 +371,6 @@
     finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
-
   }
 
   public void testTimerUpdatingProcessVariables() throws Exception {
@@ -418,7 +414,7 @@
       assertEquals("value a", contextInstance.getVariable("a"));
       assertEquals("value b updated", contextInstance.getVariable("b"));
 
-      TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
+      TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
           .getTaskInstances()
           .iterator()
           .next();
@@ -431,7 +427,6 @@
   }
 
   public static class ConcurrentUpdateAction implements ActionHandler {
-
     private static final long serialVersionUID = 1L;
 
     public void execute(ExecutionContext executionContext) throws Exception {
@@ -440,7 +435,6 @@
   }
 
   public static class NoOp implements ActionHandler {
-
     private static final long serialVersionUID = 1L;
 
     public void execute(ExecutionContext executionContext) throws Exception {
@@ -449,7 +443,6 @@
   }
 
   public static class UpdateVariables implements ActionHandler {
-
     private static final long serialVersionUID = 1L;
 
     public void execute(ExecutionContext executionContext) throws Exception {

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -25,7 +25,11 @@
 import org.jbpm.graph.exe.ExecutionContext;
 
 public class AsyncAction implements ActionHandler {
+
+  private static final long serialVersionUID = 1L;
+
   public void execute(ExecutionContext executionContext) throws Exception {
-    JobExecutorCustomizationTest.jobEvents.add("execute action");
+    JobExecutorCustomizationTest.addJobEvent("execute action");
   }
+
 }
\ No newline at end of file

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -3,9 +3,11 @@
 import org.jbpm.job.executor.JobExecutor;
 
 public class CustomJobExecutor extends JobExecutor {
+
   private static final long serialVersionUID = 1L;
 
   protected Thread createThread(String threadName) {
-    return new CustomJobExecutorThread(threadName, this, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, historyMaxSize);
+    return new CustomJobExecutorThread(threadName, this);
   }
+
 }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -1,24 +1,24 @@
 package org.jbpm.seam;
 
-import org.jbpm.JbpmConfiguration;
 import org.jbpm.job.Job;
 import org.jbpm.job.executor.JobExecutor;
 import org.jbpm.job.executor.JobExecutorThread;
 
 public class CustomJobExecutorThread extends JobExecutorThread {
 
-  public CustomJobExecutorThread(String name, JobExecutor jobExecutor, JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime, int maxHistory) {
-    super(name, jobExecutor, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, maxHistory);
+  public CustomJobExecutorThread(String name, JobExecutor jobExecutor) {
+    super(name, jobExecutor);
   }
 
   protected void executeJob(Job job) {
     // intercept before
-    JobExecutorCustomizationTest.jobEvents.add("before");
+    JobExecutorCustomizationTest.addJobEvent("before");
     try {
       super.executeJob(job);
-    } finally {
+    }
+    finally {
       // intercept after
-      JobExecutorCustomizationTest.jobEvents.add("after");
+      JobExecutorCustomizationTest.addJobEvent("after");
     }
   }
 }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -1,17 +1,17 @@
 package org.jbpm.seam;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.jbpm.db.AbstractDbTestCase;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.job.executor.JobExecutor;
 
-
 public class JobExecutorCustomizationTest extends AbstractDbTestCase {
-  
-  public static List jobEvents = new ArrayList();
-  
+
+  private static List<String> jobEvents = new ArrayList<String>();
+
   protected String getJbpmTestConfig() {
     return "org/jbpm/seam/custom.job.executor.jbpm.cfg.xml";
   }
@@ -25,45 +25,33 @@
   public void testCustomJobExecutor() {
     JobExecutor jobExecutor = getJbpmConfiguration().getJobExecutor();
     assertEquals(CustomJobExecutor.class, jobExecutor.getClass());
-    
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition name='customjobexecution' initial='start'>" +
-      "  <node name='start'>" +
-      "    <transition to='end'>" +
-      "      <action async='true' class='"+AsyncAction.class.getName()+"' />" +
-      "    </transition>" +
-      "  </node>" +
-      "  <state name='end' />" +
-      "</process-definition>"
-    );
+
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='customjobexecution' initial='start'>"
+        + "  <node name='start'>"
+        + "    <transition to='end'>"
+        + "      <action async='true' class='"
+        + AsyncAction.class.getName()
+        + "' />"
+        + "    </transition>"
+        + "  </node>"
+        + "  <state name='end' />"
+        + "</process-definition>");
     jbpmContext.deployProcessDefinition(processDefinition);
-    long processDefinitionId = processDefinition.getId();
+    newTransaction();
     try {
-      
-      newTransaction();
-      
       jbpmContext.newProcessInstanceForUpdate("customjobexecution");
-      
-      newTransaction();
-      
-      jobExecutor.start();
-      try {
-        waitForJobs(20000);
-      } finally {
-        jobExecutor.stop();
-      }
+      processJobs(20 * 1000);
 
-    } finally {
-      newTransaction();
-      
-      graphSession.deleteProcessDefinition(processDefinitionId);
+      List<String> expectedJobEvents = Arrays.asList("before", "execute action", "after");
+      assertEquals(expectedJobEvents, jobEvents);
     }
-    
-    List expectedJobEvents = new ArrayList();
-    expectedJobEvents.add("before");
-    expectedJobEvents.add("execute action");
-    expectedJobEvents.add("after");
-    
-    assertEquals(expectedJobEvents, jobEvents);
+    finally {
+      graphSession.deleteProcessDefinition(processDefinition.getId());
+    }
   }
+
+  public static void addJobEvent(String event) {
+    jobEvents.add(event);
+  }
+
 }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java	2009-01-23 07:10:21 UTC (rev 3705)
@@ -35,83 +35,78 @@
 public class TaskTimerExecutionDbTest extends AbstractDbTestCase {
 
   static int counter = 0;
-  
+
   public static class PlusPlus implements ActionHandler {
     private static final long serialVersionUID = 1L;
+
     public void execute(ExecutionContext executionContext) throws Exception {
       counter++;
     }
   }
-  
+
   protected void setUp() throws Exception {
     super.setUp();
     counter = 0;
   }
 
   public void testTimerCreation() {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition>" +
-      "  <start-state>" +
-      "    <transition to='a' />" +
-      "  </start-state>" +
-      "  <task-node name='a'>" +
-      "    <task name='clean ceiling'>" +
-      "      <timer name='ceiling-timer' duedate='0 seconds'>" +
-      "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
-      "      </timer>" +
-      "    </task>" +
-      "  </task-node>" +
-      "</process-definition>"
-    );
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+        + "  <start-state>"
+        + "    <transition to='a' />"
+        + "  </start-state>"
+        + "  <task-node name='a'>"
+        + "    <task name='clean ceiling'>"
+        + "      <timer name='ceiling-timer' duedate='0 seconds'>"
+        + "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+        + "      </timer>"
+        + "    </task>"
+        + "  </task-node>"
+        + "</process-definition>");
 
     processDefinition = saveAndReload(processDefinition);
-    try
-    {
+    try {
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstance.signal();
-      
+
       processInstance = saveAndReload(processInstance);
 
-      Timer timer = (Timer) getJob();
+      Timer timer = getTimer();
       assertEquals("ceiling-timer", timer.getName());
     }
-    finally
-    {
+    finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
   }
 
   public void testTimerDeletion() {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition>" +
-      "  <start-state>" +
-      "    <transition to='a' />" +
-      "  </start-state>" +
-      "  <task-node name='a'>" +
-      "    <task name='clean ceiling'>" +
-      "      <timer name='ceiling-timer' duedate='0 seconds'>" +
-      "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
-      "      </timer>" +
-      "    </task>" +
-      "    <transition to='b' />" +
-      "  </task-node>" +
-      "  <state name='b' />" +
-      "</process-definition>"
-    );
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+        + "  <start-state>"
+        + "    <transition to='a' />"
+        + "  </start-state>"
+        + "  <task-node name='a'>"
+        + "    <task name='clean ceiling'>"
+        + "      <timer name='ceiling-timer' duedate='0 seconds'>"
+        + "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+        + "      </timer>"
+        + "    </task>"
+        + "    <transition to='b' />"
+        + "  </task-node>"
+        + "  <state name='b' />"
+        + "</process-definition>");
 
     processDefinition = saveAndReload(processDefinition);
-    try
-    {
+    try {
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstance.signal();
       jbpmContext.save(processInstance);
 
       newTransaction();
 
-      List taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken().getId());
+      List<TaskInstance> taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken()
+          .getId());
       assertEquals(1, taskInstances.size());
 
-      TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
+      TaskInstance taskInstance = taskInstances.get(0);
       taskInstance.end();
       jbpmContext.save(taskInstance);
 
@@ -119,98 +114,86 @@
 
       assertEquals(0, getTimerCount());
     }
-    finally
-    {
+    finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
   }
 
   public void testTimerExecution() {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition>" +
-      "  <start-state>" +
-      "    <transition to='a' />" +
-      "  </start-state>" +
-      "  <task-node name='a'>" +
-      "    <task name='clean ceiling'>" +
-      "      <timer name='ceiling-timer' duedate='0 seconds'>" +
-      "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
-      "      </timer>" +
-      "    </task>" +
-      "  </task-node>" +
-      "</process-definition>"
-    );
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+        + "  <start-state>"
+        + "    <transition to='a' />"
+        + "  </start-state>"
+        + "  <task-node name='a'>"
+        + "    <task name='clean ceiling'>"
+        + "      <timer name='ceiling-timer' duedate='0 seconds'>"
+        + "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+        + "      </timer>"
+        + "    </task>"
+        + "  </task-node>"
+        + "</process-definition>");
 
     processDefinition = saveAndReload(processDefinition);
-    try
-    {
+    try {
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstance.signal();
       jbpmContext.save(processInstance);
-      
+
       processJobs(5000);
 
       assertEquals(1, counter);
     }
-    finally
-    {
+    finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
-    
+
   }
 
   public void testTaskNodeTimerExecution() {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition>" +
-      "  <start-state>" +
-      "    <transition to='a' />" +
-      "  </start-state>" +
-      "  <task-node name='a'>" +
-      "    <timer name='ceiling-timer' duedate='0 seconds'>" +
-      "      <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
-      "    </timer>" +
-      "    <task name='clean ceiling' />" +
-      "  </task-node>" +
-      "</process-definition>"
-    );
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+        + "  <start-state>"
+        + "    <transition to='a' />"
+        + "  </start-state>"
+        + "  <task-node name='a'>"
+        + "    <timer name='ceiling-timer' duedate='0 seconds'>"
+        + "      <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+        + "    </timer>"
+        + "    <task name='clean ceiling' />"
+        + "  </task-node>"
+        + "</process-definition>");
 
     processDefinition = saveAndReload(processDefinition);
-    try
-    {
+    try {
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstance.signal();
       jbpmContext.save(processInstance);
-      
+
       newTransaction();
 
       processJobs(5000);
       assertEquals(1, counter);
     }
-    finally
-    {
+    finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
   }
 
   public void testTimerExecutionRepeat() throws Exception {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition>" +
-      "  <start-state>" +
-      "    <transition to='a' />" +
-      "  </start-state>" +
-      "  <task-node name='a'>" +
-      "    <task name='clean ceiling'>" +
-      "      <timer name='ceiling-timer' duedate='0 seconds' repeat='60 second'>" +
-      "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
-      "      </timer>" +
-      "    </task>" +
-      "  </task-node>" +
-      "</process-definition>"
-    );
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+        + "  <start-state>"
+        + "    <transition to='a' />"
+        + "  </start-state>"
+        + "  <task-node name='a'>"
+        + "    <task name='clean ceiling'>"
+        + "      <timer name='ceiling-timer' duedate='0 seconds' repeat='60 second'>"
+        + "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+        + "      </timer>"
+        + "    </task>"
+        + "  </task-node>"
+        + "</process-definition>");
 
     processDefinition = saveAndReload(processDefinition);
-    try
-    {
+    try {
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstance.signal();
       jbpmContext.save(processInstance);
@@ -218,7 +201,7 @@
       newTransaction();
 
       // fetch the original duedate
-      Timer timer = (Timer) getJob();
+      Timer timer = getTimer();
       assertNotNull(timer);
       long originalDueDate = timer.getDueDate().getTime();
 
@@ -226,37 +209,33 @@
       assertEquals(1, counter);
 
       // check if the timer has be re-scheduled because of the repeat.
-      timer = (Timer) getJob();
+      timer = getTimer();
       assertNotNull(timer);
       // check that the timer was rescheduled with a duedate 60 seconds after the original duedate.
-      assertEquals(originalDueDate+60000, timer.getDueDate().getTime());
+      assertEquals(originalDueDate + 60000, timer.getDueDate().getTime());
     }
-    finally
-    {
+    finally {
       newTransaction();
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
   }
-  
+
   public void testTimerELCreation() {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition>" +
-      "  <start-state>" +
-      "    <transition to='a' />" +
-      "  </start-state>" +
-      "  <task-node name='a'>" +
-      "    <task name='clean ceiling'>" +
-      "      <timer name='ceiling-timer' duedate='#{baseDate} + 2 days'>" +
-      "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
-      "      </timer>" +
-      "    </task>" +
-      "  </task-node>" +
-      "</process-definition>"
-    );
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+        + "  <start-state>"
+        + "    <transition to='a' />"
+        + "  </start-state>"
+        + "  <task-node name='a'>"
+        + "    <task name='clean ceiling'>"
+        + "      <timer name='ceiling-timer' duedate='#{baseDate} + 2 days'>"
+        + "        <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+        + "      </timer>"
+        + "    </task>"
+        + "  </task-node>"
+        + "</process-definition>");
 
     processDefinition = saveAndReload(processDefinition);
-    try
-    {
+    try {
       Calendar baseDate = Calendar.getInstance();
       Date dateTestDate = new Date();
       baseDate.setTime(dateTestDate);
@@ -273,15 +252,18 @@
       baseDateTest.clear(Calendar.MILLISECOND);
       baseDateTest.add(Calendar.DAY_OF_YEAR, 2);
 
-      Timer timer = (Timer) getJob();
+      Timer timer = getTimer();
       assertEquals("ceiling-timer", timer.getName());
-      
+
       assertNotNull(timer.getDueDate());
-      assertEquals(baseDateTest.getTime(), timer.getDueDate());      
+      assertEquals(baseDateTest.getTime(), timer.getDueDate());
     }
-    finally
-    {
+    finally {
       jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
     }
-  }  
+  }
+
+  private Timer getTimer() {
+    return (Timer) session.createCriteria(Timer.class).setMaxResults(1).uniqueResult();
+  }
 }

Modified: jbpm3/trunk/modules/core/src/test/resources/log4j.xml
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/log4j.xml	2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/resources/log4j.xml	2009-01-23 07:10:21 UTC (rev 3705)
@@ -35,17 +35,28 @@
   <category name="org.hibernate">
     <priority value="INFO" />
   </category>
+
+  <!-- hide optimistic locking failures
+  <category name="org.hibernate.event.def.AbstractFlushingEventListener">
+    <priority value="FATAL" />
+  </category>
+  -->
+
+  <!-- hide proxy narrowing warns -->
+  <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
+    <priority value="ERROR" />
+  </category>
+
+  <!-- show SQL DML statements as they are executed -->
   <category name="org.hibernate.SQL">
     <priority value="DEBUG" />
   </category>
-  <!--
+
+  <!-- show JDBC parameters
   <category name="org.hibernate.type">
     <priority value="TRACE" />
   </category>
   -->
-  <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
-    <priority value="ERROR" />
-  </category>
 
   <!-- ======================= -->
   <!-- Setup the Root category -->




More information about the jbpm-commits mailing list