[jbpm-commits] JBoss JBPM SVN: r1644 - in jbpm4/pvm/trunk/modules/core/src: main/java/org/jbpm/pvm/internal/jobexecutor and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jul 15 18:17:15 EDT 2008
Author: alex.guizar at jboss.com
Date: 2008-07-15 18:17:15 -0400 (Tue, 15 Jul 2008)
New Revision: 1644
Added:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimerCmd.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhraseCmd.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhraseCmd.java
Removed:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimer.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobs.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCommand.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/NextDueDate.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhrase.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhrase.java
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/CommandReceiverMDB.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/TimerEB.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/job/JobTestHelper.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandExecutorTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandReceiverTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/EnterpriseTimerSessionTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/TimerTest.java
Log:
renamed several commands for consistency
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/CommandReceiverMDB.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/CommandReceiverMDB.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/CommandReceiverMDB.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -41,7 +41,7 @@
import javax.naming.NamingException;
import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.jobexecutor.ExecuteJobCommand;
+import org.jbpm.pvm.internal.jobexecutor.ExecuteJobCmd;
import org.jbpm.pvm.internal.log.Log;
/**
@@ -149,7 +149,7 @@
long jobId = message.getLongProperty("jobId");
log.debug("received message with jobImpl id " + jobId);
// create a command with the given jobId
- command = new ExecuteJobCommand(jobId);
+ command = new ExecuteJobCmd(jobId);
}
else {
log.info("WARNING: ignoring message, unknown format: " + message);
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimer.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimer.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimer.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -1,60 +0,0 @@
-/*
- * 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.ejb;
-
-import java.util.Date;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.job.TimerImpl;
-import org.jbpm.pvm.internal.log.Log;
-import org.jbpm.pvm.session.DbSession;
-
-
-/**
- * @author Tom Baeyens
- * @author Alejandro Guizar
- */
-public class ExecuteTimer implements Command<Date> {
-
- private final long timerDbid;
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(ExecuteTimer.class.getName());
-
- public ExecuteTimer(long timerDbid) {
- this.timerDbid = timerDbid;
- }
-
- public Date execute(Environment environment) throws Exception {
- DbSession dbSession = environment.get(DbSession.class);
- TimerImpl timerImpl = dbSession.get(TimerImpl.class, timerDbid);
- if (timerImpl == null) {
- log.debug("timer not found: " + timerDbid);
- return null; // i.e. delete this timer
- }
- return timerImpl.execute(environment) ? null : timerImpl.getDueDate();
- }
-
- public String toString() {
- return ExecuteTimer.class.getSimpleName() + '(' + timerDbid + ')';
- }
-}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimerCmd.java (from rev 1643, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimer.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimerCmd.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/ExecuteTimerCmd.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -0,0 +1,60 @@
+/*
+ * 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.ejb;
+
+import java.util.Date;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class ExecuteTimerCmd implements Command<Date> {
+
+ private final long timerDbid;
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(ExecuteTimerCmd.class.getName());
+
+ public ExecuteTimerCmd(long timerDbid) {
+ this.timerDbid = timerDbid;
+ }
+
+ public Date execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+ TimerImpl timerImpl = dbSession.get(TimerImpl.class, timerDbid);
+ if (timerImpl == null) {
+ log.debug("timer not found: " + timerDbid);
+ return null; // i.e. delete this timer
+ }
+ return timerImpl.execute(environment) ? null : timerImpl.getDueDate();
+ }
+
+ public String toString() {
+ return ExecuteTimerCmd.class.getSimpleName() + '(' + timerDbid + ')';
+ }
+}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/TimerEB.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/TimerEB.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/ejb/TimerEB.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -114,7 +114,7 @@
}
public void ejbTimeout(Timer timer) {
- Date nextDueDate = commandExecutor.execute(new ExecuteTimer(getDbid()));
+ Date nextDueDate = commandExecutor.execute(new ExecuteTimerCmd(getDbid()));
if (nextDueDate != null) {
schedule(nextDueDate);
}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobs.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobs.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobs.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -1,88 +0,0 @@
-/*
- * 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.jobexecutor;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.log.Log;
-
-
-/**
- * @author Tom Baeyens
- */
-public class AcquireJobs implements Command<Collection<Long>> {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log = Log.getLog(AcquireJobs.class.getName());
- private static final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
-
- JobExecutor jobExecutor;
-
- public AcquireJobs(JobExecutor jobExecutor) {
- this.jobExecutor = jobExecutor;
- }
-
- public Collection<Long> execute(Environment environment) throws Exception {
- Collection<Long> acquiredJobDbids = new ArrayList<Long>();
-
- Collection<JobImpl<?>> acquiredJobs = new ArrayList<JobImpl<?>>();
-
- JobDbSession jobDbSession = environment.get(JobDbSession.class);
- log.debug("start querying first acquirable jobImpl...");
-
- JobImpl<?> job = jobDbSession.findFirstAcquirableJob();
-
- if (job!=null) {
- if (job.isExclusive()) {
- log.trace("exclusive acquirable jobImpl found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
- List<JobImpl<?>> otherExclusiveJobs = jobDbSession.findExclusiveJobs(job.getProcessInstance());
- acquiredJobs.addAll(otherExclusiveJobs);
- } else {
- acquiredJobs.add(job);
- }
-
- for (JobImpl<?> acquiredJob: acquiredJobs) {
- long lockExpirationTime = System.currentTimeMillis()+jobExecutor.getLockMillis();
- log.trace("trying to obtain a lock for '"+acquiredJob+"' with exp "+timeFormat.format(new Date(lockExpirationTime)));
- acquiredJob.setLockExpirationTime(new Date(lockExpirationTime));
- acquiredJob.setLockOwner(jobExecutor.getName());
- acquiredJobDbids.add(acquiredJob.getDbid());
- }
-
- } else {
- log.trace("no acquirable jobs in jobImpl table");
- }
-
- log.debug("locking jobs "+acquiredJobDbids);
-
- return acquiredJobDbids;
- }
-
-}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java (from rev 1643, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobs.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -0,0 +1,88 @@
+/*
+ * 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.jobexecutor;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AcquireJobsCmd implements Command<Collection<Long>> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = Log.getLog(AcquireJobsCmd.class.getName());
+ private static final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
+
+ JobExecutor jobExecutor;
+
+ public AcquireJobsCmd(JobExecutor jobExecutor) {
+ this.jobExecutor = jobExecutor;
+ }
+
+ public Collection<Long> execute(Environment environment) throws Exception {
+ Collection<Long> acquiredJobDbids = new ArrayList<Long>();
+
+ Collection<JobImpl<?>> acquiredJobs = new ArrayList<JobImpl<?>>();
+
+ JobDbSession jobDbSession = environment.get(JobDbSession.class);
+ log.debug("start querying first acquirable jobImpl...");
+
+ JobImpl<?> job = jobDbSession.findFirstAcquirableJob();
+
+ if (job!=null) {
+ if (job.isExclusive()) {
+ log.trace("exclusive acquirable jobImpl found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
+ List<JobImpl<?>> otherExclusiveJobs = jobDbSession.findExclusiveJobs(job.getProcessInstance());
+ acquiredJobs.addAll(otherExclusiveJobs);
+ } else {
+ acquiredJobs.add(job);
+ }
+
+ for (JobImpl<?> acquiredJob: acquiredJobs) {
+ long lockExpirationTime = System.currentTimeMillis()+jobExecutor.getLockMillis();
+ log.trace("trying to obtain a lock for '"+acquiredJob+"' with exp "+timeFormat.format(new Date(lockExpirationTime)));
+ acquiredJob.setLockExpirationTime(new Date(lockExpirationTime));
+ acquiredJob.setLockOwner(jobExecutor.getName());
+ acquiredJobDbids.add(acquiredJob.getDbid());
+ }
+
+ } else {
+ log.trace("no acquirable jobs in jobImpl table");
+ }
+
+ log.debug("locking jobs "+acquiredJobDbids);
+
+ return acquiredJobDbids;
+ }
+
+}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java (from rev 1643, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCommand.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -0,0 +1,101 @@
+/*
+ * 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.jobexecutor;
+
+import java.util.Date;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.cmd.CommandService;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.job.Job;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecuteJobCmd implements Command<Job> {
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = Log.getLog(ExecuteJobCmd.class.getName());
+
+ protected long jobDbid;
+
+ public ExecuteJobCmd(long jobDbid) {
+ this.jobDbid = jobDbid;
+ }
+
+ public Job execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ if (session==null) {
+ throw new PvmException("no hibernate-session configured to get job "+jobDbid+" for execution");
+ }
+ JobImpl<?> job = (JobImpl<?>) session.get(JobImpl.class, jobDbid);
+
+ // in case of exclusive jobs, the jobImpl might have been deleted
+ // before we execute it (they are in a list)
+ if (job != null) {
+ try {
+ log.debug("executing job "+job+"...");
+ job.execute(environment);
+
+ // if this job is locked too long, it could be unlocked by the lockmonitor and
+ // executed by another thread.
+ Date lockExpirationDate = job.getLockExpirationTime();
+ // can be null if it was rescheduled
+ if (lockExpirationDate != null) {
+ long lockExpiration = lockExpirationDate.getTime();
+ long currentTime = System.currentTimeMillis();
+ if (currentTime>lockExpiration) {
+ throw new PvmException("job took too long: lock expired "+(currentTime-lockExpiration)+"ms ago");
+ }
+ }
+ } catch (Throwable exception) {
+ log.error("exception while executing '"+job+"'", exception);
+ handleJobExecutionException(environment, job, exception);
+ }
+
+ log.debug("executed job "+job);
+ } else {
+ log.debug("job " + jobDbid + " no longer exists");
+ }
+ return job;
+ }
+
+ /** This transaction will be marked for rollback. A command will be associated with the
+ * Transaction.EVENT_AFTERCOMPLETION (after the jobImpl locks of the current transaction are
+ * released). Then the command will update the JobImpl with the exception details in a separate
+ * transaction. */
+ protected void handleJobExecutionException(Environment environment, JobImpl<?> job, Throwable exception) {
+ Transaction transaction = environment.get(Transaction.class);
+ transaction.setRollbackOnly();
+
+ CommandService commandService = (CommandService) environment.get(CommandService.class);
+ JobExceptionHandler jobExceptionHandler = new JobExceptionHandler(job.getDbid(), exception, commandService);
+ transaction.addListener(jobExceptionHandler, Transaction.EVENT_AFTERCOMPLETION);
+ }
+}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCommand.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCommand.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCommand.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -1,101 +0,0 @@
-/*
- * 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.jobexecutor;
-
-import java.util.Date;
-
-import org.hibernate.Session;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.env.Transaction;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.cmd.CommandService;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.log.Log;
-import org.jbpm.pvm.job.Job;
-
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExecuteJobCommand implements Command<Job> {
- private static final long serialVersionUID = 1L;
-
- private static final Log log = Log.getLog(ExecuteJobCommand.class.getName());
-
- protected long jobDbid;
-
- public ExecuteJobCommand(long jobDbid) {
- this.jobDbid = jobDbid;
- }
-
- public Job execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- if (session==null) {
- throw new PvmException("no hibernate-session configured to get job "+jobDbid+" for execution");
- }
- JobImpl<?> job = (JobImpl<?>) session.get(JobImpl.class, jobDbid);
-
- // in case of exclusive jobs, the jobImpl might have been deleted
- // before we execute it (they are in a list)
- if (job != null) {
- try {
- log.debug("executing job "+job+"...");
- job.execute(environment);
-
- // if this job is locked too long, it could be unlocked by the lockmonitor and
- // executed by another thread.
- Date lockExpirationDate = job.getLockExpirationTime();
- // can be null if it was rescheduled
- if (lockExpirationDate != null) {
- long lockExpiration = lockExpirationDate.getTime();
- long currentTime = System.currentTimeMillis();
- if (currentTime>lockExpiration) {
- throw new PvmException("job took too long: lock expired "+(currentTime-lockExpiration)+"ms ago");
- }
- }
- } catch (Throwable exception) {
- log.error("exception while executing '"+job+"'", exception);
- handleJobExecutionException(environment, job, exception);
- }
-
- log.debug("executed job "+job);
- } else {
- log.debug("job " + jobDbid + " no longer exists");
- }
- return job;
- }
-
- /** This transaction will be marked for rollback. A command will be associated with the
- * Transaction.EVENT_AFTERCOMPLETION (after the jobImpl locks of the current transaction are
- * released). Then the command will update the JobImpl with the exception details in a separate
- * transaction. */
- protected void handleJobExecutionException(Environment environment, JobImpl<?> job, Throwable exception) {
- Transaction transaction = environment.get(Transaction.class);
- transaction.setRollbackOnly();
-
- CommandService commandService = (CommandService) environment.get(CommandService.class);
- JobExceptionHandler jobExceptionHandler = new JobExceptionHandler(job.getDbid(), exception, commandService);
- transaction.addListener(jobExceptionHandler, Transaction.EVENT_AFTERCOMPLETION);
- }
-}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java (from rev 1643, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/NextDueDate.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -0,0 +1,59 @@
+/*
+ * 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.jobexecutor;
+
+import java.util.Date;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.log.Log;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetNextDueDateCmd implements Command<Date> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = Log.getLog(GetNextDueDateCmd.class.getName());
+
+ JobExecutor jobExecutor;
+
+ public GetNextDueDateCmd(JobExecutor jobExecutor) {
+ this.jobExecutor = jobExecutor;
+ }
+
+ public Date execute(Environment environment) throws Exception {
+ Date nextDueDate = null;
+ log.debug("getting next due date...");
+ JobDbSession jobDbSession = environment.get(JobDbSession.class);
+ JobImpl<?> job = jobDbSession.findFirstDueJob();
+ if (job!=null) {
+ nextDueDate = job.getDueDate();
+ }
+ log.debug("next due date is "+nextDueDate);
+ return nextDueDate;
+ }
+
+}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -77,8 +77,8 @@
throw new PvmException("no command executor available in jobImpl executor");
}
if (! isActive) {
- acquireJobsCommand = new AcquireJobs(this);
- nextDueDateCommand = new NextDueDate(this);
+ acquireJobsCommand = new AcquireJobsCmd(this);
+ nextDueDateCommand = new GetNextDueDateCmd(this);
// the max capacity of the jobDbidsQueue is set to nbrOfJobExecutorThreads.
// That way, the distpatcher thread will be stalled if enough jobs are acquired.
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -59,7 +59,7 @@
for (Long jobDbid: jobDbids) {
CommandService commandService = jobExecutor.getCommandExecutor();
- commandService.execute(new ExecuteJobCommand(jobDbid));
+ commandService.execute(new ExecuteJobCmd(jobDbid));
}
} catch (InterruptedException e) {
log.trace("waiting for acquired jobs got interrupted");
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/NextDueDate.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/NextDueDate.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/NextDueDate.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -1,59 +0,0 @@
-/*
- * 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.jobexecutor;
-
-import java.util.Date;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.log.Log;
-
-
-
-/**
- * @author Tom Baeyens
- */
-public class NextDueDate implements Command<Date> {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log = Log.getLog(NextDueDate.class.getName());
-
- JobExecutor jobExecutor;
-
- public NextDueDate(JobExecutor jobExecutor) {
- this.jobExecutor = jobExecutor;
- }
-
- public Date execute(Environment environment) throws Exception {
- Date nextDueDate = null;
- log.debug("getting next due date...");
- JobDbSession jobDbSession = environment.get(JobDbSession.class);
- JobImpl<?> job = jobDbSession.findFirstDueJob();
- if (job!=null) {
- nextDueDate = job.getDueDate();
- }
- log.debug("next due date is "+nextDueDate);
- return nextDueDate;
- }
-
-}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/job/JobTestHelper.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/job/JobTestHelper.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/job/JobTestHelper.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -29,7 +29,7 @@
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.job.TimerImpl;
-import org.jbpm.pvm.internal.jobexecutor.ExecuteJobCommand;
+import org.jbpm.pvm.internal.jobexecutor.ExecuteJobCmd;
/** helper class for testing that executes messages and timers
@@ -55,7 +55,7 @@
query.setLong("executionDbid", executionDbid);
query.setMaxResults(1);
Long messageDbid = (Long) query.uniqueResult();
- ExecuteJobCommand executeJobCommand = new ExecuteJobCommand(messageDbid);
+ ExecuteJobCmd executeJobCommand = new ExecuteJobCmd(messageDbid);
Job job = executeJobCommand.execute(environment);
job.getExecution().getNode().getName();
return job.getExecution();
@@ -76,7 +76,7 @@
query.setLong("timerDbid", timerDbid);
query.setMaxResults(1);
Long timerDbid = (Long) query.uniqueResult();
- ExecuteJobCommand executeJobCommand = new ExecuteJobCommand(timerDbid);
+ ExecuteJobCmd executeJobCommand = new ExecuteJobCmd(timerDbid);
Job job = executeJobCommand.execute(environment);
return job.getExecution();
}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandExecutorTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandExecutorTest.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandExecutorTest.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -27,8 +27,8 @@
import org.apache.cactus.ServletTestCase;
-import org.jbpm.enterprise.custom.InsertPhrase;
-import org.jbpm.enterprise.custom.RemovePhrase;
+import org.jbpm.enterprise.custom.InsertPhraseCmd;
+import org.jbpm.enterprise.custom.RemovePhraseCmd;
import org.jbpm.pvm.internal.ejb.CommandExecutorSLSB;
import org.jbpm.pvm.internal.ejb.LocalCommandExecutor;
import org.jbpm.pvm.internal.ejb.LocalCommandExecutorHome;
@@ -73,43 +73,43 @@
* <h3>Preconditions</h3>
* The TEST_PHRASE table does not contain any row with the specified text.
* <h3>Behavior</h3>
- * The {@link InsertPhrase} command creates a row with the specified text.
+ * The {@link InsertPhraseCmd} command creates a row with the specified text.
* <h3>Postconditions</h3>
* A new row with the specified text exists in the table. The
- * {@link RemovePhrase} command removes the row, and the return value confirms
+ * {@link RemovePhraseCmd} command removes the row, and the return value confirms
* it was there.
*/
public void testHappyCommand() throws CreateException {
String text = "been there, done that";
- commandExecutor.execute(new InsertPhrase(text));
+ commandExecutor.execute(new InsertPhraseCmd(text));
// verify phrase was inserted
- assertTrue(commandExecutor.execute(new RemovePhrase(text)));
+ assertTrue(commandExecutor.execute(new RemovePhraseCmd(text)));
}
/**
* This scenario tests a command that throws a checked exception inside the
- * {@link InsertPhrase#execute(org.jbpm.env.Environment) execute} method.
+ * {@link InsertPhraseCmd#execute(org.jbpm.env.Environment) execute} method.
* <h3>Preconditions</h3>
* The TEST_PHRASE table does not contain any row with the specified text.
* <h3>Behavior</h3>
- * The {@link InsertPhrase} command creates a row with the specified text. The
+ * The {@link InsertPhraseCmd} command creates a row with the specified text. The
* command is configured to throw a checked exception before completing.
* <h3>Postconditions</h3>
* The command executor throws an {@link EJBException} and rolls back the
* managed transaction. No row with the specified text exists in the database.
- * The {@link RemovePhrase} command return value confirms the row was not
+ * The {@link RemovePhraseCmd} command return value confirms the row was not
* there.
*/
public void testNoisyCommand() throws CreateException {
String text = "houston, we have a problem";
// insert phrase via command
try {
- commandExecutor.execute(new InsertPhrase(text, /* fail? */true));
+ commandExecutor.execute(new InsertPhraseCmd(text, /* fail? */true));
fail("expected: " + EJBException.class.getSimpleName());
} catch (EJBException e) {
log.info("noisy command threw exception", e);
// verify phrase was NOT inserted
- assertFalse(commandExecutor.execute(new RemovePhrase(text)));
+ assertFalse(commandExecutor.execute(new RemovePhraseCmd(text)));
}
}
}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandReceiverTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandReceiverTest.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandReceiverTest.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -35,8 +35,8 @@
import org.apache.cactus.ServletTestCase;
-import org.jbpm.enterprise.custom.InsertPhrase;
-import org.jbpm.enterprise.custom.RemovePhrase;
+import org.jbpm.enterprise.custom.InsertPhraseCmd;
+import org.jbpm.enterprise.custom.RemovePhraseCmd;
import org.jbpm.pvm.internal.cmd.Command;
import org.jbpm.pvm.internal.ejb.CommandReceiverMDB;
@@ -84,12 +84,12 @@
* <h3>Preconditions</h3>
* The TEST_PHRASE table does not contain any row with the specified text.
* <h3>Behavior</h3>
- * The {@link InsertPhrase} command message creates a row with the specified
+ * The {@link InsertPhraseCmd} command message creates a row with the specified
* text. Once the command completes, the command receiver sends the result to
* the reply queue.
* <h3>Postconditions</h3>
* A new row with the specified text exists in the table. The
- * {@link RemovePhrase} command message removes the row. The result sent to
+ * {@link RemovePhraseCmd} command message removes the row. The result sent to
* the reply queue confirms the row was there.
*/
public void testHappyMessage() throws JMSException {
@@ -97,7 +97,7 @@
Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
// send insert command
- Command<Void> insertCommand = new InsertPhrase(text, /* fail? */false);
+ Command<Void> insertCommand = new InsertPhraseCmd(text, /* fail? */false);
Message insertMessage = jmsSession.createObjectMessage(insertCommand);
Destination replyTo = jmsSession.createTemporaryQueue();
insertMessage.setJMSReplyTo(replyTo);
@@ -110,7 +110,7 @@
assertNull(responseMessage.getObject());
// send remove command
- Command<Boolean> removeCommand = new RemovePhrase(text);
+ Command<Boolean> removeCommand = new RemovePhraseCmd(text);
Message removeMessage = jmsSession.createObjectMessage(removeCommand);
removeMessage.setJMSReplyTo(replyTo);
producer.send(removeMessage);
@@ -127,19 +127,19 @@
/**
* This scenario tests a command message that throws a checked exception
- * inside the {@link InsertPhrase#execute(org.jbpm.env.Environment) execute}
+ * inside the {@link InsertPhraseCmd#execute(org.jbpm.env.Environment) execute}
* method.
* <h3>Preconditions</h3>
* The TEST_PHRASE table does not contain any row with the specified text.
* <h3>Behavior</h3>
- * The {@link InsertPhrase} command message creates a row with the specified
+ * The {@link InsertPhraseCmd} command message creates a row with the specified
* text. The command is configured to throw a checked exception before
* completing. The exception prevents the command receiver from sending the
* result to the reply queue.
* <h3>Postconditions</h3>
* The command receiver rolls back the managed transaction and puts the
* insertion message back in the command queue. No row with the specified
- * exists in the database. The {@link RemovePhrase} command result sent to the
+ * exists in the database. The {@link RemovePhraseCmd} command result sent to the
* reply queue confirms the row was not there.
*/
public void testNoisyMessage() throws JMSException {
@@ -148,7 +148,7 @@
Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
// send insert command
- Command<Void> insertCommand = new InsertPhrase(text, /* fail? */true);
+ Command<Void> insertCommand = new InsertPhraseCmd(text, /* fail? */true);
Message insertMessage = jmsSession.createObjectMessage(insertCommand);
Destination replyTo = jmsSession.createTemporaryQueue();
insertMessage.setJMSReplyTo(replyTo);
@@ -161,7 +161,7 @@
assertNull(insertResponse);
// send remove command
- Command<Boolean> removeCommand = new RemovePhrase(text);
+ Command<Boolean> removeCommand = new RemovePhraseCmd(text);
Message removeMessage = jmsSession.createObjectMessage(removeCommand);
removeMessage.setJMSReplyTo(replyTo);
producer.send(removeMessage);
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/EnterpriseTimerSessionTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/EnterpriseTimerSessionTest.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/EnterpriseTimerSessionTest.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -40,7 +40,6 @@
import org.jbpm.pvm.internal.ejb.LocalCommandExecutorHome;
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.job.Timer;
import org.jbpm.pvm.model.ProcessDefinition;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.pvm.session.DbSession;
@@ -91,7 +90,7 @@
* <h3>Preconditions</h3>
* The activity has not executed.
* <h3>Behavior</h3>
- * The {@link ScheduleTimer} command activates a timerImpl. After that, the test
+ * The {@link ScheduleTimerCmd} command activates a timerImpl. After that, the test
* waits for the activity to execute. Upon timeout, the
* {@linkplain HappyActivity activity} notifies the test of its execution.
* <h3>Postconditions</h3>
@@ -116,8 +115,8 @@
* <h3>Preconditions</h3>
* The activity has not executed.
* <h3>Behavior</h3>
- * The {@link ScheduleTimer} command activates a timerImpl, which is immediately
- * disabled by the {@link CancelTimer} command. After that, the test waits
+ * The {@link ScheduleTimerCmd} command activates a timerImpl, which is immediately
+ * disabled by the {@link CancelTimerCmd} command. After that, the test waits
* past the timerImpl's due date.
* <h3>Postconditions</h3>
* The activity does not execute, ever.
@@ -130,13 +129,13 @@
assertNull(executionDate);
}
- static class ScheduleTimer implements Command<Void> {
+ static class ScheduleTimerCmd implements Command<Void> {
private final TimerImpl timer;
private static final long serialVersionUID = 1L;
- ScheduleTimer(TimerImpl timer) {
+ ScheduleTimerCmd(TimerImpl timer) {
this.timer = timer;
}
@@ -147,13 +146,13 @@
}
}
- static class CancelTimer implements Command<Void> {
+ static class CancelTimerCmd implements Command<Void> {
private final long timerDbid;
private static final long serialVersionUID = 1L;
- CancelTimer(long timerDbid) {
+ CancelTimerCmd(long timerDbid) {
this.timerDbid = timerDbid;
}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/TimerTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/TimerTest.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/TimerTest.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -100,7 +100,7 @@
* <h3>Preconditions</h3>
* The activity has not executed.
* <h3>Behavior</h3>
- * The {@link CreateTimer} command subscribes a timerImpl bean to the EJB timerImpl
+ * The {@link CreateTimerCmd} command subscribes a timerImpl bean to the EJB timerImpl
* service. After that, the test waits for the activity to execute. Upon
* timeout, the {@linkplain HappyActivity activity} notifies the test of its
* execution.
@@ -118,7 +118,7 @@
timerImpl.setEventName("timeout");
timerImpl.setDueDate(dueDate);
timerImpl.setExecution(execution);
- commandExecutor.execute(new CreateTimer(timerImpl));
+ commandExecutor.execute(new CreateTimerCmd(timerImpl));
Date executionDate = HappyActivity.waitFor();
assertTrue(dueDate.compareTo(executionDate) <= 0);
@@ -130,7 +130,7 @@
* <h3>Preconditions</h3>
* The activity has not executed.
* <h3>Behavior</h3>
- * The {@link CreateTimer} command subscribes a timerImpl bean to the EJB timerImpl
+ * The {@link CreateTimerCmd} command subscribes a timerImpl bean to the EJB timerImpl
* service. After that, the test waits for the activity to execute. Upon
* timeout, the {@linkplain NoisyActivity activity} notifies the test of its
* execution, sets a variable and throws a checked exception.
@@ -149,7 +149,7 @@
timerImpl.setEventName("timeout");
timerImpl.setDueDate(dueDate);
timerImpl.setExecution(execution);
- commandExecutor.execute(new CreateTimer(timerImpl));
+ commandExecutor.execute(new CreateTimerCmd(timerImpl));
Date executionDate = NoisyActivity.waitFor();
assertTrue(dueDate.compareTo(executionDate) <= 0);
@@ -164,7 +164,7 @@
* <h3>Preconditions</h3>
* The activity has not executed.
* <h3>Behavior</h3>
- * The {@link CreateTimer} command subscribes a timerImpl bean to the EJB timerImpl
+ * The {@link CreateTimerCmd} command subscribes a timerImpl bean to the EJB timerImpl
* service. After that, the test waits for the first execution of the
* activity, and then for the subsequent <em>n</em> executions of the
* activity. Upon each timeout, the {@linkplain HappyActivity activity}
@@ -186,7 +186,7 @@
timerImpl.setDueDate(dueDate);
timerImpl.setRepeat(REPEAT + " milliseconds");
timerImpl.setExecution(execution);
- commandExecutor.execute(new CreateTimer(timerImpl));
+ commandExecutor.execute(new CreateTimerCmd(timerImpl));
try {
Date executionTime = HappyActivity.waitFor();
@@ -199,17 +199,17 @@
assertTrue(dueDate.compareTo(executionTime) <= 0);
}
} finally {
- commandExecutor.execute(new CancelTimer(timerImpl.getDbid()));
+ commandExecutor.execute(new CancelTimerCmd(timerImpl.getDbid()));
}
}
- static class CreateTimer implements Command<Void> {
+ static class CreateTimerCmd implements Command<Void> {
private final TimerImpl timerImpl;
private static final long serialVersionUID = 1L;
- CreateTimer(TimerImpl timerImpl) {
+ CreateTimerCmd(TimerImpl timerImpl) {
this.timerImpl = timerImpl;
}
@@ -226,17 +226,17 @@
}
public String toString() {
- return CreateTimer.class.getSimpleName() + '(' + timerImpl + ')';
+ return CreateTimerCmd.class.getSimpleName() + '(' + timerImpl + ')';
}
}
- static class CancelTimer implements Command<Void> {
+ static class CancelTimerCmd implements Command<Void> {
private final long timerDbid;
private static final long serialVersionUID = 1L;
- CancelTimer(long timerDbid) {
+ CancelTimerCmd(long timerDbid) {
this.timerDbid = timerDbid;
}
@@ -247,7 +247,7 @@
}
public String toString() {
- return CancelTimer.class.getSimpleName() + '(' + timerDbid + ')';
+ return CancelTimerCmd.class.getSimpleName() + '(' + timerDbid + ')';
}
}
}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhrase.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhrase.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhrase.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -1,62 +0,0 @@
-/*
- * 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.enterprise.custom;
-
-import java.sql.SQLException;
-
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.session.DbSession;
-
-/**
- * @author Alejandro Guizar
- */
-public class InsertPhrase implements Command<Void> {
-
- private final String text;
- private final boolean fail;
-
- private static final long serialVersionUID = 1L;
-
- public InsertPhrase(String text) {
- this(text, false);
- }
-
- public InsertPhrase(String text, boolean fail) {
- this.text = text;
- this.fail = fail;
- }
-
- public Void execute(Environment environment) throws Exception {
- Phrase phrase = new Phrase();
- phrase.setText(text);
- environment.get(DbSession.class).save(phrase);
- if (fail)
- throw new SQLException("simulated failure");
- return null;
- }
-
- @Override
- public String toString() {
- return InsertPhrase.class.getSimpleName() + '(' + text + ')';
- }
-}
\ No newline at end of file
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhraseCmd.java (from rev 1643, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhrase.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhraseCmd.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhraseCmd.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -0,0 +1,62 @@
+/*
+ * 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.enterprise.custom;
+
+import java.sql.SQLException;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.session.DbSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class InsertPhraseCmd implements Command<Void> {
+
+ private final String text;
+ private final boolean fail;
+
+ private static final long serialVersionUID = 1L;
+
+ public InsertPhraseCmd(String text) {
+ this(text, false);
+ }
+
+ public InsertPhraseCmd(String text, boolean fail) {
+ this.text = text;
+ this.fail = fail;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ Phrase phrase = new Phrase();
+ phrase.setText(text);
+ environment.get(DbSession.class).save(phrase);
+ if (fail)
+ throw new SQLException("simulated failure");
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return InsertPhraseCmd.class.getSimpleName() + '(' + text + ')';
+ }
+}
\ No newline at end of file
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhrase.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhrase.java 2008-07-15 16:26:12 UTC (rev 1643)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhrase.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -1,62 +0,0 @@
-/*
- * 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.enterprise.custom;
-
-import java.util.List;
-
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
-
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-
-/**
- * @author Alejandro Guizar
- */
-public class RemovePhrase implements Command<Boolean> {
-
- private final String text;
-
- private static final long serialVersionUID = 1L;
-
- public RemovePhrase(String text) {
- this.text = text;
- }
-
- public Boolean execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- List<?> phrases = session.createCriteria(Phrase.class)
- .add(Restrictions.eq("text", text))
- .setMaxResults(1)
- .list();
- if (phrases.isEmpty())
- return false;
- Phrase phrase = (Phrase) phrases.get(0);
- session.delete(phrase);
- return true;
- }
-
- @Override
- public String toString() {
- return RemovePhrase.class.getSimpleName() + '(' + text + ')';
- }
-}
\ No newline at end of file
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhraseCmd.java (from rev 1643, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhrase.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhraseCmd.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhraseCmd.java 2008-07-15 22:17:15 UTC (rev 1644)
@@ -0,0 +1,61 @@
+/*
+ * 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.enterprise.custom;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class RemovePhraseCmd implements Command<Boolean> {
+
+ private final String text;
+
+ private static final long serialVersionUID = 1L;
+
+ public RemovePhraseCmd(String text) {
+ this.text = text;
+ }
+
+ public Boolean execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ List<?> phrases = session.createCriteria(Phrase.class)
+ .add(Restrictions.eq("text", text))
+ .setMaxResults(1)
+ .list();
+ if (phrases.isEmpty())
+ return false;
+ Phrase phrase = (Phrase) phrases.get(0);
+ session.delete(phrase);
+ return true;
+ }
+
+ public String toString() {
+ return RemovePhraseCmd.class.getSimpleName() + '(' + text + ')';
+ }
+}
\ No newline at end of file
More information about the jbpm-commits
mailing list