[jbpm-commits] JBoss JBPM SVN: r2549 - in jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm: db and 11 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Oct 16 03:37:21 EDT 2008


Author: alex.guizar at jboss.com
Date: 2008-10-16 03:37:21 -0400 (Thu, 16 Oct 2008)
New Revision: 2549

Modified:
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/JbpmConfiguration.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/db/JobSession.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/graph/node/Join.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/Timer.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutor.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmVariableResolver.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/parser/ELParserTokenManager.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/msg/db/DbMessageService.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/SchedulerService.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/db/DbSchedulerService.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/svc/Services.java
Log:
merged revisions 1471, 1580, 1595, 1937, 2034, 2134 and 2185 from https://svn.jboss.org/repos/jbpm/jbpm3/trunk/modules/core/src/main/java

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/JbpmConfiguration.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/JbpmConfiguration.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -278,12 +278,13 @@
             log.info("using jbpm configuration resource '"+resource+"'");
             InputStream jbpmCfgXmlStream = ClassLoaderUtil.getStream(resource);
 
-            // if a resource SHOULD BE used, but is not found in the classpath
-            // throw exception (otherwise, the user wants to load own stuff
-            // but is confused, if it is not found and not loaded, without
+            // 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)
-              throw new JbpmException("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);

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/db/JobSession.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/db/JobSession.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -2,12 +2,10 @@
 
 import java.util.Collection;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hibernate.LockMode;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.jbpm.JbpmContext;
@@ -90,21 +88,14 @@
     if (job instanceof Timer) {
       Timer timer = (Timer) job;
       Action action = timer.getAction();
-      if ( (action!=null) 
-           && (! session.contains(action))
-         ) {
-        log.debug("cascading timer save to timer action");
+      if (action != null && !session.contains(action)) {
+        log.debug("cascading timer save to action");
         session.save(action);
       }
     }
   }
 
-  public void reattachUnmodifiedJob(Job job) {
-    session.lock(job, LockMode.NONE);
-  }
-
   public void deleteJob(Job job) {
-    log.debug("deleting "+job);
     session.delete(job);
   }
 
@@ -117,6 +108,14 @@
     }
   }
 
+  public Timer loadTimer(long timerId) {
+    try {
+      return (Timer) session.load(Timer.class, new Long(timerId));
+    } catch (Exception e) {
+      log.error(e);
+      throw new JbpmException("couldn't load timer " + timerId, e);
+    }
+  }
 
   public Job getJob(long jobId) {
     try {
@@ -151,17 +150,17 @@
     }
   }
 
-  public void cancelTimersByName(String name, Token token) {
+  public void deleteTimersByName(String name, Token token) {
     try {
-      log.debug("canceling timers by name " + name + " for " + token);
+      log.debug("deleting timers by name '" + name + "' for " + token);
       Query query = session.getNamedQuery("JobSession.deleteTimersByName");
       query.setString("name", name);
       query.setParameter("token", token);
       int entityCount = query.executeUpdate();
-      log.debug(entityCount+" timers by name " + name + " for " + token + " were deleted");
+      log.debug(entityCount + " timers by name '" + name + "' for " + token + " were deleted");
     } catch (Exception e) {
       log.error(e);
-      throw new JbpmException("couldn't cancel timers by name '"+name+"' for '"+token+"'", e);
+      throw new JbpmException("couldn't delete timers by name '" + name + "' for " + token, e);
     }
   }
 

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/graph/node/Join.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/graph/node/Join.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/graph/node/Join.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -112,7 +112,8 @@
             lockMode = LockMode.parse(parentLockMode);
           }
           log.debug("forcing version increment on parent token "+parentToken);
