[jbpm-commits] JBoss JBPM SVN: r2182 - 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
Thu Sep 11 18:59:00 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-09-11 18:59:00 -0400 (Thu, 11 Sep 2008)
New Revision: 2182

Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.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/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
   jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/jcr/JcrDbTest.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
Log:
Remove drop schema from tearDown

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -21,40 +21,13 @@
  */
 package org.jbpm;
 
-import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class AbstractJbpmTestCase extends TestCase {
-
-  private static Log log = LogFactory.getLog(AbstractJbpmTestCase.class);
-
-  public void setUp() throws Exception {
+public abstract class AbstractJbpmTestCase extends TestCase
+{
+  public void setUp() throws Exception
+  {
     JbpmConfigurationTestHelper.reset();
     JbpmContextTestHelper.reset();
   }
-  
-  public void tearDown() throws Exception {
-    JbpmConfigurationTestHelper.reset();
-    JbpmContextTestHelper.reset();
-  }
-  
-  protected void runTest() throws Throwable {
-    try {
-      super.runTest();
-    } catch (AssertionFailedError e) {
-      log.error("");
-      log.error("ASSERTION FAILURE: "+e.getMessage());
-      log.error("");
-      throw e;
-    } catch (Throwable t) {
-      log.error("");
-      log.error("EXCEPTION: "+t.getMessage());
-      log.error("");
-      t.printStackTrace();
-      throw t;
-    }
-  }
 }

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -46,51 +46,62 @@
 /**
  * configuration of one jBPM instance.
  * 
- * <p>During process execution, jBPM might need to use some services.  
- * A JbpmConfiguration contains the knowledge on how to create those services.
+ * <p>
+ * During process execution, jBPM might need to use some services. A JbpmConfiguration contains the knowledge on how to create those services.
  * </p>
  * 
- * <p>A JbpmConfiguration is a thread safe object and serves as a factory for 
- * {@link org.jbpm.JbpmContext}s, which means one JbpmConfiguration 
- * can be used to create {@link org.jbpm.JbpmContext}s for all threads. 
- * The single JbpmConfiguration can be maintained in a static member or 
- * in the JNDI tree if that is available.
+ * <p>
+ * A JbpmConfiguration is a thread safe object and serves as a factory for {@link org.jbpm.JbpmContext}s, which means one JbpmConfiguration can be used to create
+ * {@link org.jbpm.JbpmContext}s for all threads. The single JbpmConfiguration can be maintained in a static member or in the JNDI tree if that is available.
  * </p>
  * 
- * <p>A JbpmConfiguration can be obtained in following ways:
+ * <p>
+ * A JbpmConfiguration can be obtained in following ways:
  * <ul>
- *   <li>from a resource (by default <code>jbpm.cfg.xml</code> is used):
- * <pre> JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ * <li>from a resource (by default <code>jbpm.cfg.xml</code> is used):
+ * 
+ * <pre>
+ * JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  * </pre>
+ * 
  * or
- * <pre> String myXmlResource = "...";
- * JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(myXmlResource);</pre> 
- *   </li>
- *   <li>from an XML string:
- * <pre> JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- *   "<jbpm-configuration>" +
+ * 
+ * <pre>
+ * String myXmlResource = &quot;...&quot;;
+ * JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(myXmlResource);
+ * </pre>
+ * 
+ * </li>
+ * <li>from an XML string:
+ * 
+ * <pre>
+ * JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ *   &quot;&lt;jbpm-configuration&gt;&quot; +
  *   ...
- *   "</jbpm-configuration>"
+ *   &quot;&lt;/jbpm-configuration&gt;&quot;
  * );
  * </pre>
- *   </li>
- *   <li>By specifying a custom implementation of an object factory.  This can be 
- *   used to specify a JbpmConfiguration in other bean-style notations such as 
- *   used by JBoss Microcontainer or Spring.
- * <pre> ObjectFactory of = new <i>MyCustomObjectFactory</i>();
+ * 
+ * </li>
+ * <li>By specifying a custom implementation of an object factory. This can be used to specify a JbpmConfiguration in other bean-style notations such as used by JBoss
+ * Microcontainer or Spring.
+ * 
+ * <pre>
+ * ObjectFactory of = new &lt;i&gt;MyCustomObjectFactory&lt;/i&gt;();
  * JbpmConfiguration.Configs.setDefaultObjectFactory(of);
  * JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  * </pre>
- *   </li>
+ * 
+ * </li>
  * </ul>
  * </p>
  * 
- * <p>JbpmConfigurations can be configured using a spring-like XML notation
- * (in relax ng compact notation):
+ * <p>
+ * JbpmConfigurations can be configured using a spring-like XML notation (in relax ng compact notation):
  * </p>
  * 
  * <pre>
- * datatypes xs = "http://www.w3.org/2001/XMLSchema-datatypes"
+ * datatypes xs = &quot;http://www.w3.org/2001/XMLSchema-datatypes&quot;
  * 
  * start = element beans { element object* }
  * 
@@ -148,7 +159,7 @@
  *   ( attribute ref-name {xsd:string} ) |
  *   ( attribute name {xsd:string}?,
  *     attribute class {xsd:string}?,
- *     attribute singleton { "true" | "false" }?,
+ *     attribute singleton { &quot;true&quot; | &quot;false&quot; }?,
  *     constructor*,
  *     field*,
  *     property*
@@ -211,36 +222,41 @@
  * float  = element float {xsd:string}
  * double = element string {xsd:double}
  * char   = element char {xsd:character}
- * bool   = element bool { "true" | "false" }
+ * bool   = element bool { &quot;true&quot; | &quot;false&quot; }
  * true   = element true {}
  * false  = element false {}
  * null   = element null {}
  * </pre>
+ * 
  * </p>
  * 
  * <p>
  * Other configuration properties
  * <table>
- *   <tr>
- *     <td>jbpm.files.dir</td><td></td>
- *   </tr>
- *   <tr>
- *     <td>jbpm.types</td><td></td>
- *   </tr>
+ * <tr>
+ * <td>jbpm.files.dir</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>jbpm.types</td>
+ * <td></td>
+ * </tr>
  * </table>
  * </p>
  */
-public class JbpmConfiguration implements Serializable {
-  
+public class JbpmConfiguration implements Serializable
+{
+
   private static final long serialVersionUID = 1L;
 
   static ObjectFactory defaultObjectFactory = null;
   static Map instances = new HashMap();
-  
+
   /**
    * resets static members for test isolation.
    */
-  static void reset() {
+  static void reset()
+  {
     defaultObjectFactory = null;
     instances = new HashMap();
   }
@@ -248,50 +264,65 @@
   ObjectFactory objectFactory = null;
   static ThreadLocal jbpmConfigurationsStacks = new ThreadLocal();
   ThreadLocal jbpmContextStacks = new ThreadLocal();
-  JobExecutor jobExecutor = null; 
+  JobExecutor jobExecutor = null;
 
-  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) {
-    
+
+  public static JbpmConfiguration getInstance(String resource)
+  {
+
     JbpmConfiguration instance = null;
-    
-    synchronized(instances) {
-      if (resource==null) {
+
+    synchronized (instances)
+    {
+      if (resource == null)
+      {
         resource = "jbpm.cfg.xml";
       }
 
-      instance = (JbpmConfiguration) instances.get(resource);
-      if (instance==null) {
+      instance = (JbpmConfiguration)instances.get(resource);
+      if (instance == null)
+      {
 
-        if (defaultObjectFactory!=null) {
-          log.debug("creating jbpm configuration from given default object factory '"+defaultObjectFactory+"'");
+        if (defaultObjectFactory != null)
+        {
+          log.debug("creating jbpm configuration from given default object factory '" + defaultObjectFactory + "'");
           instance = new JbpmConfiguration(defaultObjectFactory);
 
-        } else {
-          
-          try {
-            log.info("using jbpm configuration resource '"+resource+"'");
+        }
+        else
+        {
+
+          try
+          {
+            log.info("using jbpm configuration resource '" + resource + "'");
             InputStream jbpmCfgXmlStream = ClassLoaderUtil.getStream(resource);
 
             // if a custom resource is to be used, but is 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)) {
-              log.warn("jbpm configuration resource '"+resource+"' is not available");
+            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);
@@ -301,26 +332,29 @@
     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);
     }
@@ -331,26 +365,31 @@
   /**
    * 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) {
+    // now we make the bean jbpm.configuration always availble
+    if (objectFactory instanceof ObjectFactoryImpl)
+    {
       ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl)objectFactory;
       ObjectInfo jbpmConfigurationInfo = new ValueInfo("jbpmConfiguration", jbpmConfiguration);
       objectFactoryImpl.addObjectInfo(jbpmConfigurationInfo);
-      
-      if (mustStaleObjectExceptionsBeHidden(objectFactory)) {
+
+      if (mustStaleObjectExceptionsBeHidden(objectFactory))
+      {
         StaleObjectLogConfigurer.hideStaleObjectExceptions();
       }
     }
@@ -358,252 +397,340 @@
     return jbpmConfiguration;
   }
 
-  private static boolean mustStaleObjectExceptionsBeHidden(ObjectFactory objectFactory) {
-    if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions")) {
+  private static boolean mustStaleObjectExceptionsBeHidden(ObjectFactory objectFactory)
+  {
+    if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions"))
+    {
       return true;
     }
-    Object o = (Boolean) objectFactory.createObject("jbpm.hide.stale.object.exceptions");
-    if ( (o instanceof Boolean)
-         && (((Boolean)o).booleanValue()==false)
-       ) {
+    Object o = (Boolean)objectFactory.createObject("jbpm.hide.stale.object.exceptions");
+    if ((o instanceof Boolean) && (((Boolean)o).booleanValue() == false))
+    {
       return false;
     }
     return true;
   }
-  
-  public static JbpmConfiguration parseInputStream(InputStream inputStream) {
-    ObjectFactory objectFactory = parseObjectFactory(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) {
+    log.debug("creating jbpm configuration from resource '" + resource + "'");
+    if (resource != null)
+    {
       inputStream = ClassLoaderUtil.getStream(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) {
-    JbpmContext jbpmContext = (JbpmContext) objectFactory.createObject(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;
   }
-  
+
   /**
    * gives the jbpm domain model access to configuration information via the current JbpmContext.
    */
-  public abstract static class Configs {
-    public static ObjectFactory getObjectFactory() {
+  public abstract static class Configs
+  {
+    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) {
-      return (String) getObject(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 createSchema() {
+  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 createSchema()
+  {
     createSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
-  
-  public void createSchema(String jbpmContextName) {
+
+  public void createSchema(String jbpmContextName)
+  {
     JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try {
+    try
+    {
       Services services = jbpmContext.getServices();
-      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory)services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
       persistenceServiceFactory.createSchema();
-    } finally {
+    }
+    finally
+    {
       jbpmContext.close();
     }
   }
-  
-  public void dropSchema() {
+
+  public void dropSchema()
+  {
     dropSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
-  
-  public void dropSchema(String jbpmContextName) {
+
+  public void dropSchema(String jbpmContextName)
+  {
+    log.warn("Dropping schema: " + jbpmContextName);
     JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try {
+    try
+    {
       Services services = jbpmContext.getServices();
-      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+      DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory)services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
       persistenceServiceFactory.dropSchema();
-    } finally {
+    }
+    finally
+    {
       jbpmContext.close();
     }
   }
 
-  public void close() {
+  public void close()
+  {
     close(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
   }
 
-  public void close(String jbpmContextName) {
+  public void close(String jbpmContextName)
+  {
     JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
-    try {
-      
-      synchronized (instances) {
+    try
+    {
+
+      synchronized (instances)
+      {
         Iterator iter = instances.keySet().iterator();
-        while(iter.hasNext()) {
-          String resource = (String) iter.next();
-          if (this==instances.get(resource)) {
+        while (iter.hasNext())
+        {
+          String resource = (String)iter.next();
+          if (this == instances.get(resource))
+          {
             instances.remove(resource);
             break;
           }
         }
       }
-      
-      if (jobExecutor!=null) {
+
+      if (jobExecutor != null)
+      {
         jobExecutor.stop();
       }
-      
+
       Map serviceFactories = jbpmContext.getServices().getServiceFactories();
-      if (serviceFactories!=null) {
+      if (serviceFactories != null)
+      {
         Iterator iter = serviceFactories.values().iterator();
-        while (iter.hasNext()) {
-          ServiceFactory serviceFactory = (ServiceFactory) iter.next();
+        while (iter.hasNext())
+        {
+          ServiceFactory serviceFactory = (ServiceFactory)iter.next();
           serviceFactory.close();
         }
       }
-    } finally {
+    }
+    finally
+    {
       jbpmContext.close();
     }
   }
-  
-  static JbpmConfiguration getCurrentJbpmConfiguration() {
+
+  static JbpmConfiguration getCurrentJbpmConfiguration()
+  {
     JbpmConfiguration currentJbpmConfiguration = null;
     Stack stack = getJbpmConfigurationStack();
-    if (! stack.isEmpty()) {
-      currentJbpmConfiguration = (JbpmConfiguration) stack.peek();
+    if (!stack.isEmpty())
+    {
+      currentJbpmConfiguration = (JbpmConfiguration)stack.peek();
     }
     return currentJbpmConfiguration;
   }
 
-  static synchronized Stack getJbpmConfigurationStack() {
-    Stack stack = (Stack) jbpmConfigurationsStacks.get();
-    if (stack==null) {
+  static synchronized Stack getJbpmConfigurationStack()
+  {
+    Stack stack = (Stack)jbpmConfigurationsStacks.get();
+    if (stack == null)
+    {
       stack = new Stack();
       jbpmConfigurationsStacks.set(stack);
     }
     return stack;
   }
-  
-  synchronized void pushJbpmConfiguration() {
+
+  synchronized void pushJbpmConfiguration()
+  {
     getJbpmConfigurationStack().push(this);
   }
 
-  synchronized void popJbpmConfiguration() {
+  synchronized void popJbpmConfiguration()
+  {
     getJbpmConfigurationStack().remove(this);
   }
 
-
-  public JbpmContext getCurrentJbpmContext() {
+  public JbpmContext getCurrentJbpmContext()
+  {
     JbpmContext currentJbpmContext = null;
     Stack stack = getJbpmContextStack();
-    if (! stack.isEmpty()) {
-      currentJbpmContext = (JbpmContext) stack.peek();
+    if (!stack.isEmpty())
+    {
+      currentJbpmContext = (JbpmContext)stack.peek();
     }
     return currentJbpmContext;
   }
 
-  
-  Stack getJbpmContextStack() {
-    Stack stack = (Stack) jbpmContextStacks.get();
-    if (stack==null) {
+  Stack getJbpmContextStack()
+  {
+    Stack stack = (Stack)jbpmContextStacks.get();
+    if (stack == null)
+    {
       stack = new Stack();
       jbpmContextStacks.set(stack);
     }
     return stack;
   }
 
-  void pushJbpmContext(JbpmContext jbpmContext) {
+  void pushJbpmContext(JbpmContext jbpmContext)
+  {
     getJbpmContextStack().push(jbpmContext);
   }
 
-  void popJbpmContext(JbpmContext jbpmContext) {
+  void popJbpmContext(JbpmContext jbpmContext)
+  {
     Stack stack = getJbpmContextStack();
-    if (stack.isEmpty()) {
+    if (stack.isEmpty())
+    {
       throw new JbpmException("closed JbpmContext more then once... check your try-finally's around JbpmContexts blocks");
     }
-    JbpmContext popped = (JbpmContext) stack.pop();
-    if (jbpmContext!=popped) {
+    JbpmContext popped = (JbpmContext)stack.pop();
+    if (jbpmContext != popped)
+    {
       throw new JbpmException("closed JbpmContext in different order then they were created... 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 {
-        jobExecutor = (JobExecutor) this.objectFactory.createObject("jbpm.job.executor"); 
-      } catch (ClassCastException e) {
-        throw new JbpmException("jbpm configuration object under key 'jbpm.job.executor' is not a "+JobExecutor.class.getName(), e);
+  public synchronized JobExecutor getJobExecutor()
+  {
+    if (jobExecutor == null)
+    {
+      try
+      {
+        jobExecutor = (JobExecutor)this.objectFactory.createObject("jbpm.job.executor");
       }
+      catch (ClassCastException e)
+      {
+        throw new JbpmException("jbpm configuration object under key 'jbpm.job.executor' is not a " + JobExecutor.class.getName(), e);
+      }
     }
     return jobExecutor;
   }

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	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -38,240 +38,282 @@
 import org.jbpm.logging.log.ProcessLog;
 import org.jbpm.taskmgmt.exe.TaskInstance;
 
-public abstract class AbstractDbTestCase extends AbstractJbpmTestCase {
+public abstract class AbstractDbTestCase extends AbstractJbpmTestCase
+{
 
-	protected static JbpmConfiguration jbpmConfiguration = getDbTestJbpmConfiguration();
+  private JbpmConfiguration jbpmConfiguration;
 
-	protected JbpmContext jbpmContext = null;
-	protected SchemaExport schemaExport = null;
+  protected JbpmContext jbpmContext = null;
+  protected SchemaExport schemaExport = null;
 
-	protected Session session = null;
-	protected GraphSession graphSession = null;
-	protected TaskMgmtSession taskMgmtSession = null;
-	protected ContextSession contextSession = null;
-	protected JobSession jobSession = null;
-	protected LoggingSession loggingSession = null;
+  protected Session session = null;
+  protected GraphSession graphSession = null;
+  protected TaskMgmtSession taskMgmtSession = null;
+  protected ContextSession contextSession = null;
+  protected JobSession jobSession = null;
+  protected LoggingSession loggingSession = null;
 
-	protected JobExecutor jobExecutor;
+  protected JobExecutor jobExecutor;
 
-	public static JbpmConfiguration getDbTestJbpmConfiguration() {
-		return JbpmConfiguration.getInstance("org/jbpm/db/jbpm.db.test.cfg.xml");
-	}
+  public void setUp() throws Exception
+  {
+    createSchema();
+    createJbpmContext();
+    initializeMembers();
+    log.debug("### starting " + getClass().getName() + "." + getName() + " ####################################################");
+  }
 
-	public void setUp() throws Exception {
-		createSchema();
-		createJbpmContext();
-		initializeMembers();
+  public void tearDown() throws Exception
+  {
+    log.debug("### " + getClass().getName() + "." + getName() + " done ####################################################");
+    resetMembers();
+    closeJbpmContext();
+    super.tearDown();
+  }
 
-		log.debug("### starting " + getClass().getName() + "."
-				+ getName() + " ####################################################");
-	}
+  public void beginSessionTransaction()
+  {
+    createJbpmContext();
+    initializeMembers();
+  }
 
-	public void tearDown() throws Exception {
-		log.debug("### " + getClass().getName() + "." + getName()
-				+ " done ####################################################");
-		resetMembers();
-		closeJbpmContext();
-		dropSchema();
-		super.tearDown();
-	}
+  public void commitAndCloseSession()
+  {
+    closeJbpmContext();
+    resetMembers();
+  }
 
-	public void beginSessionTransaction() {
-		createJbpmContext();
-		initializeMembers();
-	}
+  protected void newTransaction()
+  {
+    try
+    {
+      commitAndCloseSession();
+      beginSessionTransaction();
+    }
+    catch (Throwable t)
+    {
+      throw new RuntimeException("couldn't commit and start new transaction", t);
+    }
+  }
 
-	public void commitAndCloseSession() {
-		closeJbpmContext();
-		resetMembers();
-	}
+  public ProcessInstance saveAndReload(ProcessInstance pi)
+  {
+    jbpmContext.save(pi);
+    newTransaction();
+    return graphSession.loadProcessInstance(pi.getId());
+  }
 
-	protected void newTransaction() {
-		try {
-			commitAndCloseSession();
-			beginSessionTransaction();
-		}
-		catch(Throwable t) {
-			throw new RuntimeException("couldn't commit and start new transaction", t);
-		}
-	}
+  public TaskInstance saveAndReload(TaskInstance taskInstance)
+  {
+    jbpmContext.save(taskInstance);
+    newTransaction();
+    return (TaskInstance)session.load(TaskInstance.class, new Long(taskInstance.getId()));
+  }
 
-	public ProcessInstance saveAndReload(ProcessInstance pi) {
-		jbpmContext.save(pi);
-		newTransaction();
-		return graphSession.loadProcessInstance(pi.getId());
-	}
+  public ProcessDefinition saveAndReload(ProcessDefinition pd)
+  {
+    graphSession.saveProcessDefinition(pd);
+    newTransaction();
+    return graphSession.loadProcessDefinition(pd.getId());
+  }
 
-	public TaskInstance saveAndReload(TaskInstance taskInstance) {
-		jbpmContext.save(taskInstance);
-		newTransaction();
-		return (TaskInstance) session.load(TaskInstance.class, new Long(
-				taskInstance.getId()));
-	}
+  public ProcessLog saveAndReload(ProcessLog processLog)
+  {
+    loggingSession.saveProcessLog(processLog);
+    newTransaction();
+    return loggingSession.loadProcessLog(processLog.getId());
+  }
 
-	public ProcessDefinition saveAndReload(ProcessDefinition pd) {
-		graphSession.saveProcessDefinition(pd);
-		newTransaction();
-		return graphSession.loadProcessDefinition(pd.getId());
-	}
+  protected void createSchema()
+  {
+    getJbpmConfiguration().createSchema();
+  }
 
-	public ProcessLog saveAndReload(ProcessLog processLog) {
-		loggingSession.saveProcessLog(processLog);
-		newTransaction();
-		return loggingSession.loadProcessLog(processLog.getId());
-	}
+  protected void cleanSchema()
+  {
+    getJbpmConfiguration().cleanSchema();
+  }
 
-	protected void createSchema() {
-		getJbpmConfiguration().createSchema();
-	}
+  protected void dropSchema()
+  {
+    getJbpmConfiguration().dropSchema();
+  }
 
-	protected JbpmConfiguration getJbpmConfiguration() {
-		return jbpmConfiguration;
-	}
+  protected JbpmConfiguration getJbpmConfiguration()
+  {
+    if (jbpmConfiguration == null)
+    {
+      jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/db/jbpm.db.test.cfg.xml");
+    }
+    return jbpmConfiguration;
+  }
 
-	protected void dropSchema() {
-		getJbpmConfiguration().dropSchema();
-	}
+  protected void createJbpmContext()
+  {
+    jbpmContext = getJbpmConfiguration().createJbpmContext();
+  }
 
-	protected void createJbpmContext() {
-		jbpmContext = getJbpmConfiguration().createJbpmContext();
-	}
+  protected void closeJbpmContext()
+  {
+    jbpmContext.close();
+  }
 
-	protected void closeJbpmContext() {
-		jbpmContext.close();
-	}
+  protected void startJobExecutor()
+  {
+    jobExecutor = getJbpmConfiguration().getJobExecutor();
+    jobExecutor.start();
+  }
 
-	protected void startJobExecutor() {
-		jobExecutor = getJbpmConfiguration().getJobExecutor();
-		jobExecutor.start();
-	}
+  private void processAllJobs(final long maxWait, int maxJobs)
+  {
+    boolean jobsAvailable = true;
 
-	private void processAllJobs(final long maxWait, int maxJobs) {
-		boolean jobsAvailable = true;
+    // install a timer that will interrupt if it takes too long
+    // if that happens, it will lead to an interrupted exception and the test
+    // will fail
+    TimerTask interruptTask = new TimerTask()
+    {
+      Thread testThread = Thread.currentThread();
 
-		// install a timer that will interrupt if it takes too long
-		// if that happens, it will lead to an interrupted exception and the test
-		// will fail
-		TimerTask interruptTask = new TimerTask() {
-			Thread testThread = Thread.currentThread();
+      public void run()
+      {
+        log.debug("test " + getName() + " took too long. going to interrupt...");
+        testThread.interrupt();
+      }
+    };
+    Timer timer = new Timer();
+    timer.schedule(interruptTask, maxWait);
 
-			public void run() {
-				log
-						.debug("test " + getName()
-								+ " took too long. going to interrupt...");
-				testThread.interrupt();
-			}
-		};
-		Timer timer = new Timer();
-		timer.schedule(interruptTask, maxWait);
+    try
+    {
+      while (jobsAvailable)
+      {
+        log.debug("going to sleep for 200 millis, waiting for the job executor to process more jobs");
+        Thread.sleep(200);
+        jobsAvailable = (getNbrOfJobsAvailable() > maxJobs);
+      }
+      jobExecutor.stopAndJoin();
 
-		try {
-			while(jobsAvailable) {
-				log
-						.debug("going to sleep for 200 millis, waiting for the job executor to process more jobs");
-				Thread.sleep(200);
-				jobsAvailable = (getNbrOfJobsAvailable() > maxJobs);
-			}
-			jobExecutor.stopAndJoin();
+    }
+    catch (InterruptedException e)
+    {
+      fail("test execution exceeded treshold of " + maxWait + " milliseconds");
+    }
+    finally
+    {
+      timer.cancel();
+    }
+  }
 
-		}
-		catch(InterruptedException e) {
-			fail("test execution exceeded treshold of " + maxWait + " milliseconds");
-		}
-		finally {
-			timer.cancel();
-		}
-	}
+  protected int getNbrOfJobsAvailable()
+  {
+    if (session != null)
+    {
+      return getNbrOfJobsAvailable(session);
+    }
+    else
+    {
+      beginSessionTransaction();
+      try
+      {
+        return getNbrOfJobsAvailable(session);
+      }
+      finally
+      {
+        commitAndCloseSession();
+      }
+    }
+  }
 
-	protected int getNbrOfJobsAvailable() {
-		if(session != null) {
-			return getNbrOfJobsAvailable(session);
-		}
-		else {
-			beginSessionTransaction();
-			try {
-				return getNbrOfJobsAvailable(session);
-			}
-			finally {
-				commitAndCloseSession();
-			}
-		}
-	}
+  private int getNbrOfJobsAvailable(Session session)
+  {
+    int nbrOfJobsAvailable = 0;
+    Number jobs = (Number)session.createQuery("select count(*) from org.jbpm.job.Job").uniqueResult();
+    log.debug("there are '" + jobs + "' jobs currently in the job table");
+    if (jobs != null)
+    {
+      nbrOfJobsAvailable = jobs.intValue();
+    }
+    return nbrOfJobsAvailable;
+  }
 
-	private int getNbrOfJobsAvailable(Session session) {
-		int nbrOfJobsAvailable = 0;
-		Number jobs = (Number) session.createQuery(
-				"select count(*) from org.jbpm.job.Job").uniqueResult();
-		log.debug("there are '" + jobs + "' jobs currently in the job table");
-		if(jobs != null) {
-			nbrOfJobsAvailable = jobs.intValue();
-		}
-		return nbrOfJobsAvailable;
-	}
+  protected boolean areJobsAvailable()
+  {
+    return (getNbrOfJobsAvailable() > 0);
+  }
 
-	protected boolean areJobsAvailable() {
-		return(getNbrOfJobsAvailable() > 0);
-	}
+  protected Job getJob()
+  {
+    return (Job)session.createQuery("from org.jbpm.job.Job").uniqueResult();
+  }
 
-	protected Job getJob() {
-		return (Job) session.createQuery("from org.jbpm.job.Job").uniqueResult();
-	}
+  protected void processJobs(long maxWait)
+  {
+    processJobs(maxWait, 0);
+  }
 
-	protected void processJobs(long maxWait) {
-		processJobs(maxWait, 0);
-	}
+  protected void processJobs(long maxWait, int maxJobs)
+  {
+    commitAndCloseSession();
+    try
+    {
+      Thread.sleep(300);
+    }
+    catch (InterruptedException e)
+    {
+      e.printStackTrace();
+    }
+    startJobExecutor();
+    try
+    {
+      processAllJobs(maxWait, maxJobs);
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      throw new RuntimeException(e);
+    }
+    finally
+    {
+      stopJobExecutor();
+      beginSessionTransaction();
+    }
+  }
 
-	protected void processJobs(long maxWait, int maxJobs) {
-		commitAndCloseSession();
-		try {
-			Thread.sleep(300);
-		}
-		catch(InterruptedException e) {
-			e.printStackTrace();
-		}
-		startJobExecutor();
-		try {
-			processAllJobs(maxWait, maxJobs);
-		}
-		catch(Exception e) {
-			e.printStackTrace();
-			throw new RuntimeException(e);
-		}
-		finally {
-			stopJobExecutor();
-			beginSessionTransaction();
-		}
-	}
+  protected void stopJobExecutor()
+  {
+    if (jobExecutor != null)
+    {
+      try
+      {
+        jobExecutor.stopAndJoin();
+      }
+      catch (InterruptedException e)
+      {
+        throw new RuntimeException("waiting for job executor to stop and join got interrupted", e);
+      }
+    }
+  }
 
-	protected void stopJobExecutor() {
-		if(jobExecutor != null) {
-			try {
-				jobExecutor.stopAndJoin();
-			}
-			catch(InterruptedException e) {
-				throw new RuntimeException(
-						"waiting for job executor to stop and join got interrupted", e);
-			}
-		}
-	}
+  protected void initializeMembers()
+  {
+    session = jbpmContext.getSession();
+    graphSession = jbpmContext.getGraphSession();
+    taskMgmtSession = jbpmContext.getTaskMgmtSession();
+    loggingSession = jbpmContext.getLoggingSession();
+    jobSession = jbpmContext.getJobSession();
+    contextSession = jbpmContext.getContextSession();
+  }
 
-	protected void initializeMembers() {
-		session = jbpmContext.getSession();
-		graphSession = jbpmContext.getGraphSession();
-		taskMgmtSession = jbpmContext.getTaskMgmtSession();
-		loggingSession = jbpmContext.getLoggingSession();
-		jobSession = jbpmContext.getJobSession();
-		contextSession = jbpmContext.getContextSession();
-	}
+  protected void resetMembers()
+  {
+    session = null;
+    graphSession = null;
+    taskMgmtSession = null;
+    loggingSession = null;
+    jobSession = null;
+    contextSession = null;
+  }
 
-	protected void resetMembers() {
-		session = null;
-		graphSession = null;
-		taskMgmtSession = null;
-		loggingSession = null;
-		jobSession = null;
-		contextSession = null;
-	}
-
-	private static Log log = LogFactory.getLog(AbstractDbTestCase.class);
+  private static Log log = LogFactory.getLog(AbstractDbTestCase.class);
 }

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	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -54,14 +54,15 @@
 import org.jbpm.JbpmException;
 
 /**
- * utilities for the jBPM database schema.  
+ * utilities for the jBPM database schema.
  */
-public class JbpmSchema implements Serializable {
-  
+public class JbpmSchema implements Serializable
+{
+
   private static final long serialVersionUID = 1L;
 
   static final String JBPM_TABLE_PREFIX = "JBPM_";
-  
+
   Configuration configuration = null;
   Properties properties = null;
   Dialect dialect = null;
@@ -74,58 +75,68 @@
   Connection connection = null;
   Statement statement = null;
 
-  public JbpmSchema(Configuration configuration) {
+  public JbpmSchema(Configuration configuration)
+  {
     this.configuration = configuration;
     this.properties = configuration.getProperties();
     this.dialect = Dialect.getDialect(properties);
-    try {
+    try
+    {
       // get the mapping field via reflection :-(
       Field mappingField = Configuration.class.getDeclaredField("mapping");
       mappingField.setAccessible(true);
-      this.mapping = (Mapping) mappingField.get(configuration);
-    } catch (Exception e) {
+      this.mapping = (Mapping)mappingField.get(configuration);
+    }
+    catch (Exception e)
+    {
       throw new JbpmException("couldn't get the hibernate mapping", e);
     }
   }
 
-  public String[] getCreateSql() {
-    if (createSql==null) {
+  public String[] getCreateSql()
+  {
+    if (createSql == null)
+    {
       createSql = configuration.generateSchemaCreationScript(dialect);
     }
     return createSql;
   }
-  
-  public String[] getDropSql() {
-    if (dropSql==null) {
+
+  public String[] getDropSql()
+  {
+    if (dropSql == null)
+    {
       dropSql = configuration.generateDropSchemaScript(dialect);
     }
     return dropSql;
   }
-  
-  public String[] getCleanSql() {
-    if (cleanSql==null) {
+
+  public String[] getCleanSql()
+  {
+    if (cleanSql == null)
+    {
       // loop over all foreign key constraints
       List dropForeignKeysSql = new ArrayList();
       List createForeignKeysSql = new ArrayList();
       Iterator iter = configuration.getTableMappings();
-      while ( iter.hasNext() ) {
-        Table table = ( Table ) iter.next();
-        if ( table.isPhysicalTable() ) {
+      while (iter.hasNext())
+      {
+        Table table = (Table)iter.next();
+        if (table.isPhysicalTable())
+        {
           Iterator subIter = table.getForeignKeyIterator();
-          while ( subIter.hasNext() ) {
-            ForeignKey fk = ( ForeignKey ) subIter.next();
-            if ( fk.isPhysicalConstraint() ) {
+          while (subIter.hasNext())
+          {
+            ForeignKey fk = (ForeignKey)subIter.next();
+            //if (fk.getReferencedTable() != null && fk.isPhysicalConstraint())
+            if (fk.isPhysicalConstraint())
+            {
               // collect the drop foreign key constraint sql
-              dropForeignKeysSql.add( fk.sqlDropString( 
-                  dialect, 
-                  properties.getProperty(Environment.DEFAULT_CATALOG),
-                  properties.getProperty(Environment.DEFAULT_SCHEMA) ) );
+              dropForeignKeysSql
+                  .add(fk.sqlDropString(dialect, properties.getProperty(Environment.DEFAULT_CATALOG), properties.getProperty(Environment.DEFAULT_SCHEMA)));
               // and collect the create foreign key constraint sql
-              createForeignKeysSql.add( fk.sqlCreateString( 
-                  dialect,
-                  mapping,
-                  properties.getProperty(Environment.DEFAULT_CATALOG),
-                  properties.getProperty(Environment.DEFAULT_SCHEMA) ) );
+              createForeignKeysSql.add(fk.sqlCreateString(dialect, mapping, properties.getProperty(Environment.DEFAULT_CATALOG), properties
+                  .getProperty(Environment.DEFAULT_SCHEMA)));
             }
           }
         }
@@ -133,100 +144,126 @@
 
       List deleteSql = new ArrayList();
       iter = configuration.getTableMappings();
-      while (iter.hasNext()) {
-        Table table = (Table) iter.next();
-        deleteSql.add("delete from "+table.getName());
+      while (iter.hasNext())
+      {
+        Table table = (Table)iter.next();
+        deleteSql.add("delete from " + table.getName());
       }
 
       // glue
-      //  - drop foreign key constraints
-      //  - delete contents of all tables
-      //  - create foreign key constraints
+      // - drop foreign key constraints
+      // - delete contents of all tables
+      // - create foreign key constraints
       // together to form the clean script
       List cleanSqlList = new ArrayList();
       cleanSqlList.addAll(dropForeignKeysSql);
       cleanSqlList.addAll(deleteSql);
       cleanSqlList.addAll(createForeignKeysSql);
-      
-      cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
+
+      cleanSql = (String[])cleanSqlList.toArray(new String[cleanSqlList.size()]);
     }
     return cleanSql;
   }
 
-  public boolean hasJbpmTables() {
-    return (getJbpmTables().size()>0);
+  public boolean hasJbpmTables()
+  {
+    return (getJbpmTables().size() > 0);
   }
 
-  public List getJbpmTables() {
+  public List getJbpmTables()
+  {
     // delete all the data in the jbpm tables
     List jbpmTableNames = new ArrayList();
-    try {
+    try
+    {
       createConnection();
       ResultSet resultSet = connection.getMetaData().getTables(null, null, null, null);
-      while(resultSet.next()) {
+      while (resultSet.next())
+      {
         String tableName = resultSet.getString("TABLE_NAME");
-        if ( (tableName!=null)
-             && (tableName.length()>5)
-             && (JBPM_TABLE_PREFIX.equalsIgnoreCase(tableName.substring(0,5))) ) {
+        if ((tableName != null) && (tableName.length() > 5) && (JBPM_TABLE_PREFIX.equalsIgnoreCase(tableName.substring(0, 5))))
+        {
           jbpmTableNames.add(tableName);
         }
       }
-    } catch (SQLException e) {
+    }
+    catch (SQLException e)
+    {
       throw new JbpmException("couldn't get the jbpm table names");
-    } finally {
+    }
+    finally
+    {
       closeConnection();
     }
     return jbpmTableNames;
   }
-  
-  public void dropSchema() {
-    execute( getDropSql() );
+
+  public void dropSchema()
+  {
+    execute(getDropSql());
   }
 
-  public void createSchema() {
-    execute( getCreateSql() );
+  public void createSchema()
+  {
+    execute(getCreateSql());
   }
 
-  public void cleanSchema() {
-    execute( getCleanSql() );
+  public void cleanSchema()
+  {
+    if (getJbpmTables().size() > 0)
+      execute(getCleanSql());
   }
 
-  public void saveSqlScripts(String dir, String prefix) {
-    try {
+  public void saveSqlScripts(String dir, String prefix)
+  {
+    try
+    {
       new File(dir).mkdirs();
-      saveSqlScript(dir+"/"+prefix+".drop.sql", getDropSql());
-      saveSqlScript(dir+"/"+prefix+".create.sql", getCreateSql());
-      saveSqlScript(dir+"/"+prefix+".clean.sql", getCleanSql());
-      new SchemaExport(configuration)
-        .setDelimiter(getSqlDelimiter())
-        .setOutputFile(dir+"/"+prefix+".drop.create.sql")
-        .create(true, false);
-    } catch (IOException e) {
+      saveSqlScript(dir + "/" + prefix + ".drop.sql", getDropSql());
+      saveSqlScript(dir + "/" + prefix + ".create.sql", getCreateSql());
+      saveSqlScript(dir + "/" + prefix + ".clean.sql", getCleanSql());
+      new SchemaExport(configuration).setDelimiter(getSqlDelimiter()).setOutputFile(dir + "/" + prefix + ".drop.create.sql").create(true, false);
+    }
+    catch (IOException e)
+    {
       throw new JbpmException("couldn't generate scripts", e);
     }
   }
 
-  public static void main(String[] args) {
-    if ( (args==null) || (args.length==0) ) {
+  public static void main(String[] args)
+  {
+    if ((args == null) || (args.length == 0))
+    {
       syntax();
-    } else if ("create".equalsIgnoreCase(args[0]) && args.length <= 3) {
+    }
+    else if ("create".equalsIgnoreCase(args[0]) && args.length <= 3)
+    {
       Configuration configuration = createConfiguration(args, 1);
       new JbpmSchema(configuration).createSchema();
-    } else if ("drop".equalsIgnoreCase(args[0]) && args.length <= 3) {
+    }
+    else if ("drop".equalsIgnoreCase(args[0]) && args.length <= 3)
+    {
       Configuration configuration = createConfiguration(args, 1);
       new JbpmSchema(configuration).dropSchema();
-    } else if ("clean".equalsIgnoreCase(args[0]) && args.length <= 3) {
+    }
+    else if ("clean".equalsIgnoreCase(args[0]) && args.length <= 3)
+    {
       Configuration configuration = createConfiguration(args, 1);
       new JbpmSchema(configuration).cleanSchema();
-    } else if ("scripts".equalsIgnoreCase(args[0]) && args.length >= 3 && args.length <= 5) {
+    }
+    else if ("scripts".equalsIgnoreCase(args[0]) && args.length >= 3 && args.length <= 5)
+    {
       Configuration configuration = createConfiguration(args, 3);
       new JbpmSchema(configuration).saveSqlScripts(args[1], args[2]);
-    } else {
+    }
+    else
+    {
       syntax();
     }
   }
 
-  private static void syntax() {
+  private static void syntax()
+  {
     System.err.println("syntax:");
     System.err.println("JbpmSchema create [<hibernate.cfg.xml> [<hibernate.properties>]]");
     System.err.println("JbpmSchema drop [<hibernate.cfg.xml> [<hibernate.properties>]]");
@@ -234,105 +271,139 @@
     System.err.println("JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
   }
 
-  static Configuration createConfiguration(String[] args, int index) {
-    String hibernateCfgXml = (args.length>index ? args[index] : "hibernate.cfg.xml");
-    String hibernateProperties = (args.length>(index+1) ? args[index+1] : null);
-    
+  static Configuration createConfiguration(String[] args, int index)
+  {
+    String hibernateCfgXml = (args.length > index ? args[index] : "hibernate.cfg.xml");
+    String hibernateProperties = (args.length > (index + 1) ? args[index + 1] : null);
+
     Configuration configuration = new Configuration();
     configuration.configure(new File(hibernateCfgXml));
-    if (hibernateProperties!=null) {
-      try {
+    if (hibernateProperties != null)
+    {
+      try
+      {
         Properties properties = new Properties();
         InputStream inputStream = new FileInputStream(hibernateProperties);
         properties.load(inputStream);
         configuration.setProperties(properties);
-      } catch (IOException e) {
+      }
+      catch (IOException e)
+      {
         throw new JbpmException("couldn't load hibernate configuration", e);
       }
     }
-    
+
     return configuration;
   }
 
-  void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException {
+  void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException
+  {
     FileOutputStream fileOutputStream = new FileOutputStream(fileName);
-    try {
+    try
+    {
       PrintStream printStream = new PrintStream(fileOutputStream);
-      for (int i=0; i<sql.length; i++) {
-        printStream.println(sql[i]+getSqlDelimiter());
+      for (int i = 0; i < sql.length; i++)
+      {
+        printStream.println(sql[i] + getSqlDelimiter());
       }
-    } finally {
-      try { 
-        fileOutputStream.close(); 
-      } catch (IOException e) { 
+    }
+    finally
+    {
+      try
+      {
+        fileOutputStream.close();
+      }
+      catch (IOException e)
+      {
         log.debug("failed to close file", e);
       }
     }
   }
 
-  public void execute(String[] sqls) {
+  public void execute(String[] sqls)
+  {
     String sql = null;
     String showSqlText = properties.getProperty("hibernate.show_sql");
     boolean showSql = ("true".equalsIgnoreCase(showSqlText));
 
-    try {
+    try
+    {
       createConnection();
       statement = connection.createStatement();
-      
-      for (int i=0; i<sqls.length; i++) {
+
+      for (int i = 0; i < sqls.length; i++)
+      {
         sql = sqls[i];
-        
-        if (showSql) log.debug(sql);
+
+        if (showSql)
+          log.debug(sql);
         statement.executeUpdate(sql);
       }
-    
-    } catch (SQLException e) {
-      throw new JbpmException("couldn't execute sql '"+sql+"'", e);
-    } finally {
+
+    }
+    catch (SQLException e)
+    {
+      throw new JbpmException("couldn't execute sql '" + sql + "'", e);
+    }
+    finally
+    {
       closeConnection();
     }
   }
 
-  void closeConnection() {
-    if (statement!=null) {
-      try {
+  void closeConnection()
+  {
+    if (statement != null)
+    {
+      try
+      {
         statement.close();
       }
-      catch (SQLException e) {
+      catch (SQLException e)
+      {
         log.debug("could not close jdbc statement", e);
       }
     }
-    if (connection!=null) {
-      try {
-        JDBCExceptionReporter.logWarnings( connection.getWarnings() );
+    if (connection != null)
+    {
+      try
+      {
+        JDBCExceptionReporter.logWarnings(connection.getWarnings());
         connection.clearWarnings();
         connectionProvider.closeConnection(connection);
         connectionProvider.close();
       }
-      catch (SQLException e) {
+      catch (SQLException e)
+      {
         log.debug("could not close jdbc connection", e);
       }
     }
   }
 
-  void createConnection() throws SQLException {
+  void createConnection() throws SQLException
+  {
     connectionProvider = ConnectionProviderFactory.newConnectionProvider(properties);
     connection = connectionProvider.getConnection();
-    if ( !connection.getAutoCommit() ) {
+    if (!connection.getAutoCommit())
+    {
       connection.commit();
       connection.setAutoCommit(true);
     }
   }
 
-  public Properties getProperties() {
+  public Properties getProperties()
+  {
     return properties;
   }
 
   // sql delimiter ////////////////////////////////////////////////////////////
-  
+
   static String sqlDelimiter = null;
-  synchronized String getSqlDelimiter() {
-    if (sqlDelimiter==null) {
+
+  synchronized String getSqlDelimiter()
+  {
+    if (sqlDelimiter == null)
+    {
       sqlDelimiter = properties.getProperty("jbpm.sql.delimiter", ";");
     }
     return sqlDelimiter;

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -29,12 +29,14 @@
 import org.hibernate.cfg.Configuration;
 import org.hibernate.tool.hbm2ddl.SchemaExport;
 import org.jbpm.JbpmConfiguration;
+import org.jbpm.db.JbpmSchema;
 import org.jbpm.db.hibernate.HibernateHelper;
 import org.jbpm.svc.Service;
 import org.jbpm.svc.ServiceFactory;
 import org.jbpm.util.JndiUtil;
 
-public class DbPersistenceServiceFactory implements ServiceFactory {
+public class DbPersistenceServiceFactory implements ServiceFactory
+{
 
   private static final long serialVersionUID = 1L;
 
@@ -42,7 +44,7 @@
 
   String sessionFactoryJndiName = null;
   SessionFactory sessionFactory = null;
-  
+
   String dataSourceJndiName = null;
   DataSource dataSource = null;
 
@@ -51,19 +53,24 @@
 
   SchemaExport schemaExport = null;
 
-  public Service openService() {
+  public Service openService()
+  {
     log.debug("creating persistence service");
     return new DbPersistenceService(this);
   }
 
-  public synchronized Configuration getConfiguration() {
-    if (configuration==null) {
+  public synchronized Configuration getConfiguration()
+  {
+    if (configuration == null)
+    {
       String hibernateCfgXmlResource = null;
-      if (JbpmConfiguration.Configs.hasObject("resource.hibernate.cfg.xml")) {
+      if (JbpmConfiguration.Configs.hasObject("resource.hibernate.cfg.xml"))
+      {
         hibernateCfgXmlResource = JbpmConfiguration.Configs.getString("resource.hibernate.cfg.xml");
       }
       String hibernatePropertiesResource = null;
-      if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties")) {
+      if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties"))
+      {
         hibernatePropertiesResource = JbpmConfiguration.Configs.getString("resource.hibernate.properties");
       }
       configuration = HibernateHelper.createConfiguration(hibernateCfgXmlResource, hibernatePropertiesResource);
@@ -71,102 +78,143 @@
     return configuration;
   }
 
-  public synchronized SchemaExport getSchemaExport() {
-    if (schemaExport==null) {
+  public synchronized SchemaExport getSchemaExport()
+  {
+    if (schemaExport == null)
+    {
       log.debug("creating schema export");
       schemaExport = new SchemaExport(getConfiguration());
     }
     return schemaExport;
   }
 
-  public synchronized SessionFactory getSessionFactory() {
-    if (sessionFactory==null) {
+  public synchronized SessionFactory getSessionFactory()
+  {
+    if (sessionFactory == null)
+    {
 
-      if (sessionFactoryJndiName!=null) {
-        log.debug("looking up hibernate session factory in jndi '"+sessionFactoryJndiName+"'");
-        sessionFactory = (SessionFactory) JndiUtil.lookup(sessionFactoryJndiName, SessionFactory.class);
-        
-      } else {
+      if (sessionFactoryJndiName != null)
+      {
+        log.debug("looking up hibernate session factory in jndi '" + sessionFactoryJndiName + "'");
+        sessionFactory = (SessionFactory)JndiUtil.lookup(sessionFactoryJndiName, SessionFactory.class);
+
+      }
+      else
+      {
         log.debug("building hibernate session factory");
         sessionFactory = getConfiguration().buildSessionFactory();
       }
     }
     return sessionFactory;
   }
-  
-  public DataSource getDataSource() {
-    if ( (dataSource==null)
-         && (dataSourceJndiName!=null)
-       ) {
-      log.debug("looking up datasource from jndi location '"+dataSourceJndiName+"'");
-      dataSource = (DataSource) JndiUtil.lookup(dataSourceJndiName, DataSource.class);
+
+  public DataSource getDataSource()
+  {
+    if ((dataSource == null) && (dataSourceJndiName != null))
+    {
+      log.debug("looking up datasource from jndi location '" + dataSourceJndiName + "'");
+      dataSource = (DataSource)JndiUtil.lookup(dataSourceJndiName, DataSource.class);
     }
     return dataSource;
   }
-  
-  public void createSchema() {
+
+  public void cleanSchema()
+  {
+    new JbpmSchema(getConfiguration()).cleanSchema();
+    HibernateHelper.clearHibernateCache(getSessionFactory());
+  }
+
+  public void createSchema()
+  {
     getSchemaExport().create(getScript(), true);
     HibernateHelper.clearHibernateCache(getSessionFactory());
   }
-  
-  public void dropSchema() {
+
+  public void dropSchema()
+  {
     HibernateHelper.clearHibernateCache(getSessionFactory());
     getSchemaExport().drop(getScript(), true);
   }
 
-  boolean getScript() {
+  boolean getScript()
+  {
     boolean script = false;
     String showSql = getConfiguration().getProperty("hibernate.show_sql");
-    if ("true".equalsIgnoreCase(showSql)) {
+    if ("true".equalsIgnoreCase(showSql))
+    {
       script = true;
     }
     return script;
   }
 
-  public void close() {
-    if (sessionFactory!=null) {
+  public void close()
+  {
+    if (sessionFactory != null)
+    {
       log.debug("closing hibernate session factory");
       sessionFactory.close();
     }
   }
 
-  public String getDataSourceJndiName() {
+  public String getDataSourceJndiName()
+  {
     return dataSourceJndiName;
   }
-  public void setDataSourceJndiName(String dataSourceJndiName) {
+
+  public void setDataSourceJndiName(String dataSourceJndiName)
+  {
     this.dataSourceJndiName = dataSourceJndiName;
   }
-  public String getSessionFactoryJndiName() {
+
+  public String getSessionFactoryJndiName()
+  {
     return sessionFactoryJndiName;
   }
-  public void setSessionFactoryJndiName(String sessionFactoryJndiName) {
+
+  public void setSessionFactoryJndiName(String sessionFactoryJndiName)
+  {
     this.sessionFactoryJndiName = sessionFactoryJndiName;
   }
-  public void setConfiguration(Configuration configuration) {
+
+  public void setConfiguration(Configuration configuration)
+  {
     this.configuration = configuration;
   }
-  public void setDataSource(DataSource dataSource) {
+
+  public void setDataSource(DataSource dataSource)
+  {
     this.dataSource = dataSource;
   }
-  public void setSchemaExport(SchemaExport schemaExport) {
+
+  public void setSchemaExport(SchemaExport schemaExport)
+  {
     this.schemaExport = schemaExport;
   }
-  public void setSessionFactory(SessionFactory sessionFactory) {
+
+  public void setSessionFactory(SessionFactory sessionFactory)
+  {
     this.sessionFactory = sessionFactory;
   }
-  public boolean isTransactionEnabled() {
+
+  public boolean isTransactionEnabled()
+  {
     return isTransactionEnabled;
   }
-  public void setTransactionEnabled(boolean isTransactionEnabled) {
+
+  public void setTransactionEnabled(boolean isTransactionEnabled)
+  {
     this.isTransactionEnabled = isTransactionEnabled;
   }
-  public boolean isCurrentSessionEnabled() {
+
+  public boolean isCurrentSessionEnabled()
+  {
     return isCurrentSessionEnabled;
   }
-  public void setCurrentSessionEnabled(boolean isCurrentSessionEnabled) {
+
+  public void setCurrentSessionEnabled(boolean isCurrentSessionEnabled)
+  {
     this.isCurrentSessionEnabled = isCurrentSessionEnabled;
   }
 
   private static Log log = LogFactory.getLog(DbPersistenceServiceFactory.class);
 }
-

Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml	2008-09-11 22:59:00 UTC (rev 2182)
@@ -17,6 +17,9 @@
     <!-- # common settings                 # -->
     <!-- ################################### -->
 
+    <!-- Create schema on demand -->
+    <property name="hibernate.hbm2ddl.auto">create</property>
+    
     <!-- Simple memory-only cache -->
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
 

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -40,8 +40,7 @@
  */
 public class JBPM1106Test extends AbstractDbTestCase
 {
-
-  private static CommandService commandService = new CommandServiceImpl(jbpmConfiguration);
+  private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
   private ProcessDefinition processDefinition;
 
   public void setUp() throws Exception

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jcr/JcrDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jcr/JcrDbTest.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jcr/JcrDbTest.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -36,41 +36,40 @@
  * 
  * @author Jim Rigsbee, Tom Baeyens
  */
-public class JcrDbTest extends AbstractDbTestCase {
-  
-  public static JbpmConfiguration jbpmJcrConfiguration = 
-      JbpmConfiguration.parseResource("org/jbpm/jcr/jbpm.jcr.cfg.xml");
-  
-  protected JbpmConfiguration getJbpmConfiguration() {
-    return jbpmJcrConfiguration;
+public class JcrDbTest extends AbstractDbTestCase
+{
+
+  @Override
+  protected JbpmConfiguration getJbpmConfiguration()
+  {
+    return JbpmConfiguration.parseResource("org/jbpm/jcr/jbpm.jcr.cfg.xml");
   }
 
-  public void testJcrNodeStorageAndRetrieval() throws Exception {
+  public void testJcrNodeStorageAndRetrieval() throws Exception
+  {
     deployDocumentApprovalProcess();
 
     newTransaction();
-    
+
     ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("document approval");
 
-    JcrService jcrService = (JcrService) jbpmContext.getServices().getService(Services.SERVICENAME_JCR);
+    JcrService jcrService = (JcrService)jbpmContext.getServices().getService(Services.SERVICENAME_JCR);
     assertNotNull(jcrService);
     Session session = jcrService.getSession();
     Node rootNode = session.getRootNode();
-    Node processInstanceNode = rootNode.addNode("process"+processInstance.getId());
+    Node processInstanceNode = rootNode.addNode("process" + processInstance.getId());
     Node documentNode = processInstanceNode.addNode("document");
 
     ContextInstance contextInstance = processInstance.getContextInstance();
     contextInstance.setVariable("document", documentNode);
-    
+
     newTransaction();
   }
 
-  public void deployDocumentApprovalProcess() {
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
-      "<process-definition name='document approval'>" +
-      "  <start-state name='start' />" +
-      "</process-definition>"
-    );
+  public void deployDocumentApprovalProcess()
+  {
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='document approval'>" + "  <start-state name='start' />"
+        + "</process-definition>");
     jbpmContext.deployProcessDefinition(processDefinition);
   }
 }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -8,6 +8,7 @@
 
 public class LoggingConfigDbTest extends AbstractDbTestCase {
   
+  @Override
   protected JbpmConfiguration getJbpmConfiguration() {
     return JbpmConfiguration.parseResource("org/jbpm/logging/exe/nologging.jbpm.cfg.xml");
   }

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java	2008-09-11 19:04:35 UTC (rev 2181)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java	2008-09-11 22:59:00 UTC (rev 2182)
@@ -4,8 +4,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.jbpm.JbpmConfiguration;
@@ -14,13 +12,9 @@
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.Comment;
 import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.persistence.db.DbPersistenceServiceFactory;
 
-public class LockingTest extends TestCase
+public class LockingTest extends AbstractDbTestCase
 {
-
-  static JbpmConfiguration jbpmConfiguration = AbstractDbTestCase.getDbTestJbpmConfiguration();
-
   static int nbrOfThreads = 5;
   static int nbrOfIterations = 20;
 
@@ -33,11 +27,16 @@
     // start state, and that signal will bring the process to it's end state.
 
     // It's the second transaction for which we'll set up multiple competing threads
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='lockprocess'>" + "  <start-state name='start'>"
-        + "    <transition to='end'/>" + "  </start-state>" + "  <end-state name='end' />" + "</process-definition>");
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
+        "<process-definition name='lockprocess'>" + 
+        "  <start-state name='start'>" + 
+        "    <transition to='end'/>" + 
+        "  </start-state>" + 
+        "  <end-state name='end' />" + 
+        "</process-definition>");
 
     // deploy the process
-    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+    JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
     try
     {
       jbpmContext.deployProcessDefinition(processDefinition);
@@ -50,7 +49,6 @@
 
   public void testLocking()
   {
-    createSchema();
     deployProcess();
 
     for (int i = 0; i < nbrOfIterations; i++)
@@ -72,7 +70,7 @@
       joinAllThreads(threads);
 
       // check that only 1 of those threads committed
-      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+      JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
       try
       {
         Session session = jbpmContext.getSession();
@@ -91,7 +89,7 @@
       }
 
       // check that the process instance has ended
-      jbpmContext = jbpmConfiguration.createJbpmContext();
+      jbpmContext = getJbpmConfiguration().createJbpmContext();
       try
       {
         ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
@@ -107,7 +105,7 @@
 
   private long launchProcessInstance()
   {
-    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+    JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
     try
     {
       return jbpmContext.newProcessInstance("lockprocess").getId();
@@ -123,7 +121,7 @@
     List threads = new ArrayList();
     for (int i = 0; i < nbrOfThreads; i++)
     {
-      Thread thread = new LockThread(semaphore, processInstanceId);
+      Thread thread = new LockThread(getJbpmConfiguration(), semaphore, processInstanceId);
       thread.start();
       threads.add(thread);
     }
@@ -145,11 +143,13 @@
   {
     Object semaphore;
     long processInstanceId;
+    JbpmConfiguration jbpmConfiguration;
 
-    public LockThread(Object semaphore, long processInstanceId)
+    public LockThread(JbpmConfiguration jbpmConfiguration, Object semaphore, long processInstanceId)
     {
       this.semaphore = semaphore;
       this.processInstanceId = processInstanceId;
+      this.jbpmConfiguration = jbpmConfiguration;
     }
 
     public void run()
@@ -214,12 +214,4 @@
       }
     }
   }
-
-  private void createSchema()
-  {
-    // create the jbpm schema
-    DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory("persistence");
-    persistenceServiceFactory.createSchema();
-  }
-
 }




More information about the jbpm-commits mailing list