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

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Sep 2 10:53:51 EDT 2010


Author: rebody
Date: 2010-09-02 10:53:46 -0400 (Thu, 02 Sep 2010)
New Revision: 6647

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/OptimisticLockingException.java
Modified:
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java
   jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java
Log:
JBPM-2927 remove staleStateException from retryInterceptor and DatabaseDbidGenerator.  replace org.hibernate.Session to DbSession in PropertyImpl.

Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Create.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -28,6 +28,7 @@
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cfg.ConfigurationImpl;
 import org.jbpm.pvm.internal.id.PropertyImpl;
+import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Alejandro Guizar
@@ -53,8 +54,9 @@
 
         public Void execute(Environment environment) throws Exception {
           Session session = environment.get(Session.class);
+          DbSession dbSession = environment.get(DbSession.class);
           DbHelper.executeSqlResource("create/jbpm." + database + ".create.sql", session);
-          PropertyImpl.createProperties(session);
+          PropertyImpl.createProperties(dbSession);
           return null;
         }
       });

Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/Upgrade.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -109,6 +109,7 @@
     }
 
     public JbpmVersion execute(Environment environment) throws Exception {
+      DbSession dbSession = environment.get(DbSession.class);
       Session session = environment.get(Session.class);
       if (!propertiesTableExists) {
         try {
@@ -120,7 +121,7 @@
         }
       }
       else {
-        String dbVersion = PropertyImpl.getDbVersion(session);
+        String dbVersion = PropertyImpl.getDbVersion(dbSession);
         if (dbVersion == null) {
           throw new JbpmException("property table exists, but no db version property is present");
         }
@@ -145,6 +146,7 @@
     }
 
     protected void executeVoid(Environment environment) throws Exception {
+      DbSession dbSession = environment.get(DbSession.class);
       Session session = environment.get(Session.class);
 
       log.info("upgrading from " + databaseVersion + " to "
@@ -161,9 +163,9 @@
         // in that case, the next part is skipped
         if (!propertiesTableExists) {
           DbHelper.executeSqlResource("upgrade-4.1-to-4.2/jbpm." + database + ".upgrade.sql", session);
-          PropertyImpl.initializeNextDbid(session);
+          PropertyImpl.initializeNextDbid(dbSession);
           // we set the version to 4.1 as the next transaction might fail
-          PropertyImpl.setDbVersionTo41(session);
+          PropertyImpl.setDbVersionTo41(dbSession);
         }
       }
       // transaction is now committed as the next transaction requires the NextDbid
@@ -182,6 +184,7 @@
     }
 
     protected void executeVoid(Environment environment) throws Exception {
+      DbSession dbSession = environment.get(DbSession.class);
       Session session = environment.get(Session.class);
 
       if (databaseVersion.compareTo(JbpmVersion.V_4_2) < 0) {
@@ -196,7 +199,7 @@
         }
       }
 
-      PropertyImpl.setDbVersionToLibraryVersion(session);
+      PropertyImpl.setDbVersionToLibraryVersion(dbSession);
     }
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.pvm.internal.cmd;
 
-import org.hibernate.Session;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
@@ -43,7 +42,6 @@
 
   public Object execute(Environment environment) throws Exception {
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-    Session session = EnvironmentImpl.getFromCurrent(Session.class);
 
     // if table JBPM4_PROPERTIES doesn't exist,
     if (!dbSession.propertiesTableExists()) {
@@ -57,17 +55,17 @@
       }
 
     } else {
-      Long nextDbid = PropertyImpl.getNextDbid(session);
+      Long nextDbid = PropertyImpl.getNextDbid(dbSession);
       // if there is no next.dbid property specified
       if (nextDbid == null) {
         // (this only happens in the test suite)
         // initialize the dbid property.
-        PropertyImpl.setNextDbid(session, 1);
+        PropertyImpl.setNextDbid(dbSession, 1);
       }
     }
 
     // verify if DB version matches with library version,