-          session.flush();
+          // TODO why is a flush needed?!
+          // session.flush();
           session.lock(parentToken, lockMode);
         }
 

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/Timer.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/Timer.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -103,10 +103,8 @@
   }
   
   public String toString() {
-    StringBuffer buffer = new StringBuffer();
-    buffer.append("timer");
-    if ( (name!=null) || (dueDate!=null)) {
-
+    StringBuffer buffer = new StringBuffer("Timer");
+    if (name != null || dueDate != null) {
       buffer.append("(");
       if (name!=null) {
         buffer.append(name).append(",");

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutor.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutor.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -2,6 +2,7 @@
 
 import java.io.Serializable;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -35,19 +36,20 @@
   Map monitoredJobIds = Collections.synchronizedMap(new HashMap());
 
   boolean isStarted = false;
-  
+
+  private static String hostName;
+
   public synchronized void start() {
     if (! isStarted) {
       log.debug("starting thread group '"+name+"'...");
       for (int i=0; i<nbrOfThreads; i++) {
         startThread();
       }
+      lockMonitorThread = new LockMonitorThread(jbpmConfiguration, lockMonitorInterval, maxLockTime, lockBufferTime);
       isStarted = true;
     } else {
       log.debug("ignoring start: thread group '"+name+"' is already started'");
     }
-    
-    lockMonitorThread = new LockMonitorThread(jbpmConfiguration, lockMonitorInterval, maxLockTime, lockBufferTime);
   }
   
   /**
@@ -65,6 +67,7 @@
       for (int i=0; i<nbrOfThreads; i++) {
         stoppedThreads.add(stopThread());
       }
+      lockMonitorThread.deactivate();
       isStarted = false;
     } else {
       log.debug("ignoring stop: thread group '"+name+"' not started");
@@ -78,6 +81,7 @@
       Thread thread = (Thread) iter.next();
       thread.join();
     }
+    lockMonitorThread.join();
   }
 
   protected synchronized void startThread() {
@@ -99,12 +103,15 @@
     return name + ":" + getHostName() + ":" + index;
   }
 
-  private String getHostName() {
-    try {
-      return InetAddress.getLocalHost().getHostAddress();
-    } catch (Exception e) {
-      return "unknown";
+  private static String getHostName() {
+    if (hostName == null) {
+      try {
+        hostName = InetAddress.getLocalHost().getHostAddress();
+      } catch (UnknownHostException e) {
+        hostName = "127.0.0.1";
+      }      
     }
+    return hostName;
   }
 
   protected synchronized Thread stopThread() {

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -10,14 +10,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hibernate.Hibernate;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
 import org.jbpm.db.JobSession;
+import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.job.Job;
-import org.jbpm.job.Timer;
 import org.jbpm.persistence.JbpmPersistenceException;
-import org.jbpm.persistence.db.StaleObjectLogConfigurer;
 import org.jbpm.svc.Services;
 
 public class JobExecutorThread extends Thread {
@@ -100,35 +98,38 @@
     Collection acquiredJobs;
     synchronized (jobExecutor) {
       log.debug("acquiring jobs for execution...");
-      Collection jobsToLock = Collections.EMPTY_LIST;
+      List jobsToLock = Collections.EMPTY_LIST;
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
         JobSession jobSession = jbpmContext.getJobSession();
+        String lockOwner = getName();
         log.debug("querying for acquirable job...");
-        Job job = jobSession.getFirstAcquirableJob(getName());
+        Job job = jobSession.getFirstAcquirableJob(lockOwner);
         if (job!=null) {
           if (job.isExclusive()) {
-            log.debug("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
-            List otherExclusiveJobs = jobSession.findExclusiveJobs(getName(), job.getProcessInstance());
-            jobsToLock = otherExclusiveJobs;
-            log.debug("trying to obtain a process-instance exclusive locks for '"+otherExclusiveJobs+"'");
+            log.debug("found exclusive " + job);
+            ProcessInstance processInstance = job.getProcessInstance();
+            log.debug("finding other exclusive jobs for " + processInstance);
+            jobsToLock = jobSession.findExclusiveJobs(lockOwner, processInstance);
+            log.debug("trying to obtain exclusive locks on " + jobsToLock + " for " + processInstance);
           } else {
-            log.debug("trying to obtain a lock for '"+job+"'");
+            log.debug("trying to obtain lock on " + job);
             jobsToLock = Collections.singletonList(job);
           }
           
-          Iterator iter = jobsToLock.iterator();
-          while (iter.hasNext()) {
+          Date lockTime = new Date();
+          for (Iterator iter = jobsToLock.iterator(); iter.hasNext();) {
             job = (Job) iter.next();
-            job.setLockOwner(getName());
-            job.setLockTime(new Date());
+            job.setLockOwner(lockOwner);
+            job.setLockTime(lockTime);
             // jbpmContext.getSession().update(job);
           }
 
           // HACKY HACK : this is a workaround for a hibernate problem that is fixed in hibernate 3.2.1
-          if (job instanceof Timer) {
-            Hibernate.initialize(((Timer)job).getGraphElement());
-          }
+          // TODO remove this hack already?
+          // if (job instanceof Timer) {
+          //   Hibernate.initialize(((Timer)job).getGraphElement());
+          // }
         } else {
           log.debug("no acquirable jobs in job table");
         }
@@ -141,7 +142,7 @@
         catch (JbpmPersistenceException e) {
           // if this is a stale object exception, keep it quiet
           if (Services.isCausedByStaleState(e)) {
-            log.debug("optimistic locking failed, couldn't obtain lock on jobs: "+jobsToLock);
+            log.debug("optimistic locking failed, couldn't obtain lock on jobs "+jobsToLock);
             acquiredJobs = Collections.EMPTY_LIST;
           } else {
             throw e;
@@ -159,15 +160,15 @@
       job = jobSession.loadJob(job.getId());
 
       try {
-        log.debug("executing job "+job);
+        log.debug("executing " + job);
         if (job.execute(jbpmContext)) {
           jobSession.deleteJob(job);
         }
       } catch (Exception e) {
-        log.debug("exception while executing '"+job+"'", e);
-        StringWriter sw = new StringWriter();
-        e.printStackTrace(new PrintWriter(sw));
-        job.setException(sw.toString());
+        log.debug("exception while executing " + job, e);
+        StringWriter memoryWriter = new StringWriter();
+        e.printStackTrace(new PrintWriter(memoryWriter));
+        job.setException(memoryWriter.toString());
         job.setRetries(job.getRetries()-1);
       }
       
@@ -180,13 +181,10 @@
       try {
         jbpmContext.close();
       } catch (JbpmPersistenceException e) {
-        // if this is a stale object exception, the jbpm configuration has control over the logging
-        if ("org.hibernate.StaleObjectStateException".equals(e.getCause().getClass().getName())) {
-          log.info("problem committing job execution transaction: optimistic locking failed");
-          StaleObjectLogConfigurer.staleObjectExceptionsLog.error("problem committing job execution transaction: optimistic locking failed", e);
+        // if this is a stale object exception, keep it quiet
+        if (Services.isCausedByStaleState(e)) {
+          log.debug("optimistic locking failed, couldn't complete job "+job);
         } else {
-          // TODO run() will log this exception, log it here too?
-          log.error("problem committing job execution transaction", e);
           throw e;
         }
       }
@@ -204,7 +202,17 @@
         jobExecutor.addMonitoredJobId(getName(), job.getId());
       }
     } finally {
-      jbpmContext.close();
+      try {
+        jbpmContext.close();
+      } catch (JbpmPersistenceException e) {
+        // if this is a stale object exception, keep it quiet
+        if (Services.isCausedByStaleState(e)) {
+          log.debug("optimistic locking failed, couldn't get next due date");
+          nextDueDate = null;
+        } else {
+          throw e;
+        }
+      }
     }
     return nextDueDate;
   }
@@ -213,10 +221,10 @@
     long interval = currentIdleInterval;
     Date nextDueDate = getNextDueDate();
     if (nextDueDate!=null) {
-      long currentTimeMillis = System.currentTimeMillis();
-      long nextDueDateTime = nextDueDate.getTime();
-      if (nextDueDateTime < currentTimeMillis+currentIdleInterval) {
-        interval = nextDueDateTime-currentTimeMillis;
+      long currentTime = System.currentTimeMillis();
+      long nextDueTime = nextDueDate.getTime();
+      if (nextDueTime < currentTime+currentIdleInterval) {
+        interval = nextDueTime-currentTime;
       }
     }
     if (interval<0) {
@@ -234,7 +242,8 @@
   }
 
   /**
-   * Signals this thread to stop running. Execution should cease shortly afterwards.
+   * Indicates that this thread should stop running.
+   * Execution will cease shortly afterwards.
    */
   public void deactivate() {
     if (isActive) {

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/LockMonitorThread.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/job/executor/LockMonitorThread.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -10,6 +10,8 @@
 import org.jbpm.JbpmContext;
 import org.jbpm.db.JobSession;
 import org.jbpm.job.Job;
+import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.svc.Services;
 
 public class LockMonitorThread extends Thread {
   
@@ -76,16 +78,35 @@
     } finally {
       try {
         jbpmContext.close();
-      } catch (RuntimeException e) {
-        log.error("problem committing job execution transaction", e);
-        throw e;
+      } catch (JbpmPersistenceException e) {
+        // if this is a stale object exception, keep it quiet
+        if (Services.isCausedByStaleState(e)) {
+          log.debug("optimistic locking failed, couldn't unlock overdue jobs");
+        } else {
+          throw e;
+        }
       }
     }
   }
 
+  /**
+   * @deprecated As of jBPM 3.2.3, replaced by {@link #deactivate()}
+   */
   public void setActive(boolean isActive) {
-    this.isActive = isActive;
+    if (isActive == false) 
+      deactivate();
   }
 
+  /**
+   * Indicates that this thread should stop running.
+   * Execution will cease shortly afterwards.
+   */
+  public void deactivate() {
+    if (isActive) {
+      isActive = false;
+      interrupt();      
+    }
+  }
+
   private static Log log = LogFactory.getLog(LockMonitorThread.class);
 }

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -49,16 +49,15 @@
   }
 
   static String translateExpressionToDollars(String expression) {
-    char[] chars = expression.toCharArray();
-    int index = 0;
-    while (index!=-1) {
-      index = expression.indexOf("#{", index);
-      if (index!=-1) {
-        chars[index] = '$';
-        index++;
-      }
-    }
-    return new String(chars);
+    int hashIndex = expression.indexOf("#{");
+    if (hashIndex == -1) return expression;
+    
+    char[] expressionChars = expression.toCharArray();
+    do {
+      expressionChars[hashIndex] = '$';
+      hashIndex = expression.indexOf("#{", hashIndex + 2);
+    } while (hashIndex != -1);
+    return new String(expressionChars);
   }
 
   public static VariableResolver getUsedVariableResolver() {

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmVariableResolver.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmVariableResolver.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/impl/JbpmVariableResolver.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -61,11 +61,6 @@
         SwimlaneInstance swimlaneInstance = taskMgmtInstance.getSwimlaneInstance(name);
         value = (swimlaneInstance!=null ? swimlaneInstance.getActorId() : null);
         
-      } else if ( (contextInstance!=null)
-                  && (contextInstance.hasTransientVariable(name))
-                ) {
-        value = contextInstance.getTransientVariable(name);
-        
       } else if (JbpmConfiguration.Configs.hasObject(name)) {
         value = JbpmConfiguration.Configs.getObject(name);
       }

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/parser/ELParserTokenManager.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/parser/ELParserTokenManager.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/jpdl/el/parser/ELParserTokenManager.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -121,7 +121,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -160,7 +160,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -188,7 +188,7 @@
          long l1 = 1L << (hiByte & 077);
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -541,7 +541,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -710,7 +710,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -790,7 +790,7 @@
          long l1 = 1L << (hiByte & 077);
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/msg/db/DbMessageService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/msg/db/DbMessageService.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/msg/db/DbMessageService.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -21,11 +21,8 @@
  */
 package org.jbpm.msg.db;
 
-import java.util.Collection;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
 import org.jbpm.JbpmException;
 import org.jbpm.db.JobSession;

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -92,7 +92,7 @@
   }
 
   public SessionFactory getSessionFactory() {
-    return persistenceServiceFactory.getSessionFactory();
+    return session != null ? session.getSessionFactory() : persistenceServiceFactory.getSessionFactory();
   }
 
   public Session getSession() {
@@ -235,7 +235,10 @@
     
     Exception flushException = flushSession();
     if (flushException!=null) {
-      rollback();
+      // JBPM-1465 transaction has been either committed or rolled back at this point
+      // on the other hand, it is possible that no transaction is underway
+      // rolling back here is redundant and possibly dangerous
+      // rollback();
       closeSession();
       closeConnection();
       throw new JbpmPersistenceException("hibernate flush failed", flushException);

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -21,8 +21,6 @@
  */
 package org.jbpm.persistence.jta;
 
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import javax.transaction.SystemException;
 import javax.transaction.UserTransaction;
 
@@ -51,7 +49,7 @@
   }
 
   protected boolean isTransactionActive() {
-    return isJtaTxCreated() ; 
+    return isJtaTxCreated();
   }
   
   public void close() {
@@ -63,14 +61,14 @@
   }
 
   boolean isJtaTransactionInProgress() {
-    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) persistenceServiceFactory.getSessionFactory();
+    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
     return JTAHelper.isTransactionInProgress(sessionFactory);
   }
 
   void beginJtaTransaction() {
     try {
-    	log.debug("start user JTA transaction");
-    	userTransaction = getUserTransaction();
+      log.debug("start user JTA transaction");
+      userTransaction = ((JtaDbPersistenceServiceFactory) persistenceServiceFactory).getUserTransaction();
       userTransaction.begin();
     } catch (Exception e) {
       throw new JbpmException("couldn't start JTA transaction", e);
@@ -95,27 +93,6 @@
     }
   }
 
-  UserTransaction getUserTransaction() {
-    String jndiName = persistenceServiceFactory.getConfiguration().getProperty("jta.UserTransaction");
-    if (jndiName == null) {
-      /*
-       * EJB 2.1 section 20.9 The container must make the UserTransaction interface available to the
-       * enterprise beans that are allowed to use this interface (only session and message-
-       * driven beans with bean-managed transaction demarcation are allowed to use this 
-       * interface) in JNDI under the name java:comp/UserTransaction.
-       * J2EE 1.4 section 4.2.1.1 The J2EE platform must provide an object implementing the
-       * UserTransaction interface to all web components. The platform must publish the 
-       * UserTransaction object in JNDI under the name java:comp/UserTransaction.
-       */
-      jndiName = "java:comp/UserTransaction";
-    }
-    try {
-      return (UserTransaction) new InitialContext().lookup(jndiName);
-    } catch (NamingException e) {
-      throw new JbpmException("couldn't lookup UserTransaction in JNDI with name "+jndiName, e);
-    }
-  }
-
   int getJtaTransactionStatus() {
     try {
       return userTransaction.getStatus();

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -21,6 +21,11 @@
  */
 package org.jbpm.persistence.jta;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+
+import org.jbpm.JbpmException;
 import org.jbpm.persistence.db.DbPersistenceServiceFactory;
 import org.jbpm.svc.Service;
 
@@ -47,6 +52,8 @@
 
   private static final long serialVersionUID = 1L;
 
+  private UserTransaction userTransaction;
+
   public JtaDbPersistenceServiceFactory() {
     setCurrentSessionEnabled(true);
     setTransactionEnabled(false);
@@ -55,4 +62,28 @@
   public Service openService() {
     return new JtaDbPersistenceService(this);
   }
+
+  public UserTransaction getUserTransaction() {
+    if (userTransaction == null) {      
+      String jndiName = getConfiguration().getProperty("jta.UserTransaction");
+      if (jndiName == null) {
+        /*
+         * EJB 2.1 section 20.9 The container must make the UserTransaction interface available to the
+         * enterprise beans that are allowed to use this interface (only session and message-
+         * driven beans with bean-managed transaction demarcation are allowed to use this 
+         * interface) in JNDI under the name java:comp/UserTransaction.
+         * J2EE 1.4 section 4.2.1.1 The J2EE platform must provide an object implementing the
+         * UserTransaction interface to all web components. The platform must publish the 
+         * UserTransaction object in JNDI under the name java:comp/UserTransaction.
+         */
+        jndiName = "java:comp/UserTransaction";
+      }
+      try {
+        userTransaction = (UserTransaction) new InitialContext().lookup(jndiName);
+      } catch (NamingException e) {
+        throw new JbpmException("could not retrieve user transaction with name "+jndiName, e);
+      }
+    }
+    return userTransaction;
+  }
 }

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/SchedulerService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/SchedulerService.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/SchedulerService.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -21,17 +21,15 @@
  */
 package org.jbpm.scheduler;
 
-import java.io.Serializable;
-
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.graph.exe.Token;
 import org.jbpm.job.Timer;
 import org.jbpm.svc.Service;
 
-public interface SchedulerService extends Service, Serializable {
+public interface SchedulerService extends Service {
 
   void createTimer(Timer timer);
+  void deleteTimer(Timer timer);
   void deleteTimersByName(String timerName, Token token);
   void deleteTimersByProcessInstance(ProcessInstance processInstance);
-  void close();
 }

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/db/DbSchedulerService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/db/DbSchedulerService.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/scheduler/db/DbSchedulerService.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -56,14 +56,15 @@
     hasProducedJobs = true;
   }
 
+  public void deleteTimer(Timer timer) {
+    jobSession.deleteJob(timer);
+  }
+
   public void deleteTimersByName(String timerName, Token token) {
-    jobSession.cancelTimersByName(timerName, token);
+    jobSession.deleteTimersByName(timerName, token);
   }
 
   public void deleteTimersByProcessInstance(ProcessInstance processInstance) {
-    if (processInstance==null) {
-      throw new JbpmException("couldn't cancel timers for null process instance");
-    }
     jobSession.deleteJobsForProcessInstance(processInstance);
   }
 

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/svc/Services.java	2008-10-16 07:34:54 UTC (rev 2548)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/main/java/org/jbpm/svc/Services.java	2008-10-16 07:37:21 UTC (rev 2549)
@@ -257,9 +257,8 @@
       if (firstException != null) {
         if (firstException instanceof JbpmException) {
           throw (JbpmException) firstException;
-        } else {
-          throw new JbpmException("problem closing services", firstException);
         }
+        throw new JbpmException("problem closing services", firstException);
       }
     }
   }




More information about the jbpm-commits mailing list