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

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Aug 16 23:38:37 EDT 2010


Author: rebody
Date: 2010-08-16 23:38:37 -0400 (Mon, 16 Aug 2010)
New Revision: 6599

Modified:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
Log:
JBPM-2927 move findTimersByExecution() from TimerSession to DbSession.

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-08-16 08:12:40 UTC (rev 6598)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-08-17 03:38:37 UTC (rev 6599)
@@ -33,6 +33,7 @@
 
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
+import org.jbpm.api.job.Timer;
 import org.jbpm.api.history.HistoryComment;
 import org.jbpm.api.task.Task;
 import org.jbpm.internal.log.Log;
@@ -43,6 +44,7 @@
 import org.jbpm.pvm.internal.id.DbidGenerator;
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.job.StartProcessTimer;
+import org.jbpm.pvm.internal.job.TimerImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
 import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
@@ -387,4 +389,11 @@
       .list();
     return CollectionUtil.checkList(comments, HistoryComment.class);
   }
+
+  public List<Timer> findTimersByExecution(Execution execution) {
+    List<?> timers = session.createCriteria(TimerImpl.class)
+      .add(Restrictions.eq("execution", execution))
+      .list();
+    return CollectionUtil.checkList(timers, Timer.class);
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	2010-08-16 08:12:40 UTC (rev 6598)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	2010-08-17 03:38:37 UTC (rev 6599)
@@ -15,14 +15,12 @@
 
 import java.util.List;
 
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
-
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.job.Timer;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.session.TimerSession;
 import org.jbpm.pvm.internal.util.CollectionUtil;
 
@@ -39,18 +37,22 @@
   private static final Log log = Log.getLog(TimerSession.class.getName());
 
   /* injected */
-  Session session;
+  DbSession dbSession;
 
   /* injected. */
   JobAdditionNotifier jobAdditionNotifier;
 
   public void schedule(Timer timer) {
-    if (timer == null) throw new JbpmException("null timer scheduled");
+    if (timer == null) {
+      throw new JbpmException("null timer scheduled");
+    }
     TimerImpl timerImpl = (TimerImpl) timer;
     timerImpl.validate();
 
-    log.debug("scheduling " + timer);
-    session.save(timer);
+    if (log.isDebugEnabled()) {
+      log.debug("scheduling " + timer);
+    }
+    dbSession.save(timer);
 
     if (jobAdditionNotifier != null) {
       jobAdditionNotifier.registerNotification();
@@ -58,18 +60,17 @@
   }
 
   public void cancel(Timer timer) {
-    log.debug("canceling " + timer);
+    if (log.isDebugEnabled()) {
+      log.debug("canceling " + timer);
+    }
     if (timer != null) {
-      session.delete(timer);
+      dbSession.delete(timer);
     } else {
       throw new JbpmException("timer is null");
     }
   }
 
   public List<Timer> findTimersByExecution(Execution execution) {
-    List<?> timers = session.createCriteria(TimerImpl.class)
-      .add(Restrictions.eq("execution", execution))
-      .list();
-    return CollectionUtil.checkList(timers, Timer.class);
+    return dbSession.findTimersByExecution(execution);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2010-08-16 08:12:40 UTC (rev 6598)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2010-08-17 03:38:37 UTC (rev 6599)
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.jbpm.api.Execution;
+import org.jbpm.api.job.Timer;
 import org.jbpm.api.history.HistoryComment;
 import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.job.JobImpl;
@@ -98,14 +99,17 @@
   // job methods //////////////////////////////////////////////////////////////
 
   /** the first job to finish among eligible and non-locked jobs or null if none */
-  public JobImpl findFirstAcquirableJob();
+  JobImpl findFirstAcquirableJob();
 
   /** the list of jobs of the process instance that mustn't be concurrent */
-  public List<JobImpl> findExclusiveJobs(Execution processInstance);
+  List<JobImpl> findExclusiveJobs(Execution processInstance);
 
   /** the first job to finish among non-owned jobs or null if none */
-  public JobImpl findFirstDueJob();
+  JobImpl findFirstDueJob();
 
   /** returns a list of start process timers for the given process definition */
-  public List<StartProcessTimer> findStartProcessTimers(String processDefinitionId);
+  List<StartProcessTimer> findStartProcessTimers(String processDefinitionId);
+
+  /** retrieve all the outstanding timers associated for the given execution */
+  List<Timer> findTimersByExecution(Execution execution);
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java	2010-08-16 08:12:40 UTC (rev 6598)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java	2010-08-17 03:38:37 UTC (rev 6599)
@@ -21,13 +21,13 @@
  */
 package org.jbpm.pvm.internal.wire.binding;
 
-import org.hibernate.Session;
 import org.w3c.dom.Element;
 
 import org.jbpm.pvm.internal.jobexecutor.JobAdditionNotifier;
 import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
 import org.jbpm.pvm.internal.jobexecutor.JobExecutorTimerSession;
 import org.jbpm.pvm.internal.session.TimerSession;
+import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.WireDefinition;
 import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
@@ -38,7 +38,7 @@
 import org.jbpm.pvm.internal.xml.Parser;
 
 /** parses a descriptor for creating a {@link TimerSession}.
- * 
+ *
  * See schema docs for more details.
  *
  * @author Tom Baeyens, Pascal Verdage
@@ -52,10 +52,10 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     ObjectDescriptor objectDescriptor = new ObjectDescriptor();
-    
+
     String target = XmlUtil.attribute(element, "target");
 
-    if ((target!=null) && ("ejb".equalsIgnoreCase(target))) {
+    if ((target != null) && ("ejb".equalsIgnoreCase(target))) {
       objectDescriptor.setClassName("org.jbpm.enterprise.internal.ejb.EnterpriseTimerSession");
 
     } else {
@@ -63,7 +63,7 @@
       objectDescriptor.setClassName(JobExecutorTimerSession.class.getName());
 
       // inject fields
-      objectDescriptor.addInjection("session", new ContextTypeRefDescriptor(Session.class));
+      objectDescriptor.addInjection("dbSession", new ContextTypeRefDescriptor(DbSession.class));
       objectDescriptor.addInjection("jobAdditionNotifier",
         getJobAdditionNotifierDescriptor(parse));
     }



More information about the jbpm-commits mailing list