-    String dbVersion = PropertyImpl.getDbVersion(session);
+    String dbVersion = PropertyImpl.getDbVersion(dbSession);
     if (log.isInfoEnabled()) {
       log.info("jBPM version info: library[" + ProcessEngineImpl.JBPM_LIBRARY_VERSION + "], schema[" + dbVersion + "]");
     }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -1,10 +1,8 @@
 package org.jbpm.pvm.internal.id;
 
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
-
 import org.jbpm.api.cmd.Command;
 import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Tom Baeyens
@@ -20,17 +18,14 @@
   }
 
   public Long execute(Environment environment) throws Exception {
-    Session session = environment.get(Session.class);
+    DbSession dbSession = environment.get(DbSession.class);
 
-    PropertyImpl property = (PropertyImpl) session.createCriteria(PropertyImpl.class)
-      .add(Restrictions.eq("key", PropertyImpl.NEXT_DBID_KEY))
-      .uniqueResult();
-
+    PropertyImpl property = PropertyImpl.getProperty(dbSession, PropertyImpl.NEXT_DBID_KEY);
     long nextId = Long.parseLong(property.getValue());
     property.setValue(Long.toString(nextId + blocksize));
 
-    session.flush();
+    dbSession.flush();
 
     return nextId;
   }
-}
\ No newline at end of file
+}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -23,7 +23,6 @@
 
 import java.util.Random;
 
-import org.hibernate.StaleStateException;
 import org.jbpm.api.JbpmException;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cmd.CommandService;
