[jbpm-commits] JBoss JBPM SVN: r5683 - in jbpm3/branches/jbpm-3.2-soa/modules: core/src/main/java/org/jbpm/configuration and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Oct 4 18:16:33 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-10-04 18:16:32 -0400 (Sun, 04 Oct 2009)
New Revision: 5683

Modified:
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.common.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.properties.hsqldb.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.db2.hbm.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm1071/JBPM1071Test.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml
   jbpm3/branches/jbpm-3.2-soa/modules/distribution/pom.xml
   jbpm3/branches/jbpm-3.2-soa/modules/enterprise/pom.xml
Log:
[JBPM-2563] Prevent test suite from continously recreating database schema

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -32,8 +32,8 @@
 import org.jbpm.JbpmConfiguration;
 
 /**
- * is used by {@link org.jbpm.bytes.ByteArray} to chop a 
- * byte arrays into a list of chunks and glue them back together. 
+ * is used by {@link org.jbpm.bytes.ByteArray} to chop a byte arrays into a list of chunks and
+ * glue them back together.
  */
 public class ByteBlockChopper {
 
@@ -49,7 +49,7 @@
       int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
       int byteCount = byteArray.length;
       if (byteCount > blockSize) {
-        log.debug("chopping " + byteCount + " bytes");
+        if (log.isTraceEnabled()) log.trace("chopping up " + byteCount + " bytes");
         bytes = new ArrayList();
         int offset;
         for (offset = 0; byteCount - offset > blockSize; offset += blockSize) {
@@ -58,7 +58,7 @@
         bytes.add(subArray(byteArray, offset, byteCount - offset));
       }
       else if (byteCount > 0) {
-        log.debug("no need to chop " + byteCount + " bytes");
+        if (log.isTraceEnabled()) log.trace("no need to chop " + byteCount + " bytes");
         bytes = Collections.singletonList(byteArray);
       }
     }
@@ -68,13 +68,13 @@
   private static byte[] subArray(byte[] array, int offset, int length) {
     byte[] subArray = new byte[length];
     System.arraycopy(array, offset, subArray, 0, length);
-    log.debug("chopped " + length + " bytes beggining at " + offset);
+    if (log.isTraceEnabled()) log.trace("chopped " + length + " bytes at offset " + offset);
     return subArray;
   }
 
   public static byte[] glueChopsBackTogether(List byteBlocks) {
     byte[] byteArray = null;
-    
+
     if (byteBlocks != null) {
       int blockCount = byteBlocks.size();
       switch (blockCount) {
@@ -82,13 +82,13 @@
         break;
       case 1:
         byteArray = (byte[]) byteBlocks.get(0);
-        log.debug("no need to glue " + byteArray.length + " bytes");
+        if (log.isTraceEnabled()) log.trace("no need to glue " + byteArray.length + " bytes");
         break;
       default:
         int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
         byte[] lastBlock = (byte[]) byteBlocks.get(blockCount - 1);
         int byteCount = blockSize * (blockCount - 1) + lastBlock.length;
-        log.debug("gluing " + byteCount + " bytes");
+        if (log.isTraceEnabled()) log.trace("gluing " + byteCount + " bytes back together");
 
         byteArray = new byte[byteCount];
         int offset = 0;
@@ -96,16 +96,18 @@
           byte[] block = (byte[]) byteBlocks.get(i);
           int length = block.length;
           System.arraycopy(block, 0, byteArray, offset, length);
-          log.debug("glued " + length + " bytes beggining at " + offset);
+          if (log.isTraceEnabled())
+            log.trace("glued " + length + " bytes at offset " + offset);
+
           // JBPM-702 sybase truncates trailing zeros
-          if (length < blockSize && i < n-1) {
+          if (length < blockSize && i < n - 1) {
             Arrays.fill(byteArray, offset + length, offset + blockSize, (byte) 0);
-            log.debug("zero filled " + (blockSize - length) + " trailing bytes");
             offset += blockSize;
+            if (log.isTraceEnabled())
+              log.trace("zero filled " + (blockSize - length) + " trailing bytes");
           }
-          else {
-            offset += length;            
-          }
+          else
+            offset += length;
         }
       }
     }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -38,12 +38,12 @@
 
   private static final long serialVersionUID = 1L;
 
-  ClassLoader classLoader = null; // lazy load it later! See below..
-  List objectInfos = null;
-  Map namedObjectInfos = null;
-  Map singletons = new HashMap();
-  Map objects = new HashMap();
-  Collection objectsUnderConstruction = new HashSet();
+  ClassLoader classLoader;
+  final List objectInfos;
+  final Map namedObjectInfos;
+  final Map singletons = new HashMap();
+  final Map objects = new HashMap();
+  final Collection objectsUnderConstruction = new HashSet();
 
   public ObjectFactoryImpl() {
     objectInfos = new ArrayList();
@@ -67,8 +67,8 @@
   }
 
   /**
-   * create a new object of the given name. Before creation starts, the non-singlton objects will be
-   * cleared from the registry. The singletons will remain in the registry.
+   * create a new object of the given name. Before creation starts, the non-singlton objects
+   * will be cleared from the registry. The singletons will remain in the registry.
    */
   public synchronized Object createObject(String name) {
     ObjectInfo objectInfo = (ObjectInfo) namedObjectInfos.get(name);
@@ -86,11 +86,11 @@
   }
 
   /**
-   * create a new object for the given index. Before creation starts, the non-singlton objects will
-   * be cleared from the registry. The singletons will remain in the registry.
+   * create a new object for the given index. Before creation starts, the non-singlton objects
+   * will be cleared from the registry. The singletons will remain in the registry.
    */
   public Object createObject(int index) {
-    if ((index < 0) || (index >= objectInfos.size())) {
+    if (index < 0 || index >= objectInfos.size()) {
       throw new ConfigurationException("index '"
           + index
           + "' is not defined in the configuration.  range [0.."
@@ -101,8 +101,9 @@
   }
 
   /**
-   * create a new object for the given {@link ObjectInfo}. Before creation starts, the non-singlton
-   * objects will be cleared from the registry. The singletons will remain in the registry.
+   * create a new object for the given {@link ObjectInfo}. Before creation starts, the
+   * non-singlton objects will be cleared from the registry. The singletons will remain in the
+   * registry.
    */
   public Object createObject(ObjectInfo objectInfo) {
     clearRegistry();
@@ -115,8 +116,8 @@
   }
 
   /**
-   * create an object of the given name. If the object was created before, that object is returned
-   * from the registry.
+   * create an object of the given name. If the object was created before, that object is
+   * returned from the registry.
    */
   Object getObject(String name) {
     Object object = null;
@@ -143,7 +144,6 @@
     Object registryKey = getRegistryKey(objectInfo);
     if (isInRegistry(registryKey)) {
       object = findInRegistry(registryKey);
-
     }
     else {
       if (registryKey != null) {
@@ -157,9 +157,7 @@
         finally {
           objectsUnderConstruction.remove(registryKey);
         }
-
         putInRegistry(objectInfo, object, registryKey);
-
       }
       else {
         object = objectInfo.createObject(this);
@@ -169,9 +167,6 @@
   }
 
   Class classForName(String className) {
-    // "lazy load" classloader, shouldn't be loaded too early 
-    // because if jbpm.cfg.xml is not yet parsed, the correct class loader
-    // may not be initialized yet.
     if (classLoader == null) {
       classLoader = ClassLoaderUtil.getClassLoader();
     }
@@ -192,7 +187,8 @@
   }
 
   boolean isInRegistry(Object registryKey) {
-    return ((registryKey != null) && ((objects.containsKey(registryKey)) || (singletons.containsKey(registryKey))));
+    return registryKey != null
+        && (objects.containsKey(registryKey) || singletons.containsKey(registryKey));
   }
 
   void putInRegistry(ObjectInfo objectInfo, Object object, Object registryKey) {

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -66,7 +66,8 @@
   private String delimiter;
   private final List exceptions = new ArrayList();
 
-  private static final String[] EMPTY_STRING_ARRAY = new String[0];
+  private static final String[] EMPTY_STRING_ARRAY = {};
+  private static final String[] TABLE_TYPES = { "TABLE" };
 
   public JbpmSchema(Configuration configuration) {
     this.configuration = configuration;
@@ -121,7 +122,8 @@
     Connection connection = null;
     try {
       connection = createConnection();
-      return configuration.generateSchemaUpdateScript(getDialect(), getDatabaseMetadata(connection));
+      return configuration.generateSchemaUpdateScript(getDialect(),
+          getDatabaseMetadata(connection));
     }
     catch (SQLException e) {
       exceptions.add(e);
@@ -306,7 +308,7 @@
       DatabaseMetaData metaData = connection.getMetaData();
       boolean storesLowerCaseIdentifiers = metaData.storesLowerCaseIdentifiers();
       ResultSet resultSet = metaData.getTables(getDefaultCatalog(), getDefaultSchema(), null,
-          new String[] { "TABLE" });
+          TABLE_TYPES);
       try {
         while (resultSet.next()) {
           String tableName = resultSet.getString("TABLE_NAME");
@@ -335,8 +337,16 @@
     Connection connection = null;
     try {
       connection = createConnection();
-      Table table = findTableMapping(tableName);
-      return getTableMetadata(connection, table) != null;
+
+      DatabaseMetaData metaData = connection.getMetaData();
+      ResultSet resultSet = metaData.getTables(getDefaultCatalog(), getDefaultSchema(),
+          tableName, TABLE_TYPES);
+      try {
+        return resultSet.next();
+      }
+      finally {
+        resultSet.close();
+      }
     }
     catch (SQLException e) {
       exceptions.add(e);
@@ -390,7 +400,8 @@
     return new DatabaseMetadata(connection, getDialect());
   }
 
-  private TableMetadata getTableMetadata(Connection connection, Table table) throws SQLException {
+  private TableMetadata getTableMetadata(Connection connection, Table table)
+      throws SQLException {
     String tableSchema = table.getSchema();
     String tableCatalog = table.getCatalog();
     return getDatabaseMetadata(connection).getTableMetadata(table.getName(),
@@ -424,6 +435,9 @@
       else if ("clean".equalsIgnoreCase(action)) {
         getJbpmSchema(args, 1).cleanSchema();
       }
+      else if ("update".equalsIgnoreCase(action)) {
+        getJbpmSchema(args, 1).updateSchema();
+      }
       else if ("scripts".equalsIgnoreCase(action) && args.length > 2) {
         getJbpmSchema(args, 3).saveSqlScripts(args[1], args[2]);
       }
@@ -439,6 +453,7 @@
     System.err.println("JbpmSchema create [<hibernate.cfg.xml> [<hibernate.properties>]]");
     System.err.println("JbpmSchema drop [<hibernate.cfg.xml> [<hibernate.properties>]]");
     System.err.println("JbpmSchema clean [<hibernate.cfg.xml> [<hibernate.properties>]]");
+    System.err.println("JbpmSchema update [<hibernate.cfg.xml> [<hibernate.properties>]]");
     System.err.println("JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
     System.exit(1);
   }
@@ -455,9 +470,10 @@
       if (index + 1 < args.length) {
         String hibernateProperties = args[index + 1];
         try {
-          InputStream inputStream = new FileInputStream(hibernateProperties);
+          InputStream fileSource = new FileInputStream(hibernateProperties);
           Properties properties = new Properties();
-          properties.load(inputStream);
+          properties.load(fileSource);
+          fileSource.close();
           configuration.addProperties(properties);
         }
         catch (IOException e) {

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -100,8 +100,8 @@
       // load the properties
       Properties properties = loadPropertiesFromResource(propertiesResource);
       if (!properties.isEmpty()) {
-        // and overwrite the properties with the specified properties
-        configuration.setProperties(properties);
+        // add (and replace) the properties to the configuration
+        configuration.addProperties(properties);
       }
     }
 

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -94,7 +94,6 @@
 
   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);

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -91,8 +91,8 @@
    * <li><code>jbpm</code> (default) indicates the class loader of the jBPM classes. Before <a
    * href="https://jira.jboss.org/jira/browse/JBPM-1148">JBPM-1148</a> no other behavior was
    * available</li>
-   * <li><code>context</code> indicates the {@linkplain Thread#getContextClassLoader() context class
-   * loader}</li>
+   * <li><code>context</code> indicates the {@linkplain Thread#getContextClassLoader() context
+   * class loader}</li>
    * <li>any other value is interpreted as a reference to a class loader bean described in the
    * configuration</li>
    * </ul>
@@ -129,20 +129,17 @@
   }
 
   /**
-   * Load jbpm configuration related resources as stream (normally jbpm.cfg.xml). This method first
-   * tries to load the resource from the {@link ClassLoaderUtil} class loader, if not found it tries
-   * the context class loader. If this doesn't return any ressource the call is delegated to the
-   * class loader configured by calling getClassLoader(). This is a special method because the class
-   * loader which has to be used for loading the jbpm.cfg.xml cannot be configured in the
-   * jbpm.cfg.xml itself.
+   * Load classpath resource as stream. This method first loads the resource from the context
+   * class loader, if not found it tries the current class loader. If no resource is found the
+   * call returns <code>null</code>. This is a special method because the class loader used for
+   * loading the jBPM configuration cannot be configured in the configuration file itself.
    */
   public static InputStream getStream(String resource, boolean useConfiguredLoader) {
     if (useConfiguredLoader) return getStream(resource);
 
     // try context class loader first, so that applications can override provided classes
-    InputStream stream = Thread.currentThread()
-        .getContextClassLoader()
-        .getResourceAsStream(resource);
+    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(
+        resource);
     if (stream == null) {
       // try the class loader of the current class
       stream = ClassLoaderUtil.class.getClassLoader().getResourceAsStream(resource);

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.common.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.common.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -16,16 +16,13 @@
     <!-- # common settings                 # -->
     <!-- ################################### -->
 
-    <!-- Automatic schema creation (begin) -->
-    <property name="hibernate.hbm2ddl.auto">create</property>
-    <!-- Automatic schema creation (end) -->
-
     <!-- Simple memory-only cache -->
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
 
-    <!-- SQL rendering properties -->
+    <!-- SQL rendering properties (begin) ===
     <property name="hibernate.format_sql">true</property>
     <property name="hibernate.use_sql_comments">true</property>
+    ==== SQL rendering properties (end) -->
 
     <!-- ############################################ -->
     <!-- # mapping files with external dependencies # -->

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.properties.hsqldb.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.properties.hsqldb.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.properties.hsqldb.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -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/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.db2.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.db2.hbm.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.db2.hbm.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -10,7 +10,6 @@
          abstract="true" 
          discriminator-value="V">
     <id name="id" column="ID_"><generator class="native" /></id>
-    <discriminator type="char" column="CLASS_"/>
     <!-- V : org.jbpm.context.exe.VariableInstance -->
     <!-- B : org.jbpm.context.exe.variableinstance.ByteArrayInstance -->
     <!-- D : org.jbpm.context.exe.variableinstance.DateInstance -->
@@ -21,6 +20,7 @@
     <!-- S : org.jbpm.context.exe.variableinstance.StringInstance -->
     <!-- N : org.jbpm.context.exe.variableinstance.NullInstance -->
     <!-- J : org.jbpm.context.exe.variableinstance.JcrNodeInstance -->
+    <discriminator type="char" column="CLASS_"/>
     <version name="version" column="VERSION_" />
     
     <property name="name" column="NAME_"/>

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -10,7 +10,6 @@
          abstract="true" 
          discriminator-value="V">
     <id name="id" column="ID_"><generator class="native" /></id>
-    <discriminator type="char" column="CLASS_"/>
     <!-- V : org.jbpm.context.exe.VariableInstance -->
     <!-- B : org.jbpm.context.exe.variableinstance.ByteArrayInstance -->
     <!-- D : org.jbpm.context.exe.variableinstance.DateInstance -->
@@ -21,6 +20,7 @@
     <!-- S : org.jbpm.context.exe.variableinstance.StringInstance -->
     <!-- N : org.jbpm.context.exe.variableinstance.NullInstance -->
     <!-- J : org.jbpm.context.exe.variableinstance.JcrNodeInstance -->
+    <discriminator type="char" column="CLASS_"/>
     <version name="version" column="VERSION_" />
     
     <property name="name" column="NAME_"/>

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -11,14 +11,13 @@
          abstract="true" 
          discriminator-value="M">
     <id name="id" column="ID_"><generator class="native" /></id>
-    <discriminator type="char" column="CLASS_"/>
-    <version name="version" column="VERSION_" />
-
     <!-- M : org.jbpm.module.exe.ModuleInstance -->
     <!-- C : org.jbpm.context.exe.ContextInstance -->
     <!-- L : org.jbpm.logging.exe.LoggingInstance -->
     <!-- I : org.jbpm.scheduler.exe.SchedulerInstance -->
     <!-- T : org.jbpm.taskmgmt.def.TaskMgmtDefinition -->
+    <discriminator type="char" column="CLASS_"/>
+    <version name="version" column="VERSION_" />
     
     <many-to-one name="processInstance" 
                  column="PROCESSINSTANCE_"

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -21,10 +21,13 @@
  */
 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;
@@ -37,9 +40,12 @@
       jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
-        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
+        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext
             .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-        persistenceServiceFactory.getConfiguration().addClass(CustomLongClass.class);
+        Configuration configuration = persistenceServiceFactory.getConfiguration();
+        configuration.addClass(CustomLongClass.class);
+        JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+        jbpmSchema.updateSchema();
       }
       finally {
         jbpmContext.close();
@@ -71,7 +77,8 @@
       contextInstance = processInstance.getContextInstance();
 
       // get the custom hibernatable object from the variables
-      customLongObject = (CustomLongClass) contextInstance.getVariable("custom hibernate object");
+      customLongObject = (CustomLongClass) contextInstance
+          .getVariable("custom hibernate object");
       assertNotNull(customLongObject);
       assertEquals("customname", customLongObject.getName());
     }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -21,10 +21,13 @@
  */
 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;
@@ -37,9 +40,12 @@
       jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
-        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
+        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext
             .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
-        persistenceServiceFactory.getConfiguration().addClass(CustomStringClass.class);
+        Configuration configuration = persistenceServiceFactory.getConfiguration();
+        configuration.addClass(CustomStringClass.class);
+        JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+        jbpmSchema.updateSchema();
       }
       finally {
         jbpmContext.close();
@@ -71,7 +77,8 @@
       contextInstance = processInstance.getContextInstance();
 
       // get the custom hibernatable object from the variables
-      customStringObject = (CustomStringClass) contextInstance.getVariable("custom hibernate object");
+      customStringObject = (CustomStringClass) contextInstance
+          .getVariable("custom hibernate object");
       assertNotNull(customStringObject);
       assertEquals("customname", customStringObject.getName());
     }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -28,7 +28,6 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.net.URI;
 import java.net.URL;
@@ -37,9 +36,13 @@
 import org.hibernate.LockMode;
 
 import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
 import org.jbpm.JbpmException;
 import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.JbpmSchema;
 import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.persistence.db.DbPersistenceServiceFactory;
+import org.jbpm.svc.Services;
 
 /**
  * Verifies the join node can be persisted correctly.
@@ -52,10 +55,12 @@
     if (jbpmConfiguration == null) {
       URL cfgResource = getClass().getClassLoader().getResource("hibernate.cfg.xml");
       try {
-        OutputStream outStream = new FileOutputStream(new File(URI.create(cfgResource.toString())
+        InputStream cfgSource = cfgResource.openStream();
+        OutputStream cfgSink = new FileOutputStream(new File(URI.create(cfgResource.toString())
             .resolve("hibernate.join.cfg.xml")));
-        sed("Join\\.hbm\\.xml", "Join.lock.hbm.xml", cfgResource.openStream(), outStream);
-        outStream.close();
+        sed("Join\\.hbm\\.xml", "Join.lock.hbm.xml", cfgSource, cfgSink);
+        cfgSource.close();
+        cfgSink.close();
       }
       catch (IOException e) {
         throw new JbpmException("could not edit hibernate configuration", e);
@@ -63,6 +68,16 @@
       jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
           + "  <string name='resource.hibernate.cfg.xml' value='hibernate.join.cfg.xml' />"
           + "</jbpm-configuration>");
+
+      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+      try {
+        DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+        JbpmSchema jbpmSchema = new JbpmSchema(persistenceServiceFactory.getConfiguration());
+        jbpmSchema.updateSchema();
+      }
+      finally {
+        jbpmContext.close();
+      }
     }
     return jbpmConfiguration;
   }
@@ -75,13 +90,12 @@
   private static void sed(String regex, String replacement, InputStream inStream,
       OutputStream outStream) throws IOException {
     BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
-    PrintWriter writer = new PrintWriter(new OutputStreamWriter(outStream));
+    PrintWriter writer = new PrintWriter(outStream);
     Pattern pattern = Pattern.compile(regex);
     for (String inLine; (inLine = reader.readLine()) != null;) {
       String outLine = pattern.matcher(inLine).replaceAll(replacement);
       writer.println(outLine);
     }
-    reader.close();
     writer.flush();
   }
 

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm1071/JBPM1071Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm1071/JBPM1071Test.java	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm1071/JBPM1071Test.java	2009-10-04 22:16:32 UTC (rev 5683)
@@ -7,8 +7,10 @@
 import org.jbpm.JbpmContext;
 import org.jbpm.db.AbstractDbTestCase;
 import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.def.Node.NodeType;
 import org.jbpm.graph.exe.Comment;
 import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
 import org.jbpm.util.Semaphore;
 
 /**
@@ -84,7 +86,7 @@
   private List startThreads(Semaphore semaphore, long processInstanceId) {
     List threads = new ArrayList();
     for (int i = 0; i < nbrOfThreads; i++) {
-      Thread thread = new LockThread(semaphore, processInstanceId);
+      Thread thread = new Thread(new Signaller(semaphore, processInstanceId));
       threads.add(thread);
       thread.start();
     }
@@ -103,12 +105,12 @@
     }
   }
 
-  class LockThread extends Thread {
+  class Signaller implements Runnable {
 
     final Semaphore semaphore;
     final long processInstanceId;
 
-    public LockThread(Semaphore semaphore, long processInstanceId) {
+    Signaller(Semaphore semaphore, long processInstanceId) {
       this.semaphore = semaphore;
       this.processInstanceId = processInstanceId;
     }
@@ -125,26 +127,37 @@
 
       // after a thread is released (=notified), it will try to load the process instance,
       // signal it and then commit the transaction
-      JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
+      String threadName = Thread.currentThread().getName();
+      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
         ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+        Token rootToken = processInstance.getRootToken();
+
+        // check whether root token is still in start state
+        if (rootToken.getNode().getNodeType() != NodeType.StartState) {
+          jbpmContext.setRollbackOnly();
+          return;
+        }
+
+        // move to end state
         processInstance.signal();
-        jbpmContext.save(processInstance);
 
         // add a comment to see which thread won
-        Comment comment = new Comment(getName() + " committed");
-        jbpmContext.getSession().save(comment);
+        Comment comment = new Comment(threadName + " committed");
+        rootToken.addComment(comment);
+
+        jbpmContext.save(processInstance);
       }
       catch (RuntimeException e) {
         jbpmContext.setRollbackOnly();
-        log.debug(getName() + " rolled back", e);
+        log.debug(threadName + " rolled back", e);
       }
       finally {
         try {
           jbpmContext.close();
         }
         catch (RuntimeException e) {
-          log.debug(getName() + " failed to close its jbpm context", e);
+          log.debug(threadName + " failed to close jbpm context", e);
         }
       }
     }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -36,11 +36,11 @@
     <priority value="INFO" />
   </category>
 
+  <!--
   <category name="org.hibernate.SQL">
     <priority value="DEBUG" />
   </category>
 
-  <!--
   <category name="org.hibernate.type">
     <priority value="TRACE" />
   </category>

Modified: jbpm3/branches/jbpm-3.2-soa/modules/distribution/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/distribution/pom.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/distribution/pom.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -107,6 +107,8 @@
       <artifactId>jbpm-jpdl-designer-site</artifactId>
       <type>zip</type>
     </dependency>
+
+    <!-- Sources -->
     <dependency>
       <groupId>org.jbpm.jbpm3</groupId>
       <artifactId>jbpm-enterprise</artifactId>
@@ -125,6 +127,8 @@
       <classifier>sources</classifier>
       <version>${project.version}</version>
     </dependency>
+
+    <!-- Javadoc -->
     <dependency>
       <groupId>org.jbpm.jbpm3</groupId>
       <artifactId>jbpm-enterprise</artifactId>
@@ -143,10 +147,14 @@
       <classifier>javadoc</classifier>
       <version>${project.version}</version>
     </dependency>
+
+    <!-- Thirdparty Dependencies -->
     <dependency>
       <groupId>org.apache.ant</groupId>
       <artifactId>ant</artifactId>
     </dependency>
+
+    <!-- Database Drivers -->
     <dependency>
       <groupId>hsqldb</groupId>
       <artifactId>hsqldb</artifactId>
@@ -159,14 +167,6 @@
       <groupId>postgresql</groupId>
       <artifactId>postgresql</artifactId>
     </dependency>
-
-    <!-- Sources -->
-
-    <!-- Javadoc -->
-
-    <!-- Thirdparty Dependencies -->
-
-    <!-- Database Drivers -->
   </dependencies>
 
   <!-- Plugins -->
@@ -204,16 +204,15 @@
             </goals>
             <configuration>
               <tasks>
-                <property name="project.version" value="${project.version}" />
-                <property name="project.build.dir" value="${project.build.directory}" />
-                <property name="project.build.assembly.resources"
-                  value="${project.build.assemblyDirectory}/resources" />
-                <property name="resources.dir" value="${resources.directory}" />
-                <property name="resources.output.dir" value="${resources.outputDirectory}" />
-                <property name="container" value="${container}" />
-                <property name="jboss.home" value="${jboss.home}" />
-                <property name="database" value="${database}" />
-                <ant antfile="scripts/antrun-installer.xml" target="process-resources" />
+                <property name="project.version" value="${project.version}"/>
+                <property name="project.build.dir" value="${project.build.directory}"/>
+                <property name="project.build.assembly.resources" value="${project.build.assemblyDirectory}/resources"/>
+                <property name="resources.dir" value="${resources.directory}"/>
+                <property name="resources.output.dir" value="${resources.outputDirectory}"/>
+                <property name="container" value="${container}"/>
+                <property name="jboss.home" value="${jboss.home}"/>
+                <property name="database" value="${database}"/>
+                <ant antfile="scripts/antrun-installer.xml" target="process-resources"/>
               </tasks>
             </configuration>
           </execution>
@@ -252,6 +251,7 @@
           <type>war</type>
         </dependency>
       </dependencies>
+
       <build>
         <plugins>
           <plugin>
@@ -266,10 +266,11 @@
                 <configuration>
                   <tasks>
                     <!-- replace jsf-console.war with the SOA platform build -->
-                    <property name="project.build.assembly.lib" value="${project.build.assemblyDirectory}/lib" />
+                    <property name="project.build.assembly.lib" value="${project.build.assemblyDirectory}/lib"/>
                     <echo>**** Replacing jsf-console with SOA-P build ****</echo>
-                    <copy file="${project.build.assembly.lib}/jsf-console-soa.war" tofile="${project.build.assembly.lib}/jsf-console.war"
-                      overwrite="yes" />
+                    <copy file="${project.build.assembly.lib}/jsf-console-soa.war"
+                      tofile="${project.build.assembly.lib}/jsf-console.war"
+                      overwrite="yes"/>
                   </tasks>
                 </configuration>
               </execution>

Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/pom.xml	2009-10-04 15:43:28 UTC (rev 5682)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/pom.xml	2009-10-04 22:16:32 UTC (rev 5683)
@@ -232,7 +232,7 @@
 
     <!-- 
       Name:  no-database
-      Descr: Setup the default database   
+      Description: Default database test exclusions
     -->
     <profile>
       <id>no-database</id>
@@ -261,7 +261,7 @@
 
     <!-- 
       Name:  hsqldb
-      Descr: Hypersonic Database Setup   
+      Description: HSQLDB test exclusions
     -->
     <profile>
       <id>hsqldb</id>



More information about the jbpm-commits mailing list