@@ -33,9 +32,9 @@
  * @author Tom Baeyens
  */
 public class DatabaseDbidGenerator extends DbidGenerator {
-  
+
   private static Log log = Log.getLog(DatabaseDbidGenerator.class.getName());
-  
+
   static Random random = new Random();
 
   // configuration
@@ -43,22 +42,26 @@
   long blocksize = 10000;
   int maxAttempts = 3;
 
-  // runtime state  
+  // runtime state
   long lastId = -2;
   long nextId = -1;
-  
+
+  protected Class<?> targetExceptionClass;
+
   public synchronized long getNextId() {
     // if no more ids available
-    if (lastId<nextId) {
+    if (lastId < nextId) {
       // acquire a next block of ids
 
-      log.debug("last id "+lastId+" was consumed.  acquiring new block...");
+      if (log.isDebugEnabled()) {
+        log.debug("last id " + lastId + " was consumed.  acquiring new block...");
+      }
 
       // reset the id block
       lastId = -2;
       nextId = -1;
-      
-      // try couple of times 
+
+      // try couple of times
       try {
         acquireDbidBlock();
       } catch (Exception e) {
@@ -72,26 +75,34 @@
   protected void acquireDbidBlock() {
     for ( int attempts = maxAttempts; (attempts>0) && (nextId==-1) ; attempts-- ) {
       try {
-        // acquire block 
+        // acquire block
         nextId = commandService.execute(new AcquireDbidBlockCmd(blocksize));
         lastId = nextId + blocksize - 1;
-        
-        log.debug("acquired new id block ["+nextId+"-"+lastId+"]");
-        
-      } catch (StaleStateException e) {
-        // optimistic locking exception indicating another thread tried to 
-        // acquire a block of ids concurrently  
+
+        if (log.isDebugEnabled()) {
+          log.debug("acquired new id block [" + nextId + "-" + lastId + "]");
+        }
+
+      } catch (RuntimeException ex) {
+        if (!this.isCausedByOptimisticLockingFailure(ex)) {
+          throw ex;
+        }
+
+        // optimistic locking exception indicating another thread tried to
+        // acquire a block of ids concurrently
         attempts--;
-        
+
         // if no attempts left
-        if (attempts==0) {
+        if (attempts == 0) {
           // fail the surrounding transaction
-          throw new JbpmException("couldn't acquire block of ids, tried "+maxAttempts+" times");
+          throw new JbpmException("couldn't acquire block of ids, tried " + maxAttempts + " times");
         }
-        
+
         // if there are still attempts left, first wait a bit
         int millis = 20 + random.nextInt(200);
-        log.debug("optimistic locking failure while trying to acquire id block.  retrying in "+millis+" millis");
+        if (log.isDebugEnabled()) {
+          log.debug("optimistic locking failure while trying to acquire id block.  retrying in " + millis + " millis");
+        }
         try {
           Thread.sleep(millis);
         } catch (InterruptedException e1) {
@@ -100,14 +111,40 @@
       }
     }
   }
-  
+
+  /**
+   * fix for JBPM-2864.
+   * If this exception is caused by StaleStateException, then we should retry.
+   */
+  protected boolean isCausedByOptimisticLockingFailure(
+      Throwable throwable) {
+    if (targetExceptionClass == null) {
+      log.warn("didnot config a targetExceptionClass, won't retry.");
+      return false;
+    }
+
+    while (throwable != null) {
+      if (targetExceptionClass.isAssignableFrom(throwable.getClass())) {
+        return true;
+      } else {
+        throwable = throwable.getCause();
+      }
+    }
+
+    return false;
+  }
+
   public void reset() {
     initialize(); // resetting the DatabaseIdGenerator means just reinitializing the id
   }
-  
+
   public void initialize() {
     nextId = commandService.execute(new InitializePropertiesCmd(blocksize));
     lastId = nextId + blocksize - 1;
     log.debug("initial id block ["+nextId+"-"+lastId+"]");
   }
+
+  public void setTargetExceptionClass(Class<?> targetExceptionClass) {
+    this.targetExceptionClass = targetExceptionClass;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -21,8 +21,6 @@
  */
 package org.jbpm.pvm.internal.id;
 
-import org.hibernate.Session;
-
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
@@ -55,68 +53,67 @@
     this.value = value;
   }
 
-  public static Long getNextDbid(Session session) {
-    String dbidPropertyValue = getPropertyValue(session, PropertyImpl.NEXT_DBID_KEY);
+  public static Long getNextDbid(DbSession dbSession) {
+    String dbidPropertyValue = getPropertyValue(dbSession, PropertyImpl.NEXT_DBID_KEY);
     if (dbidPropertyValue != null) {
       return Long.valueOf(dbidPropertyValue);
     }
     return null;
   }
 
-  public static void setNextDbid(Session session, long nextDbid) {
-    setPropertyValue(session, PropertyImpl.NEXT_DBID_KEY, Long.toString(nextDbid));
+  public static void setNextDbid(DbSession dbSession, long nextDbid) {
+    setPropertyValue(dbSession, PropertyImpl.NEXT_DBID_KEY, Long.toString(nextDbid));
   }
 
-  public static String getDbVersion(Session session) {
-    String dbVersionPropertyValue = getPropertyValue(session, PropertyImpl.DB_VERSION_KEY);
+  public static String getDbVersion(DbSession dbSession) {
+    String dbVersionPropertyValue = getPropertyValue(dbSession, PropertyImpl.DB_VERSION_KEY);
     if (dbVersionPropertyValue != null) {
       return dbVersionPropertyValue;
     }
     return null;
   }
 
-  public static void setDbVersionToLibraryVersion(Session session) {
-    setPropertyValue(session, PropertyImpl.DB_VERSION_KEY, ProcessEngineImpl.JBPM_LIBRARY_VERSION);
+  public static void setDbVersionToLibraryVersion(DbSession dbSession) {
+    setPropertyValue(dbSession, PropertyImpl.DB_VERSION_KEY, ProcessEngineImpl.JBPM_LIBRARY_VERSION);
   }
 
-  public static void createProperties(Session session) {
-    setDbVersionToLibraryVersion(session);
-    setNextDbid(session, 1);
+  public static void createProperties(DbSession dbSession) {
+    setDbVersionToLibraryVersion(dbSession);
+    setNextDbid(dbSession, 1);
   }
 
-  public static void initializeNextDbid(Session session) {
-    DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
+  public static void initializeNextDbid(DbSession dbSession) {
     long nextDbid = dbSession.getMaxDbid() + 1;
-    setNextDbid(session, nextDbid);
+    setNextDbid(dbSession, nextDbid);
     if (log.isInfoEnabled()) {
       log.info("nextDbid is initialized to " + nextDbid);
     }
   }
 
-  protected static String getPropertyValue(Session session, String propertyKey) {
-    PropertyImpl dbidProperty = getProperty(session, propertyKey);
+  protected static String getPropertyValue(DbSession dbSession, String propertyKey) {
+    PropertyImpl dbidProperty = getProperty(dbSession, propertyKey);
     if (dbidProperty == null) {
       return null;
     }
     return dbidProperty.getValue();
   }
 
-  protected static void setPropertyValue(Session session, String propertyKey, String propertyValue) {
-    PropertyImpl property = getProperty(session, propertyKey);
+  protected static void setPropertyValue(DbSession dbSession, String propertyKey, String propertyValue) {
+    PropertyImpl property = getProperty(dbSession, propertyKey);
     if (property == null) {
       property = new PropertyImpl(propertyKey, propertyValue);
-      session.save(property);
+      dbSession.save(property);
     } else {
       property.setValue(propertyValue);
     }
   }
 
-  protected static PropertyImpl getProperty(Session session, String key) {
-    return (PropertyImpl) session.get(PropertyImpl.class, key);
+  protected static PropertyImpl getProperty(DbSession dbSession, String key) {
+    return (PropertyImpl) dbSession.get(PropertyImpl.class, key);
   }
 
-  public static void setDbVersionTo41(Session session) {
-    setPropertyValue(session, DB_VERSION_KEY, "4.1");
+  public static void setDbVersionTo41(DbSession dbSession) {
+    setPropertyValue(dbSession, DB_VERSION_KEY, "4.1");
   }
 
   // getters and setters //////////////////////////////////////////////////////

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -25,8 +25,6 @@
 import org.jbpm.api.cmd.Command;
 import org.jbpm.internal.log.Log;
 
-import org.hibernate.StaleStateException;
-
 /** retries the command execution in case hibernate throws optimistic locking
  * (StaleObjectException) exceptions.
  *
@@ -41,14 +39,16 @@
   long delay = 50;
   long delayFactor = 4;
 
+  protected Class<?> targetExceptionClass;
+
   public <T> T execute(Command<T> command) {
 
     // TODO JBPM-2196 unify the retry code with the JtaTransactionInterceptor
 
     int attempt = 1;
     long sleepTime = delay;
-    while (attempt<=retries) {
-      if (attempt>1) {
+    while (attempt <= retries) {
+      if (attempt > 1) {
         log.trace("retrying...");
       }
       try {
@@ -83,8 +83,13 @@
    */
   protected boolean isCausedByOptimisticLockingFailure(
       Throwable throwable) {
+    if (targetExceptionClass == null) {
+      log.warn("didnot config a targetExceptionClass, the retryInterceptor is disabled.");
+      return false;
+    }
+
     while (throwable != null) {
-      if (throwable instanceof StaleStateException) {
+      if (targetExceptionClass.isAssignableFrom(throwable.getClass())) {
         return true;
       } else {
         throwable = throwable.getCause();
@@ -112,4 +117,8 @@
   public void setDelayFactor(long delayFactor) {
     this.delayFactor = delayFactor;
   }
+
+  public void setTargetExceptionClass(Class<?> targetExceptionClass) {
+    this.targetExceptionClass = targetExceptionClass;
+  }
 }

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/OptimisticLockingException.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/OptimisticLockingException.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/OptimisticLockingException.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.api.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class OptimisticLockingException extends JbpmException {
+
+  private static final long serialVersionUID = 1L;
+
+  public OptimisticLockingException(String message) {
+    super(message);
+  }
+
+  public OptimisticLockingException(String message, Throwable cause) {
+    super(message, cause);
+  }
+}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.pvm.internal.wire.binding;
 
+import org.hibernate.StaleStateException;
 import org.jbpm.pvm.internal.svc.RetryInterceptor;
 import org.jbpm.pvm.internal.tx.JtaRetryInterceptor;
 import org.jbpm.pvm.internal.util.XmlUtil;
@@ -30,7 +31,7 @@
 import org.w3c.dom.Element;
 
 /** parses a descriptor for creating a {@link RetryInterceptor}.
- * 
+ *
  * See schema docs for more details.
  *
  * @author Tom Baeyens
@@ -43,15 +44,16 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     RetryInterceptor retryInterceptor = null;
-    
+
     String type = XmlUtil.attribute(element, "type");
     if ("jta".equals(type)) {
       retryInterceptor = new JtaRetryInterceptor();
     } else {
       retryInterceptor = new RetryInterceptor();
+      retryInterceptor.setTargetExceptionClass(StaleStateException.class);
     }
-    
-    
+
+
     if (element.hasAttribute("retries")) {
       String retriesText = element.getAttribute("retries");
       try {

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2010-09-02 14:53:46 UTC (rev 6647)
@@ -6,7 +6,7 @@
   <import resource="jbpm.mail.templates.xml" />
 
   <process-engine-context>
-  
+
     <repository-service />
     <repository-cache />
     <execution-service />
@@ -16,30 +16,31 @@
     <task-service />
 
     <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
+      <field name="targetExceptionClass"><class class-name="org.hibernate.StaleStateException" /></field>
       <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
     </object>
 
     <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
-    
+
     <object class="org.jbpm.pvm.internal.el.JbpmElFactoryImpl" />
 
     <types resource="jbpm.variable.types.xml" />
 
     <address-resolver />
- 
+
   </process-engine-context>
 
   <transaction-context>
     <repository-session />
     <db-session />
-    
+
     <message-session />
     <timer-session />
-    
+
     <history-sessions>
       <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" />
     </history-sessions>
-    
+
     <mail-session>
       <mail-server>
         <session-properties resource="jbpm.mail.properties" />

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -36,16 +36,16 @@
  * @author Tom Baeyens
  */
 public class DbidGeneratorTest extends TestCase {
-  
+
   private static Log log = Log.getLog(DbidGeneratorTest.class.getName());
-  
+
   public void testDbidGenerator() {
     ProcessEngine processEngine = new Configuration().buildProcessEngine();
-    
+
     DbidGenerator dbidGenerator = processEngine.get(DbidGenerator.class);
-    
+
     assertEquals(1, dbidGenerator.getNextId());
-    
+
     processEngine.execute(new Command<Void>() {
       private static final long serialVersionUID = 1L;
       public Void execute(Environment environment) throws Exception {
@@ -57,7 +57,7 @@
         return null;
       }
     });
-    
+
     for (int i=2; i<10020; i++) {
       assertEquals(i, dbidGenerator.getNextId());
       if ((i%1000) == 0) {
@@ -76,7 +76,7 @@
               log.debug("just got dbid "+i+"...");
             }
           }
-          // the following 'user' exception will cause the user transaction to 
+          // the following 'user' exception will cause the user transaction to
           // roll back, but the dbid-transaction should have been committed
           throw new RuntimeException("user exception");
         }
@@ -104,7 +104,7 @@
               log.debug("just got dbid "+i+"...");
             }
           }
-          // the following 'user' exception will cause the user transaction to 
+          // the following 'user' exception will cause the user transaction to
           // roll back, but the dbid-transaction should have been committed
           throw new RuntimeException("user exception");
         }

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java	2010-09-02 12:32:06 UTC (rev 6646)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java	2010-09-02 14:53:46 UTC (rev 6647)
@@ -45,11 +45,13 @@
 
   public void testShouldRetryStaleStateException() {
     RetryInterceptor retryInterceptor = new RetryInterceptor();
+    retryInterceptor.setTargetExceptionClass(StaleStateException.class);
     assertTrue(retryInterceptor.isCausedByOptimisticLockingFailure(new StaleStateException("test")));
   }
 
   public void testShouldRetry() {
     RetryInterceptor retryInterceptor = new RetryInterceptor();
+    retryInterceptor.setTargetExceptionClass(StaleStateException.class);
     assertTrue(retryInterceptor.isCausedByOptimisticLockingFailure(
         new HibernateOptimisticLockingFailureException(new StaleStateException("test"))
     ));



More information about the jbpm-commits mailing list