JBoss JBPM SVN: r2550 - jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-16 03:37:50 -0400 (Thu, 16 Oct 2008)
New Revision: 2550
Modified:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.classpath
Log:
bumped jboss version to 4.2.3
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.classpath
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.classpath 2008-10-16 07:37:21 UTC (rev 2549)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.classpath 2008-10-16 07:37:50 UTC (rev 2550)
@@ -62,6 +62,6 @@
<classpathentry kind="var" path="JBPM_REPO/jfreechart/1.0.2/lib/jcommon.jar"/>
<classpathentry kind="var" path="JBPM_REPO/jfreechart/1.0.2/lib/jfreechart.jar"/>
<classpathentry kind="var" path="JBPM_REPO/jasperreports/2.0.4/lib/jasperreports.jar"/>
- <classpathentry kind="var" path="JBPM_REPO/jbossas/core-libs/4.2.2.GA/lib/jboss-j2ee.jar"/>
+ <classpathentry kind="var" path="JBPM_REPO/jbossas/core-libs/4.2.3.GA/lib/jboss-j2ee.jar"/>
<classpathentry kind="output" path="jpdl/jar/target/classes"/>
</classpath>
17 years, 6 months
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.
by do-not-reply@jboss.org
Author: alex.guizar(a)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);
}
}
}
17 years, 6 months
JBoss JBPM SVN: r2548 - in jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm: scheduler/exe and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-16 03:34:54 -0400 (Thu, 16 Oct 2008)
New Revision: 2548
Modified:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/mail/TaskMailTest.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/svc/ServicesTest.java
Log:
merged revision 2134 from https://svn.jboss.org/repos/jbpm/jbpm3/trunk/modules/core/src/test/java
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/mail/TaskMailTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/mail/TaskMailTest.java 2008-10-16 07:33:28 UTC (rev 2547)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/mail/TaskMailTest.java 2008-10-16 07:34:54 UTC (rev 2548)
@@ -84,7 +84,7 @@
assertTrue(-1!=email.getBody().indexOf("http://localhost:8080/jbpm/home?taskId=0"));
}
- public static class TestSchedulerService implements SchedulerService, Service, ServiceFactory {
+ public static class TestSchedulerService implements SchedulerService, ServiceFactory {
private static final long serialVersionUID = 1L;
List createdTimers = new ArrayList();
@@ -93,11 +93,12 @@
public void createTimer(Timer timer) {
createdTimers.add(timer);
}
-
+ public void deleteTimer(Timer timer) {
+ cancelledTimers.add(timer.getName());
+ }
public void deleteTimersByName(String timerName, Token token) {
cancelledTimers.add(timerName);
}
-
public void deleteTimersByProcessInstance(ProcessInstance processInstance) {
}
public Service openService() {
@@ -105,6 +106,7 @@
}
public void close() {
}
+
}
public void testTaskInstanceReminder() throws Exception {
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java 2008-10-16 07:33:28 UTC (rev 2547)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java 2008-10-16 07:34:54 UTC (rev 2548)
@@ -59,6 +59,9 @@
public void createTimer(Timer timer) {
createdTimers.add(timer);
}
+ public void deleteTimer(Timer timer) {
+ cancelledTimersByName.add(new Object[]{timer.getName(), timer.getToken()});
+ }
public void deleteTimersByName(String timerName, Token token) {
cancelledTimersByName.add(new Object[]{timerName, token});
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/svc/ServicesTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/svc/ServicesTest.java 2008-10-16 07:33:28 UTC (rev 2547)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/svc/ServicesTest.java 2008-10-16 07:34:54 UTC (rev 2548)
@@ -20,6 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jbpm.svc;
+
import java.security.AccessControlException;
import java.security.Permission;
import java.util.HashMap;
@@ -27,7 +28,6 @@
import junit.framework.TestCase;
-import org.hibernate.SessionFactory;
import org.jbpm.db.ContextSession;
import org.jbpm.db.GraphSession;
import org.jbpm.db.JobSession;
@@ -160,7 +160,6 @@
public void setLoggingSession(LoggingSession loggingSession) {}
public void setJobSession(JobSession jobSession) {}
public void setTaskMgmtSession(TaskMgmtSession taskMgmtSession) {}
- public void setSessionFactory(SessionFactory sessionFactory) {}
};
serviceFactories.put("persistence", new TestGivenServiceFactory(service));
Services services = new Services(serviceFactories);
@@ -171,6 +170,7 @@
SchedulerService schedulerService = new SchedulerService() {
private static final long serialVersionUID = 1L;
public void createTimer(Timer timer) {}
+ public void deleteTimer(Timer timer) {}
public void deleteTimersByName(String timerName, Token token) {}
public void deleteTimersByProcessInstance(ProcessInstance processInstance) {}
public void close() {}
17 years, 6 months
JBoss JBPM SVN: r2547 - jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-16 03:33:28 -0400 (Thu, 16 Oct 2008)
New Revision: 2547
Modified:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/ejb-jar.xml
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/jbosscmp-jdbc.xml
Log:
merged revisions 2080, 2114, 2134, 2155 and 2169 from https://svn.jboss.org/repos/jbpm/jbpm3/trunk/modules/enterprise/jar/src/m...
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/ejb-jar.xml
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/ejb-jar.xml 2008-10-16 07:31:42 UTC (rev 2546)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/ejb-jar.xml 2008-10-16 07:33:28 UTC (rev 2547)
@@ -21,7 +21,8 @@
<ejb-class>org.jbpm.ejb.impl.CommandServiceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
- <!--
+
+ <!-- Configuration resource ==>
<env-entry>
<description>
The classpath resource from which to read the jBPM configuration. Optional, defaults to
@@ -31,18 +32,21 @@
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>jbpm.cfg.xml</env-entry-value>
</env-entry>
- -->
+ <!== Configuration resource -->
+
<ejb-local-ref>
<description>
Link to the local entity bean that implements the scheduler service. Required for
processes that contain timers.
</description>
- <ejb-ref-name>ejb/LocalTimerEntityBean</ejb-ref-name>
+ <ejb-ref-name>ejb/TimerEntityBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>org.jbpm.ejb.LocalTimerEntityHome</local-home>
<local>org.jbpm.ejb.LocalTimerEntity</local>
<ejb-link>TimerEntityBean</ejb-link>
</ejb-local-ref>
+
+ <!-- Timer service bean ==>
<ejb-local-ref>
<description>
Link to the local session bean that implements the scheduler service. Deprecated, replaced
@@ -54,6 +58,8 @@
<local>org.jbpm.scheduler.ejbtimer.LocalTimerService</local>
<ejb-link>TimerServiceBean</ejb-link>
</ejb-local-ref>
+ <!== Timer service bean -->
+
<resource-ref>
<description>
Logical name of the data source that provides connections to the persistence service. Must
@@ -63,6 +69,7 @@
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
+
<resource-ref>
<description>
Logical name of the factory that provides JMS connections to the message service. Required
@@ -72,6 +79,7 @@
<res-type>javax.jms.ConnnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
+
<message-destination-ref>
<description>
The message service sends job messages to the queue referenced here. To ensure this is the
@@ -85,6 +93,7 @@
</message-destination-ref>
</session>
+ <!-- Timer service bean ==>
<session>
<description>
Interacts with the EJB timer service to schedule jBPM timers. Deprecated, replaced by the
@@ -97,6 +106,7 @@
<ejb-class>org.jbpm.scheduler.ejbtimer.TimerServiceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
+
<ejb-local-ref>
<description>
Link to the session bean that executes timers on a separate context.
@@ -108,6 +118,7 @@
<ejb-link>CommandServiceBean</ejb-link>
</ejb-local-ref>
</session>
+ <!== Timer service bean -->
<message-driven>
<description>
@@ -118,6 +129,7 @@
<ejb-class>org.jbpm.ejb.impl.CommandListenerBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
+
<ejb-local-ref>
<description>
Link to the local session bean that executes commands on a separate context.
@@ -128,6 +140,7 @@
<local>org.jbpm.ejb.LocalCommandService</local>
<ejb-link>CommandServiceBean</ejb-link>
</ejb-local-ref>
+
<resource-ref>
<description>
Logical name of the factory that provides JMS connections for producing result messages.
@@ -137,6 +150,7 @@
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
+
<message-destination-ref>
<description>
Messages which do not contain a command are sent to the queue referenced here. Optional;
@@ -159,6 +173,7 @@
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<message-destination-link>JobQueue</message-destination-link>
+
<ejb-local-ref>
<description>
Link to the local session bean that executes jobs on a separate context.
@@ -169,6 +184,7 @@
<local>org.jbpm.ejb.LocalCommandService</local>
<ejb-link>CommandServiceBean</ejb-link>
</ejb-local-ref>
+
<resource-ref>
<description>
Logical name of the factory that provides JMS connections for producing result messages.
@@ -178,6 +194,7 @@
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
+
<message-destination-ref>
<description>
Messages which do not contain a job ID are sent to the queue referenced here. Optional; if
@@ -213,7 +230,11 @@
<cmp-field>
<field-name>processInstanceId</field-name>
</cmp-field>
+ <cmp-field>
+ <field-name>discriminator</field-name>
+ </cmp-field>
<primkey-field>timerId</primkey-field>
+
<ejb-local-ref>
<description>
Link to the session bean that executes timers on a separate context.
@@ -224,36 +245,24 @@
<local>org.jbpm.ejb.LocalCommandService</local>
<ejb-link>CommandServiceBean</ejb-link>
</ejb-local-ref>
+
<query>
- <description>Retrieve all timers by token identifier</description>
+ <description>Retrieve all timers by name and token identifier</description>
<query-method>
- <method-name>findByTokenId</method-name>
+ <method-name>findByNameAndTokenId</method-name>
<method-params>
+ <method-param>java.lang.String</method-param>
<method-param>java.lang.Long</method-param>
</method-params>
</query-method>
<ejb-ql><![CDATA[
select object(obj)
from TimerEntityBean obj
- where obj.tokenId = ?1
+ where obj.name = ?1 and obj.tokenId = ?2 and obj.discriminator = 'T'
]]></ejb-ql>
</query>
+
<query>
- <description>Retrieve all timers by token identifier and name</description>
- <query-method>
- <method-name>findByTokenIdAndName</method-name>
- <method-params>
- <method-param>java.lang.Long</method-param>
- <method-param>java.lang.String</method-param>
- </method-params>
- </query-method>
- <ejb-ql><![CDATA[
- select object(obj)
- from TimerEntityBean obj
- where obj.tokenId = ?1 and obj.name = ?2
- ]]></ejb-ql>
- </query>
- <query>
<description>Retrieve all timers by process instance identifier</description>
<query-method>
<method-name>findByProcessInstanceId</method-name>
@@ -264,7 +273,7 @@
<ejb-ql><![CDATA[
select object(obj)
from TimerEntityBean obj
- where obj.processInstanceId = ?1
+ where obj.processInstanceId = ?1 and obj.discriminator = 'T'
]]></ejb-ql>
</query>
</entity>
@@ -281,6 +290,7 @@
<trans-attribute>Required</trans-attribute>
</container-transaction>
+ <!-- Timer service bean ==>
<container-transaction>
<method>
<ejb-name>TimerServiceBean</ejb-name>
@@ -288,6 +298,7 @@
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
+ <!== Timer service bean -->
<container-transaction>
<method>
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/jbosscmp-jdbc.xml
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/jbosscmp-jdbc.xml 2008-10-16 07:31:42 UTC (rev 2546)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/jar/META-INF/jbosscmp-jdbc.xml 2008-10-16 07:33:28 UTC (rev 2547)
@@ -31,6 +31,10 @@
<field-name>processInstanceId</field-name>
<column-name>PROCESSINSTANCE_</column-name>
</cmp-field>
+ <cmp-field>
+ <field-name>discriminator</field-name>
+ <column-name>CLASS_</column-name>
+ </cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
\ No newline at end of file
17 years, 6 months
JBoss JBPM SVN: r2546 - in jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm: ejb/impl and 2 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-16 03:31:42 -0400 (Thu, 16 Oct 2008)
New Revision: 2546
Modified:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntity.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactoryImpl.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerService.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerServiceFactory.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerServiceFactory.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/LocalTimerService.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/TimerServiceBean.java
Log:
merged revisions 1492, 1925, 1948, 2114, 2134, 2169 and 2185 from https://svn.jboss.org/repos/jbpm/jbpm3/trunk/modules/enterprise/jar/src/m...
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntity.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntity.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntity.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -4,15 +4,16 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
+import org.jbpm.job.Timer;
public interface LocalTimerEntity extends EJBLocalObject {
- public void cancelTimer();
+ public void createTimer(Timer timer);
- public void createTimer(org.jbpm.job.Timer timer);
+ public void cancelTimer(Timer timer);
public void cancelTimersByName(String timerName, Token token);
- public void deleteTimersForProcessInstance(ProcessInstance processInstance);
+ public void cancelTimersForProcessInstance(ProcessInstance processInstance);
}
\ No newline at end of file
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -10,12 +10,10 @@
public LocalTimerEntity create() throws CreateException;
- public LocalTimerEntity findByPrimaryKey(Long key) throws FinderException;
+ public LocalTimerEntity findByPrimaryKey(Long timerId) throws FinderException;
- public Collection findByTokenId(Long key) throws FinderException;
-
- public Collection findByTokenIdAndName(Long key, String name)
+ public Collection findByNameAndTokenId(String name, Long tokenId)
throws FinderException;
- public Collection findByProcessInstanceId(Long key) throws FinderException;
+ public Collection findByProcessInstanceId(Long processInstanceId) throws FinderException;
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -63,7 +63,7 @@
* </td>
* </tr>
* <tr>
- * <td><code>ejb/LocalTimerEntityBean</code></td>
+ * <td><code>ejb/TimerEntityBean</code></td>
* <td>EJB Reference</td>
* <td>Link to the local {@linkplain TimerEntityBean entity bean} that
* implements the scheduler service. Required for processes that contain
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -1,5 +1,8 @@
package org.jbpm.ejb.impl;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmContext;
@@ -9,10 +12,10 @@
public class ExecuteJobCommand implements Command {
+ private final long jobId;
+
private static final long serialVersionUID = 1L;
-
- long jobId;
-
+
public ExecuteJobCommand(long jobId) {
this.jobId = jobId;
}
@@ -20,11 +23,25 @@
public Object execute(JbpmContext jbpmContext) throws Exception {
JobSession jobSession = jbpmContext.getJobSession();
Job job = jobSession.loadJob(jobId);
- log.debug("executing job "+jobId);
- if (job.execute(jbpmContext)) {
- log.debug("deleting job "+jobId);
- jobSession.deleteJob(job);
+ job.setLockOwner(getClass().getName()); // prevent others from removing job
+ log.debug("executing " + job);
+ try {
+ if (job.execute(jbpmContext)) {
+ jobSession.deleteJob(job);
+ }
}
+ catch (RuntimeException e) {
+ // nothing to do but clean up and exit
+ throw e;
+ }
+ catch (Exception e) {
+ // save data about recoverable error condition
+ log.error("exception while executing " + job, e);
+ StringWriter memoryWriter = new StringWriter();
+ e.printStackTrace(new PrintWriter(memoryWriter));
+ job.setException(memoryWriter.toString());
+ job.setRetries(job.getRetries() - 1);
+ }
return job;
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -74,6 +74,10 @@
public abstract void setProcessInstanceId(Long processInstanceId);
+ public abstract String getDiscriminator();
+
+ public abstract void setDiscriminator(String discriminator);
+
public void ejbActivate() {
try {
Context initial = new InitialContext();
@@ -122,56 +126,70 @@
public void ejbPostCreate() {}
public void ejbTimeout(javax.ejb.Timer ejbTimer) {
- log.debug("ejb timer " + ejbTimer + " fires");
+ log.debug(ejbTimer + " fired");
TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
Timer timer = (Timer) commandService.execute(new ExecuteTimerCommand(timerInfo.getTimerId()));
// if the timer has repeat
- if(timer != null && timer.getRepeat() != null) {
+ if (timer.getRepeat() != null) {
// create a new timer
- log.debug("scheduling timer for repeat at " + timer.getDueDate());
+ log.debug("scheduling timer for repeat on " + timer.getDueDate());
createTimer(timer);
}
}
public void createTimer(org.jbpm.job.Timer timer) {
- log.debug("Creating timer " + timer + " in the ejb timer service");
TimerService timerService = entityContext.getTimerService();
- timerService.createTimer(timer.getDueDate(), new TimerInfo(timer));
+ javax.ejb.Timer ejbTimer = timerService.createTimer(timer.getDueDate(), new TimerInfo(timer));
+ log.debug("created " + ejbTimer);
}
- public void cancelTimer() {
- log.debug("Cancelling timer: " + this.getName());
+ public void cancelTimer(org.jbpm.job.Timer timer) {
+ long timerId = timer.getId();
Collection timers = entityContext.getTimerService().getTimers();
+ log.debug("retrieved " + timers.size() + " ejb timer(s) by id " + timerId);
+
+ int count = 0;
for (Iterator i = timers.iterator(); i.hasNext();) {
javax.ejb.Timer ejbTimer = (javax.ejb.Timer) i.next();
- ejbTimer.cancel();
+ TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
+ if (timerInfo.getTimerId() == timerId) {
+ ejbTimer.cancel();
+ ++count;
+ }
}
+ log.debug("canceled " + count + " ejb timer(s) by id " + timerId);
}
public void cancelTimersByName(String timerName, Token token) {
- log.debug("cancelling timers with name " + timerName
- + " from the ejb timer service");
Collection timers = entityContext.getTimerService().getTimers();
+ log.debug("retrieved " + timers.size() + " ejb timer(s) by name '" + timerName + "' for " + token);
+
+ int count = 0;
for (Iterator i = timers.iterator(); i.hasNext();) {
javax.ejb.Timer ejbTimer = (javax.ejb.Timer) i.next();
TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
- if(timerInfo.matchesName(timerName, token)) {
+ if (timerInfo.matchesName(timerName, token)) {
ejbTimer.cancel();
+ ++count;
}
}
+ log.debug("canceled " + count + " ejb timer(s) by name '" + timerName + "' for " + token);
}
- public void deleteTimersForProcessInstance(ProcessInstance processInstance) {
- log.debug("deleting timers for process instance " + processInstance
- + " from the ejb timer service");
+ public void cancelTimersForProcessInstance(ProcessInstance processInstance) {
Collection timers = entityContext.getTimerService().getTimers();
+ log.debug("retrieved " + timers.size() + " timer(s) for " + processInstance);
+
+ int count = 0;
for (Iterator i = timers.iterator(); i.hasNext();) {
javax.ejb.Timer ejbTimer = (javax.ejb.Timer) i.next();
TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
- if(timerInfo.matchesProcessInstance(processInstance)) {
+ if (timerInfo.matchesProcessInstance(processInstance)) {
ejbTimer.cancel();
+ ++count;
}
}
+ log.debug("canceled " + count + " ejb timer(s) for " + processInstance);
}
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactoryImpl.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactoryImpl.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactoryImpl.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -30,8 +30,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmException;
import org.jbpm.ejb.impl.JobListenerBean;
import org.jbpm.svc.Service;
@@ -55,11 +53,11 @@
* Refer to the jBPM manual for details.
*
* @author Tom Baeyens
+ * @author Alejandro Guizar
*/
public class JmsMessageServiceFactoryImpl implements ServiceFactory {
private static final long serialVersionUID = 1L;
- private static final Log log = LogFactory.getLog(JmsMessageServiceFactoryImpl.class);
String connectionFactoryJndiName = "java:comp/env/jms/JbpmConnectionFactory";
String destinationJndiName = "java:comp/env/jms/JobQueue";
@@ -68,37 +66,55 @@
private ConnectionFactory connectionFactory;
private Destination destination;
- public JmsMessageServiceFactoryImpl() {
+ public ConnectionFactory getConnectionFactory() {
+ if (connectionFactory == null) {
+ try {
+ connectionFactory = (ConnectionFactory) lookup(connectionFactoryJndiName);
+ }
+ catch (NamingException e) {
+ throw new JbpmException("could not retrieve message connection factory", e);
+ }
+ }
+ return connectionFactory;
+ }
+
+ public Destination getDestination() {
+ if (destination == null) {
+ try {
+ destination = (Destination) lookup(destinationJndiName);
+ }
+ catch (NamingException e) {
+ throw new JbpmException("could not retrieve message destination", e);
+ }
+ }
+ return destination;
+ }
+
+ private static Object lookup(String name) throws NamingException {
+ Context initial = new InitialContext();
try {
- Context initial = new InitialContext();
- connectionFactory = (ConnectionFactory) initial.lookup(connectionFactoryJndiName);
- destination = (Destination) initial.lookup(destinationJndiName);
+ return initial.lookup(name);
+ }
+ finally {
initial.close();
}
- catch (NamingException e) {
- log.error("jms object lookup problem", e);
- throw new JbpmException("jms object lookup problem", e);
- }
}
public Service openService() {
- Connection connection = null;
- Session session = null;
-
try {
- connection = connectionFactory.createConnection();
-
+ Connection connection = getConnectionFactory().createConnection();
+
// If you use an XA connection factory in JBoss, the parameters will be ignored. It will always take part in the global JTA transaction.
- // If you use a non XQ connection factory, the first parameter specifies whether you want to have all message productions and
+ // If you use a non XA connection factory, the first parameter specifies whether you want to have all message productions and
// consumptions as part of one transaction (TRUE) or whether you want all productions and consumptions to be instantanious (FALSE)
// Of course, we never want messages to be received before the current jbpm transaction commits so we just set it to true.
- session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
- } catch (JMSException e) {
- throw new JbpmException("couldn't open jms message session", e);
- }
-
- return new JmsMessageServiceImpl(connection, session, destination, isCommitEnabled);
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+
+ return new JmsMessageServiceImpl(connection, session, getDestination(), isCommitEnabled);
+ }
+ catch (JMSException e) {
+ throw new JbpmException("couldn't open message session", e);
+ }
}
public void close() {
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerService.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerService.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -14,6 +14,10 @@
import org.jbpm.job.Timer;
import org.jbpm.scheduler.SchedulerService;
+/**
+ * @author Tom Baeyens
+ * @deprecated replaced by {@link EntitySchedulerService}
+ */
public class EjbSchedulerService implements SchedulerService {
private static final long serialVersionUID = 1L;
@@ -38,22 +42,28 @@
}
public void createTimer(Timer timer) {
- log.debug("creating timer "+timer);
+ log.debug("creating " + timer);
jobSession.saveJob(timer);
session.flush();
timerService.createTimer(timer);
}
+ public void deleteTimer(Timer timer) {
+ log.debug("deleting " + timer);
+ timerService.cancelTimer(timer);
+ jobSession.deleteJob(timer);
+ }
+
public void deleteTimersByName(String timerName, Token token) {
- log.debug("deleting timers by name "+timerName);
- jobSession.cancelTimersByName(timerName, token);
+ log.debug("deleting timers by name '" + timerName + "' for " + token);
timerService.cancelTimersByName(timerName, token);
+ jobSession.deleteTimersByName(timerName, token);
}
public void deleteTimersByProcessInstance(ProcessInstance processInstance) {
- log.debug("deleting timers for process instance "+processInstance);
+ log.debug("deleting timers for " + processInstance);
+ timerService.cancelTimersForProcessInstance(processInstance);
jobSession.deleteJobsForProcessInstance(processInstance);
- timerService.deleteTimersForProcessInstance(processInstance);
}
public void close() {
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerServiceFactory.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerServiceFactory.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerServiceFactory.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -4,34 +4,45 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmException;
import org.jbpm.svc.Service;
import org.jbpm.svc.ServiceFactory;
+/**
+ * @author Tom Baeyens
+ * @deprecated replaced by {@link EntitySchedulerServiceFactory}
+ */
public class EjbSchedulerServiceFactory implements ServiceFactory {
private static final long serialVersionUID = 1L;
- private static final Log log = LogFactory.getLog(EjbSchedulerServiceFactory.class);
-
String timerServiceHomeJndiName = "java:comp/env/ejb/LocalTimerServiceBean";
private LocalTimerServiceHome timerServiceHome;
- public EjbSchedulerServiceFactory() {
+ public LocalTimerServiceHome getTimerServiceHome() {
+ if (timerServiceHome == null) {
+ try {
+ timerServiceHome = (LocalTimerServiceHome) lookup(timerServiceHomeJndiName);
+ } catch (NamingException e) {
+ throw new JbpmException("ejb timer service lookup problem", e);
+ }
+ }
+ return timerServiceHome;
+ }
+
+ private static Object lookup(String name) throws NamingException {
+ Context initial = new InitialContext();
try {
- Context initial = new InitialContext();
- timerServiceHome = (LocalTimerServiceHome) initial.lookup(timerServiceHomeJndiName);
- } catch (NamingException e) {
- log.error("ejb timer service lookup problem", e);
- throw new JbpmException("ejb timer service lookup problem", e);
+ return initial.lookup(name);
}
+ finally {
+ initial.close();
+ }
}
public Service openService() {
- return new EjbSchedulerService(timerServiceHome);
+ return new EjbSchedulerService(getTimerServiceHome());
}
public void close() {
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -7,6 +7,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.Session;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.db.JobSession;
@@ -22,6 +23,7 @@
private static final long serialVersionUID = 1L;
JobSession jobSession;
+ Session session;
LocalTimerEntityHome timerEntityHome;
public EntitySchedulerService(LocalTimerEntityHome timerEntityHome) {
@@ -31,53 +33,61 @@
"instantiation of the EjbSchedulerService requires a current JbpmContext");
}
this.jobSession = jbpmContext.getJobSession();
+ this.session = jbpmContext.getSession();
this.timerEntityHome = timerEntityHome;
}
public void createTimer(Timer timer) {
- log.debug("creating timer " + timer);
+ log.debug("creating " + timer);
jobSession.saveJob(timer);
+ session.flush();
try {
LocalTimerEntity timerEntity = timerEntityHome.findByPrimaryKey(new Long(timer.getId()));
timerEntity.createTimer(timer);
}
catch (FinderException e) {
- log.error("failed to retrieve entity for timer " + timer, e);
+ log.error("failed to retrieve entity for " + timer, e);
}
}
- public void deleteTimersByName(String timerName, Token token) {
- log.debug("deleting timers by name " + timerName);
- Collection timerEntities = null;
+ public void deleteTimer(Timer timer) {
+ log.debug("deleting " + timer);
+ try {
+ LocalTimerEntity timerEntity = timerEntityHome.findByPrimaryKey(new Long(timer.getId()));
+ timerEntity.cancelTimer(timer);
+ }
+ catch (FinderException e) {
+ log.error("failed to retrieve entity for " + timer, e);
+ }
+ jobSession.deleteJob(timer);
+ }
+
+ public void deleteTimersByName(String timerName, Token token) {
try {
- if(timerName == null || timerName.equals("")) {
- timerEntities = timerEntityHome.findByTokenId(new Long(token.getId()));
- }
- else {
- timerEntities = timerEntityHome.findByTokenIdAndName(new Long(token.getId()), timerName);
- }
+ Collection timerEntities = timerEntityHome.findByNameAndTokenId(timerName, new Long(token.getId()));
+ log.debug("found " + timerEntities.size() + " timer entities by name '" + timerName + "' for " + token);
for (Iterator i = timerEntities.iterator(); i.hasNext();) {
LocalTimerEntity timerEntity = (LocalTimerEntity) i.next();
timerEntity.cancelTimersByName(timerName, token);
}
}
catch (FinderException e) {
- log.error("failed to retrieve timer entities for name " + timerName + " and token " + token, e);
+ log.error("failed to retrieve timer entities by name '" + timerName + "' for " + token, e);
}
- jobSession.cancelTimersByName(timerName, token);
+ jobSession.deleteTimersByName(timerName, token);
}
public void deleteTimersByProcessInstance(ProcessInstance processInstance) {
- log.debug("deleting timers for process instance " + processInstance);
try {
Collection timerEntities = timerEntityHome.findByProcessInstanceId(new Long(processInstance.getId()));
+ log.debug("found " + timerEntities.size() + " timer entities for " + processInstance);
for (Iterator i = timerEntities.iterator(); i.hasNext();) {
LocalTimerEntity timerEntity = (LocalTimerEntity) i.next();
- timerEntity.deleteTimersForProcessInstance(processInstance);
+ timerEntity.cancelTimersForProcessInstance(processInstance);
}
}
catch (FinderException e) {
- log.error("failed to retrieve timer entities for process instance " + processInstance, e);
+ log.error("failed to retrieve timer entities for " + processInstance, e);
}
jobSession.deleteJobsForProcessInstance(processInstance);
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerServiceFactory.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerServiceFactory.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerServiceFactory.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -4,8 +4,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmException;
import org.jbpm.ejb.LocalTimerEntityHome;
import org.jbpm.job.Timer;
@@ -28,30 +26,40 @@
* Refer to the jBPM manual for details.
*
* @author Tom Baeyens
+ * @author Alejandro Guizar
* @author Fady Matar
*/
public class EntitySchedulerServiceFactory implements ServiceFactory {
private static final long serialVersionUID = 1L;
- private static final Log log = LogFactory.getLog(EntitySchedulerServiceFactory.class);
+ String timerEntityHomeJndiName = "java:comp/env/ejb/TimerEntityBean";
- String timerEntityHomeJndiName = "java:comp/env/ejb/LocalTimerEntityBean";
-
private LocalTimerEntityHome timerEntityHome;
- public EntitySchedulerServiceFactory() {
+ public LocalTimerEntityHome getTimerEntityHome() {
+ if (timerEntityHome == null) {
+ try {
+ timerEntityHome = (LocalTimerEntityHome) lookup(timerEntityHomeJndiName);
+ } catch (NamingException e) {
+ throw new JbpmException("ejb timer entity lookup problem", e);
+ }
+ }
+ return timerEntityHome;
+ }
+
+ private static Object lookup(String name) throws NamingException {
+ Context initial = new InitialContext();
try {
- Context initial = new InitialContext();
- timerEntityHome = (LocalTimerEntityHome) initial.lookup(timerEntityHomeJndiName);
- } catch (NamingException e) {
- log.error("ejb timer entity lookup problem", e);
- throw new JbpmException("ejb timer entity lookup problem", e);
+ return initial.lookup(name);
}
+ finally {
+ initial.close();
+ }
}
public Service openService() {
- return new EntitySchedulerService(timerEntityHome);
+ return new EntitySchedulerService(getTimerEntityHome());
}
public void close() {
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -1,5 +1,8 @@
package org.jbpm.scheduler.ejbtimer;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmContext;
@@ -8,24 +11,37 @@
public class ExecuteTimerCommand implements Command {
+ private final long timerId;
+
private static final long serialVersionUID = 1L;
-
- long timerId;
public ExecuteTimerCommand(long timerId) {
this.timerId = timerId;
}
public Object execute(JbpmContext jbpmContext) throws Exception {
- Timer timer = (Timer) jbpmContext.getJobSession().getJob(timerId);
- if (timer!=null) {
- log.debug("executing timer "+timerId);
- timer.execute(jbpmContext);
- } else {
- log.info("execution of timer "+timerId+" was skipped cause the timer was deleted from the database");
+ Timer timer = jbpmContext.getJobSession().loadTimer(timerId);
+ timer.setLockOwner(getClass().getName()); // prevent others from removing timer
+ log.debug("executing " + timer);
+ try {
+ if (timer.execute(jbpmContext)) {
+ jbpmContext.getServices().getSchedulerService().deleteTimer(timer);
+ }
}
+ catch (RuntimeException e) {
+ // nothing to do but clean up and exit
+ throw e;
+ }
+ catch (Exception e) {
+ // save data about recoverable error condition
+ log.error("exception while executing " + timer, e);
+ StringWriter memoryWriter = new StringWriter();
+ e.printStackTrace(new PrintWriter(memoryWriter));
+ timer.setException(memoryWriter.toString());
+ timer.setRetries(timer.getRetries() - 1);
+ }
return timer;
}
- private static Log log = LogFactory.getLog(ExecuteTimerCommand.class);
+ private static final Log log = LogFactory.getLog(ExecuteTimerCommand.class);
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/LocalTimerService.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/LocalTimerService.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/LocalTimerService.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -32,7 +32,8 @@
public interface LocalTimerService extends javax.ejb.EJBLocalObject {
void createTimer(Timer timer);
+ void cancelTimer(Timer timer);
void cancelTimersByName(String timerName, Token token);
- void deleteTimersForProcessInstance(ProcessInstance processInstance);
+ void cancelTimersForProcessInstance(ProcessInstance processInstance);
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/TimerServiceBean.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/TimerServiceBean.java 2008-10-15 19:50:24 UTC (rev 2545)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/TimerServiceBean.java 2008-10-16 07:31:42 UTC (rev 2546)
@@ -23,6 +23,7 @@
import java.io.Serializable;
import java.rmi.RemoteException;
+import java.util.Collection;
import java.util.Iterator;
import javax.ejb.EJBException;
@@ -58,54 +59,78 @@
public void ejbCreate() {
}
- public void createTimer(Timer timer) {
+ public void createTimer(org.jbpm.job.Timer timer) {
TimerService timerService = sessionContext.getTimerService();
- log.debug("creating timer "+timer+" in the ejb timer service");
- timerService.createTimer(timer.getDueDate(), new TimerInfo(timer));
+ javax.ejb.Timer ejbTimer = timerService.createTimer(timer.getDueDate(), new TimerInfo(timer));
+ log.debug("created " + ejbTimer);
}
+ public void cancelTimer(org.jbpm.job.Timer timer) {
+ // TODO make the scanning of timers for cancellation optional by only deleting the timerjobs in the db.
+ // of course, the corresponding ejb timer notifications have to be ignored.
+
+ long timerId = timer.getId();
+ Collection timers = sessionContext.getTimerService().getTimers();
+ log.debug("examining " + timers.size() + " ejb timer(s) by id " + timerId);
+
+ int count = 0;
+ for (Iterator i = timers.iterator(); i.hasNext();) {
+ javax.ejb.Timer ejbTimer = (javax.ejb.Timer) i.next();
+ if (ejbTimer.getInfo() instanceof TimerInfo) {
+ TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
+ if (timerId == timerInfo.getTimerId()) {
+ ejbTimer.cancel();
+ ++count;
+ }
+ }
+ }
+ log.debug("canceled " + count + " ejb timer(s) by id " + timerId);
+ }
+
public void cancelTimersByName(String timerName, Token token) {
-
// TODO make the scanning of timers for cancellation optional by only deleting the timerjobs in the db.
// of course, the corresponding ejb timer notifications have to be ignored.
- log.debug("cancelling timers with name "+timerName+" from the ejb timer service");
+ Collection timers = sessionContext.getTimerService().getTimers();
+ log.debug("examining " + timers.size() + " ejb timer(s) by name '" + timerName + "' for " + token);
- TimerService timerService = sessionContext.getTimerService();
- Iterator iter = timerService.getTimers().iterator();
- while (iter.hasNext()) {
- javax.ejb.Timer ejbTimer = (javax.ejb.Timer) iter.next();
+ int count = 0;
+ for (Iterator i = timers.iterator(); i.hasNext();) {
+ javax.ejb.Timer ejbTimer = (javax.ejb.Timer) i.next();
if (ejbTimer.getInfo() instanceof TimerInfo) {
TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
if (timerInfo.matchesName(timerName, token)) {
ejbTimer.cancel();
+ ++count;
}
}
}
+ log.debug("canceled " + count + " ejb timer(s) by name '" + timerName + "' for " + token);
}
- public void deleteTimersForProcessInstance(ProcessInstance processInstance) {
-
+ public void cancelTimersForProcessInstance(ProcessInstance processInstance) {
// TODO make the scanning of timers for cancellation optional by only deleting the timerjobs in the db.
// of course, the corresponding ejb timer notifications have to be ignored.
+
+ Collection timers = sessionContext.getTimerService().getTimers();
+ log.debug("examining " + timers.size() + " timer(s) for " + processInstance);
- log.debug("deleting timers for process instance "+processInstance+" from the ejb timer service");
-
- TimerService timerService = sessionContext.getTimerService();
- Iterator iter = timerService.getTimers().iterator();
- while (iter.hasNext()) {
- javax.ejb.Timer ejbTimer = (javax.ejb.Timer) iter.next();
+ int count = 0;
+ for (Iterator i = timers.iterator(); i.hasNext();) {
+ javax.ejb.Timer ejbTimer = (javax.ejb.Timer) i.next();
if (ejbTimer.getInfo() instanceof TimerInfo) {
TimerInfo timerInfo = (TimerInfo) ejbTimer.getInfo();
if (timerInfo.matchesProcessInstance(processInstance)) {
ejbTimer.cancel();
+ ++count;
}
}
}
+ log.debug("canceled " + count + " ejb timer(s) for " + processInstance);
}
public void ejbTimeout(javax.ejb.Timer ejbTimer) {
- log.debug("ejb timer "+ejbTimer+" fires");
+ log.debug(ejbTimer + " fired");
String localCommandServiceJndiName = "java:comp/env/ejb/LocalCommandServiceBean";
try {
Context initial = new InitialContext();
@@ -146,6 +171,6 @@
}
public void ejbRemove() throws EJBException, RemoteException {
}
-
+
private static Log log = LogFactory.getLog(TimerServiceBean.class);
}
17 years, 6 months
JBoss JBPM SVN: r2545 - in jbpm3/trunk: modules/gwt-console and 1 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-15 15:50:24 -0400 (Wed, 15 Oct 2008)
New Revision: 2545
Modified:
jbpm3/trunk/modules/gwt-console/pom.xml
jbpm3/trunk/modules/gwt-console/server/pom.xml
jbpm3/trunk/pom.xml
Log:
Fix gson dependency
Modified: jbpm3/trunk/modules/gwt-console/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/pom.xml 2008-10-15 13:03:28 UTC (rev 2544)
+++ jbpm3/trunk/modules/gwt-console/pom.xml 2008-10-15 19:50:24 UTC (rev 2545)
@@ -16,9 +16,11 @@
<properties>
<gchart.version>2.2</gchart.version>
- <gwtext.version>2.0.5</gwtext.version>
+ <gwtext.version>2.0.5</gwtext.version>
<stax-api.version>1.0-2</stax-api.version>
<jaf.version>1.1</jaf.version>
+ <resteasy.version>1.0-beta-8</resteasy.version>
+ <gson.version>1.2.2</gson.version>
</properties>
<modules>
@@ -38,7 +40,7 @@
<groupId>com.google.gwt</groupId>
<artifactId>gchart</artifactId>
<version>${gchart.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
@@ -47,8 +49,18 @@
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
- <version>${jaf.version}</version>
+ <version>${jaf.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
</project>
Modified: jbpm3/trunk/modules/gwt-console/server/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/pom.xml 2008-10-15 13:03:28 UTC (rev 2544)
+++ jbpm3/trunk/modules/gwt-console/server/pom.xml 2008-10-15 19:50:24 UTC (rev 2545)
@@ -55,13 +55,10 @@
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
- <version>1.0-beta-8</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>1.2.1</version>
- <scope>compile</scope>
+ <artifactId>gson</artifactId>
</dependency>
</dependencies>
@@ -87,18 +84,5 @@
</plugin>
</plugins>
<finalName>gwt-console-server</finalName>
- </build>
-
- <repositories>
- <repository>
- <id>gson</id>
- <url>http://google-gson.googlecode.com/svn/mavenrepo</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
+ </build>
</project>
Modified: jbpm3/trunk/pom.xml
===================================================================
--- jbpm3/trunk/pom.xml 2008-10-15 13:03:28 UTC (rev 2544)
+++ jbpm3/trunk/pom.xml 2008-10-15 19:50:24 UTC (rev 2545)
@@ -31,7 +31,7 @@
<module>modules/console</module>
<module>modules/core</module>
<module>modules/enterprise</module>
- <module>modules/examples</module>
+ <module>modules/examples</module>
<module>modules/identity</module>
<module>modules/jbpm4jsf</module>
<module>modules/simulation</module>
@@ -414,7 +414,7 @@
<!--
Name: distro
- Desc: Build the distribution
+ Desc: Build the distribution
-->
<profile>
<id>distro</id>
@@ -437,7 +437,7 @@
<!--
Name: skiptests
- Desc: Skips the tests
+ Desc: Skips the tests
-->
<profile>
<id>skiptests</id>
@@ -455,9 +455,9 @@
<!-- DATABASE PROFILES ***************************************************************************** -->
- <!--
+ <!--
Name: no-database
- Descr: Setup the default database
+ Descr: Setup the default database
-->
<profile>
<id>no-database</id>
@@ -478,9 +478,9 @@
</dependencies>
</profile>
- <!--
+ <!--
Name: hsqldb
- Descr: Hypersonic Database Setup
+ Descr: Hypersonic Database Setup
-->
<profile>
<id>hsqldb</id>
@@ -499,9 +499,9 @@
</dependencies>
</profile>
- <!--
+ <!--
Name: mysql
- Descr: MySQL Database Setup
+ Descr: MySQL Database Setup
-->
<profile>
<id>mysql</id>
@@ -520,9 +520,9 @@
</dependencies>
</profile>
- <!--
+ <!--
Name: postgresql
- Descr: MySQL Database Setup
+ Descr: MySQL Database Setup
-->
<profile>
<id>postgresql</id>
@@ -542,9 +542,9 @@
</dependencies>
</profile>
- <!--
+ <!--
Name: sybase
- Descr: Sybase Database Setup
+ Descr: Sybase Database Setup
-->
<profile>
<id>sybase</id>
17 years, 6 months
JBoss JBPM SVN: r2544 - in jbpm3/trunk/modules/gwt-console: rpc/src/main/java/org/jboss/bpm/console/client/model/util and 5 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-15 09:03:28 -0400 (Wed, 15 Oct 2008)
New Revision: 2544
Added:
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java
Modified:
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
Log:
Instance status and date formatting fixed
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -36,23 +36,46 @@
private long parentId;
private String key;
- private String status;
+ private enum STATE {CREATED, STARTED, SUSPENDED, ENDED};
+
private Date startDate;
private Date endDate;
+ private boolean suspended;
+
+ private STATE state; // gson is field based, hence why...
+
+ private transient Lifecycle lifecycle;
+
public ProcessInstance()
{
+ initLifecycle();
}
- public ProcessInstance(long id, long parentId, String status, Date startDate, Date endDate)
+ public ProcessInstance(long id, long parentId, Date startDate, Date endDate, boolean suspended)
{
this.instanceId = id;
this.parentId = parentId;
- this.status = status;
this.startDate = startDate;
this.endDate = endDate;
+ this.suspended = suspended;
+ initLifecycle();
}
+ private void initLifecycle()
+ {
+ if(hasEnded())
+ this.lifecycle = new Lifecycle(STATE.ENDED);
+ else if(isSuspended())
+ this.lifecycle = new Lifecycle(STATE.SUSPENDED);
+ else if (isStarted())
+ this.lifecycle = new Lifecycle(STATE.STARTED);
+ else
+ this.lifecycle = new Lifecycle(STATE.CREATED);
+
+ this.state = lifecycle.getState();
+ }
+
@XmlElement(name = "instanceId")
public long getInstanceId()
{
@@ -87,14 +110,15 @@
}
@XmlElement(name = "status")
- public String getStatus()
+ public STATE getState()
{
- return status;
+ return this.state;
}
- public void setStatus(String status)
+ public void setState(STATE nextState)
{
- this.status = status;
+ this.lifecycle = this.lifecycle.transitionTo(nextState);
+ this.state = this.lifecycle.getState();
}
@XmlElement(name = "start")
@@ -119,4 +143,86 @@
this.endDate = endDate;
}
+ public boolean isStarted()
+ {
+ return this.startDate!=null;
+ }
+
+ public boolean hasEnded()
+ {
+ return isStarted() && this.endDate!=null;
+ }
+
+ public boolean isSuspended()
+ {
+ return isStarted() && suspended;
+ }
+
+ public void setSuspended(boolean suspended)
+ {
+ this.suspended = suspended;
+ }
+
+ private class Lifecycle
+ {
+ private STATE current;
+
+ public Lifecycle(STATE current)
+ {
+ this.current = current;
+ }
+
+ public Lifecycle transitionTo(STATE next)
+ {
+ Lifecycle nextLifecycle = null;
+
+ switch(next)
+ {
+ case STARTED:
+ if(!STATE.ENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(next);
+ }
+ break;
+ case SUSPENDED:
+ if(STATE.STARTED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(next);
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ case ENDED:
+ if(STATE.STARTED.equals(current) || STATE.SUSPENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(next);
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ default:
+ throw new IllegalTransitionException(current, next);
+ }
+
+ return nextLifecycle;
+ }
+
+ public STATE getState()
+ {
+ return current;
+ }
+ }
+
+ private class IllegalTransitionException extends IllegalArgumentException
+ {
+
+ public IllegalTransitionException(STATE current, STATE next)
+ {
+ super("Illegal transition current " + current + " next " + next);
+ }
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -21,6 +21,8 @@
public class SimpleDateFormat {
private String format;
private DateLocale locale = new DateLocale();
+ public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
/**
* Gets the support locale for formatting and parsing dates
@@ -34,6 +36,17 @@
this.locale = locale;
}
+ /**
+ * Use {@link #DEFAULT_FORMAT}
+ */
+ public SimpleDateFormat()
+ {
+ format = DEFAULT_FORMAT;
+ }
+
+ /**
+ * Use a custom format
+ */
public SimpleDateFormat(String pattern) {
format = pattern;
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -51,12 +51,12 @@
final static List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
static
{
- instances.add( new ProcessInstance(2, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(3, -1, "Stopped", new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12))));
- instances.add( new ProcessInstance(4, -1, "Ended", new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24))));
- instances.add( new ProcessInstance(5, -1, "Suspended", new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17))));
- instances.add( new ProcessInstance(6, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(7, -1, "Running", new Date(), null));
+ instances.add( new ProcessInstance(2, -1, new Date(), null, false));
+ instances.add( new ProcessInstance(3, -1, new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12)), false));
+ instances.add( new ProcessInstance(4, -1, new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24)), false));
+ instances.add( new ProcessInstance(5, -1, new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17)), false));
+ instances.add( new ProcessInstance(6, -1, new Date(), null, true));
+ instances.add( new ProcessInstance(7, -1, new Date(), null, true));
}
public List<ProcessDefinition> getAllDefinitions()
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -37,10 +37,12 @@
}
public static ProcessInstance processInstance(org.jbpm.graph.exe.ProcessInstance i0)
- {
- // TODO: status?
+ {
Date start = i0.getStart();
Date end = i0.getEnd();
- return new ProcessInstance(i0.getId(), i0.getProcessDefinition().getId(), "Unknown", start, end);
+ boolean suspended = i0.isSuspended();
+ long processId = i0.getProcessDefinition().getId();
+ long instanceId = i0.getId();
+ return new ProcessInstance(instanceId, processId, start, end, suspended);
}
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -21,8 +21,8 @@
*/
package org.jboss.bpm.console.client.model.internal;
+import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.model.ProcessInstanceDAO;
-import org.jboss.bpm.console.client.model.ProcessInstance;
import java.util.ArrayList;
import java.util.Date;
@@ -37,12 +37,12 @@
final static List instances = new ArrayList();
static
{
- instances.add( new ProcessInstance(2, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(3, -1, "Stopped", new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12))));
- instances.add( new ProcessInstance(4, -1, "Ended", new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24))));
- instances.add( new ProcessInstance(5, -1, "Suspended", new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17))));
- instances.add( new ProcessInstance(6, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(7, -1, "Running", new Date(), null));
+ instances.add( new ProcessInstance(2, -1, new Date(), null, false));
+ instances.add( new ProcessInstance(3, -1, new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12)), false));
+ instances.add( new ProcessInstance(4, -1, new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24)), false));
+ instances.add( new ProcessInstance(5, -1, new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17)), false));
+ instances.add( new ProcessInstance(6, -1, new Date(), null, false));
+ instances.add( new ProcessInstance(7, -1, new Date(), null, false));
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -28,6 +28,7 @@
import com.gwtext.client.widgets.grid.ColumnConfig;
import com.gwtext.client.widgets.grid.ColumnModel;
import org.jboss.bpm.console.client.ConsoleView;
+import org.jboss.bpm.console.client.util.DateRenderer;
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.widgets.RemoteListView;
@@ -121,10 +122,9 @@
ProcessInstance pd = new ProcessInstance(
id,
Long.valueOf( r.getAsString("parentId")),
- r.getAsString("status"),
r.getAsDate("startDate"),
- r.getAsDate("endDate")
- );
+ r.getAsDate("endDate"),
+ r.getAsBoolean("suspended"));
row2InstanceMap.put(i, pd);
i++;
@@ -134,16 +134,16 @@
}
protected ColumnModel createColumnModel()
- {
+ {
final ColumnModel columnModel = new ColumnModel(
new ColumnConfig[]
{
new ColumnConfig("Instance ID", "instanceId", 75, true),
//new ColumnConfig("Process ID", "parentId", 25, true),
//new ColumnConfig("Key", "key", 50, true),
- new ColumnConfig("Status", "status", 100, true, null, "expand"),
- new ColumnConfig("Start Date", "startDate", 125, true),
- new ColumnConfig("End Date", "endDate", 125, true)
+ new ColumnConfig("State", "state", 100, true, null, "expand"),
+ new ColumnConfig("Start Date", "startDate", 125, true, new DateRenderer("startDate")),
+ new ColumnConfig("End Date", "endDate", 125, true, new DateRenderer("endDate"))
}
);
@@ -157,7 +157,7 @@
new IntegerFieldDef("instanceId"),
new IntegerFieldDef("parentId"),
new StringFieldDef("key"),
- new StringFieldDef("status"),
+ new StringFieldDef("state"),
new DateFieldDef("startDate", DATE_FORMAT),
new DateFieldDef("endDate", DATE_FORMAT)
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -91,7 +91,7 @@
//the field names must match the data field values from the Store
fieldSet.add(new TextField("Id", "instanceId", 230));
fieldSet.add(new TextField("Key", "key", 230));
- fieldSet.add(new TextField("Status", "status", 230));
+ fieldSet.add(new TextField("State", "state", 230));
fieldSet.add(new DateField("Start Date", "startDate", 230));
fieldSet.add(new DateField("End Date", "endDate", 230));
Panel inner = new PaddedPanel(fieldSet, 0, 10, 0, 0);
Added: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.client.util;
+
+import com.gwtext.client.widgets.grid.Renderer;
+import com.gwtext.client.widgets.grid.CellMetadata;
+import com.gwtext.client.data.Store;
+import com.gwtext.client.data.Record;
+
+import java.util.Date;
+
+import org.jboss.bpm.console.client.model.util.SimpleDateFormat;
+
+/**
+ * Renders a Date according to {@link org.jboss.bpm.console.client.model.util.SimpleDateFormat#DEFAULT_FORMAT}
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class DateRenderer implements Renderer
+{
+ private String fieldName;
+
+ public DateRenderer(String fieldName)
+ {
+ this.fieldName = fieldName;
+ }
+
+ /**
+ * Returns an empty string (field is null) or a formatted date (field is set).
+ */
+ public String render(Object value, CellMetadata cellMetadata, Record record,
+ int rowIndex, int colNum, Store store)
+ {
+ String s = "";
+ SimpleDateFormat df = new SimpleDateFormat();
+ Date d = record.getAsDate(fieldName);
+ if(d!=null)
+ s = df.format(d);
+
+ return s;
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -132,7 +132,7 @@
pagingToolbar.setPageSize(PAGE_SIZE);
pagingToolbar.setDisplayInfo(true);
pagingToolbar.setDisplayMsg("{0} - {1} of {2}");
- pagingToolbar.setEmptyMsg("No topics to display");
+ pagingToolbar.setEmptyMsg("No entities to display");
pagingToolbar.addButton(
new ToolbarButton("Examine", new ButtonListenerAdapter() {
17 years, 6 months
JBoss JBPM SVN: r2543 - in jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server: dao and 2 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-15 05:42:59 -0400 (Wed, 15 Oct 2008)
New Revision: 2543
Added:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/util/
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/util/ServiceLocator.java
Removed:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/ServiceLocator.java
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java
Log:
Implement process diagram lookup and added DAOProxy for TX handling
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-15 07:59:29 UTC (rev 2542)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -24,8 +24,8 @@
import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
import org.jboss.bpm.console.server.dao.DAOFactory;
+import org.jboss.bpm.console.server.dao.DiagramDAO;
import org.jboss.bpm.console.server.dao.ProcessDAO;
-import org.jboss.bpm.console.server.dao.DiagramDAO;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
@@ -108,7 +108,8 @@
HttpServletRequest request
)
{
- return getDiagramDAO(request).getActivNodeInfo(id);
+ ActiveNodeInfo activNodeInfo = getDiagramDAO(request).getActivNodeInfo(id);
+ return activNodeInfo;
}
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java 2008-10-15 07:59:29 UTC (rev 2542)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -24,6 +24,8 @@
import org.jboss.bpm.console.server.dao.DiagramDAO;
import javax.servlet.ServletContext;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -49,7 +51,7 @@
try
{
- return (DAOFactory)Class.forName(daoFactoryClassName).newInstance();
+ return (DAOFactory)Class.forName(daoFactoryClassName).newInstance();
}
catch (Exception e)
{
Added: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.server.dao;
+
+import org.jboss.bpm.console.server.util.ServiceLocator;
+
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+import java.lang.reflect.Method;
+
+/**
+ * Decorates DAO invocations with common system aspects, i.e. transaction demarcation.
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class DAOProxy implements java.lang.reflect.InvocationHandler
+{
+ private Object obj;
+
+ public static Object newInstance(Object obj) {
+ return java.lang.reflect.Proxy.newProxyInstance(
+ obj.getClass().getClassLoader(),
+ obj.getClass().getInterfaces(),
+ new DAOProxy(obj));
+ }
+
+ private DAOProxy(Object obj) {
+ this.obj = obj;
+ }
+
+ public Object invoke(Object proxy, Method m, Object[] args)
+ throws Throwable
+ {
+ Object result;
+
+ UserTransaction tx = ServiceLocator.getUserTransaction();
+
+ try
+ {
+ // before method invocation
+ tx.begin();
+
+ // field target invocation
+ result = m.invoke(obj, args);
+
+ tx.commit();
+
+ }
+ catch (Exception e)
+ {
+ if(tx!=null)
+ {
+ try
+ {
+ tx.rollback();
+ }
+ catch (SystemException e1) {}
+ }
+
+ throw new RuntimeException("Unexpected invocation exception: " + e.getMessage(), e);
+
+ }
+ finally
+ {
+ // after method invocation
+
+ }
+
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOProxy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-15 07:59:29 UTC (rev 2542)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -27,6 +27,7 @@
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
import org.jbpm.graph.def.ProcessDefinition;
+import org.jboss.bpm.console.server.util.ServiceLocator;
import javax.ejb.CreateException;
import java.util.List;
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java 2008-10-15 07:59:29 UTC (rev 2542)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DAOFactory.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -24,6 +24,7 @@
import org.jboss.bpm.console.server.dao.DAOFactory;
import org.jboss.bpm.console.server.dao.ProcessDAO;
import org.jboss.bpm.console.server.dao.DiagramDAO;
+import org.jboss.bpm.console.server.dao.DAOProxy;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -33,11 +34,11 @@
public ProcessDAO createProcessDAO()
{
- return new JBPM3ProcessDAO();
+ return (ProcessDAO) DAOProxy.newInstance(new JBPM3ProcessDAO());
}
public DiagramDAO createDiagramDAO()
{
- return new JBPM3DiagramDAO();
+ return (DiagramDAO) DAOProxy.newInstance( new JBPM3DiagramDAO() );
}
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java 2008-10-15 07:59:29 UTC (rev 2542)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -23,9 +23,11 @@
import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramNodeInfo;
import org.jboss.bpm.console.server.dao.DiagramDAO;
import java.io.InputStream;
+import java.util.List;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -33,7 +35,7 @@
public class JBPM3DiagramDAO implements DiagramDAO
{
private JBPM3CommandDelegate delegate;
-
+
private static final String PROCESSIMAGE_FILENAME = "processimage.jpg";
private static final String GPD_XML_FILENAME = "gpd.xml";
@@ -57,7 +59,26 @@
public ActiveNodeInfo getActivNodeInfo(long instanceId)
{
-
- throw new RuntimeException("Not implemented");
+ org.jbpm.graph.exe.ProcessInstance instance = delegate.getActualInstance(instanceId);
+ String currentNodeName = instance.getRootToken().getNode().getName();
+
+ DiagramInfo diagram = getDiagramInfo(instance.getProcessDefinition().getId());
+ List<DiagramNodeInfo> nodes = diagram.getNodeList();
+
+ DiagramNodeInfo activeNode = null;
+ int i = 0;
+ for(DiagramNodeInfo n : nodes)
+ {
+ if(currentNodeName.equals(n.getName()))
+ {
+ activeNode = n;
+ break;
+ }
+ }
+
+ if(null==activeNode)
+ throw new RuntimeException("Failed to retrieve activeNodeInfo for instance " + instanceId);
+
+ return new ActiveNodeInfo(diagram.getWidth(), diagram.getHeight(), activeNode);
}
}
Deleted: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/ServiceLocator.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/ServiceLocator.java 2008-10-15 07:59:29 UTC (rev 2542)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/ServiceLocator.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.server.dao.internal;
-
-import javax.ejb.EJBLocalHome;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class ServiceLocator
-{
- public static EJBLocalHome getEjbLocalHome(String localHomeJndiName)
- {
- EJBLocalHome localHome = null;
- try
- {
- Context ctx = new InitialContext();
- localHome = (EJBLocalHome) ctx.lookup(localHomeJndiName);
- }
- catch (Exception cce)
- {
- throw new RuntimeException("Failed load access EJB: " +localHomeJndiName, cce);
- }
-
- return localHome;
- }
-
-}
\ No newline at end of file
Copied: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/util/ServiceLocator.java (from rev 2538, jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/ServiceLocator.java)
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/util/ServiceLocator.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/util/ServiceLocator.java 2008-10-15 09:42:59 UTC (rev 2543)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.server.util;
+
+import javax.ejb.EJBLocalHome;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+import java.util.Properties;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class ServiceLocator
+{
+ public static EJBLocalHome getEjbLocalHome(String localHomeJndiName)
+ {
+ EJBLocalHome localHome = null;
+ try
+ {
+ Context ctx = createContext();
+ localHome = (EJBLocalHome) ctx.lookup(localHomeJndiName);
+ }
+ catch (Exception cce)
+ {
+ throw new RuntimeException("Failed load access EJB: " +localHomeJndiName, cce);
+ }
+
+ return localHome;
+ }
+
+ public static UserTransaction getUserTransaction()
+ {
+ UserTransaction tx = null;
+
+ try
+ {
+ Context ctx = createContext();
+ tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to create UserTransaction");
+ }
+
+ return tx;
+ }
+
+ private static Context createContext()
+ throws NamingException
+ {
+ InitialContext ctx = new InitialContext();
+ return ctx;
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/util/ServiceLocator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 6 months
JBoss JBPM SVN: r2542 - in jbpm3/trunk/modules/gwt-console: rpc/src/main/java/org/jboss/bpm/console/client/model/util and 5 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-15 03:59:29 -0400 (Wed, 15 Oct 2008)
New Revision: 2542
Added:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java
Modified:
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/DateLocale.java
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateParser.java
jbpm3/trunk/modules/gwt-console/server/pom.xml
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
Log:
JBPM3 DAO implementations based on the CommandServiceBean, first cut
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -22,8 +22,6 @@
package org.jboss.bpm.console.client.model;
-import org.jboss.bpm.console.client.model.util.SimpleDateFormat;
-
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
@@ -34,7 +32,7 @@
@XmlRootElement(name="processInstance")
public class ProcessInstance
{
- private long Id;
+ private long instanceId;
private long parentId;
private String key;
@@ -48,7 +46,7 @@
public ProcessInstance(long id, long parentId, String status, Date startDate, Date endDate)
{
- this.Id = id;
+ this.instanceId = id;
this.parentId = parentId;
this.status = status;
this.startDate = startDate;
@@ -56,14 +54,14 @@
}
@XmlElement(name = "instanceId")
- public long getId()
+ public long getInstanceId()
{
- return Id;
+ return instanceId;
}
- public void setId(long id)
+ public void setInstanceId(long instanceId)
{
- Id = id;
+ this.instanceId = instanceId;
}
@XmlElement(name = "parentId")
@@ -100,10 +98,9 @@
}
@XmlElement(name = "start")
- public String getStartDate()
+ public Date getStartDate()
{
- SimpleDateFormat df = new SimpleDateFormat("y-M-d H:mm:ss");
- return df.format(startDate);
+ return startDate;
}
public void setStartDate(Date startDate)
@@ -112,15 +109,9 @@
}
@XmlElement(name = "end")
- public String getEndDate()
+ public Date getEndDate()
{
- String s = "";
- if(endDate!=null)
- {
- SimpleDateFormat df = new SimpleDateFormat("y-M-d H:m:s");
- s = df.format(endDate);
- }
- return s;
+ return endDate;
}
public void setEndDate(Date endDate)
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/DateLocale.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/DateLocale.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/DateLocale.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -1,23 +1,17 @@
/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
+ * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
*
- * 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * 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.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.jboss.bpm.console.client.model.util;
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -1,31 +1,22 @@
/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
+ * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
*
- * 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * 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.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.jboss.bpm.console.client.model.util;
import java.util.Date;
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
@SuppressWarnings("deprecation")
public class SimpleDateFormat {
private String format;
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateParser.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateParser.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateParser.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -1,23 +1,17 @@
/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
+ * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
*
- * 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.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * 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.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * 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.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.jboss.bpm.console.client.model.util;
Modified: jbpm3/trunk/modules/gwt-console/server/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/pom.xml 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/pom.xml 2008-10-15 07:59:29 UTC (rev 2542)
@@ -57,6 +57,12 @@
<artifactId>resteasy-jaxrs</artifactId>
<version>1.0-beta-8</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>1.2.1</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
@@ -82,4 +88,17 @@
</plugins>
<finalName>gwt-console-server</finalName>
</build>
+
+ <repositories>
+ <repository>
+ <id>gson</id>
+ <url>http://google-gson.googlecode.com/svn/mavenrepo</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
</project>
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/BufferedResponseWrapper.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -31,6 +31,7 @@
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
+@SuppressWarnings("deprecation")
public class BufferedResponseWrapper extends HttpServletResponseWrapper
{
private ByteArrayOutputStream output;
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -108,7 +108,7 @@
HttpServletRequest request
)
{
- return getDiagramDAO(request).getActivNodeInfo(getProcessDAO(request), id);
+ return getDiagramDAO(request).getActivNodeInfo(id);
}
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -21,15 +21,18 @@
*/
package org.jboss.bpm.console.server;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import org.jboss.bpm.console.client.model.ProcessDefinitionWrapper;
import org.jboss.bpm.console.client.model.ProcessInstanceWrapper;
import org.jboss.bpm.console.server.dao.DAOFactory;
import org.jboss.bpm.console.server.dao.ProcessDAO;
+import org.jboss.bpm.console.server.gson.GsonFactory;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
/**
* REST server module for accessing process related data.
@@ -58,48 +61,64 @@
@GET
@Path("definitions")
@Produces("application/json")
- public ProcessDefinitionWrapper getDefinitionsJSON(
+ public Response getDefinitionsJSON(
@Context
HttpServletRequest request
)
- {
- return new ProcessDefinitionWrapper( getProcessDAO(request).getAllDefinitions() );
+ {
+ ProcessDefinitionWrapper wrapper =
+ new ProcessDefinitionWrapper(getProcessDAO(request).getAllDefinitions());
+ return createJsonResponse(wrapper);
}
@POST
@Path("definitions/{id}/remove")
@Produces("application/json")
- public ProcessDefinitionWrapper removeDefinitionsJSON(
+ public Response removeDefinitionsJSON(
@PathParam("id")
long processId,
@Context
HttpServletRequest request
)
{
- return new ProcessDefinitionWrapper( getProcessDAO(request).removeDefinition(processId) );
+ ProcessDefinitionWrapper wrapper =
+ new ProcessDefinitionWrapper( getProcessDAO(request).removeDefinition(processId));
+ return createJsonResponse(wrapper);
}
@GET
@Path("definitions/{id}/instances")
@Produces("application/json")
- public ProcessInstanceWrapper getInstancesJSON(
+ public Response getInstancesJSON(
@PathParam("id")
long processId,
@Context
HttpServletRequest request)
{
- return new ProcessInstanceWrapper( getProcessDAO(request).getInstancesByProcessId(processId) );
+
+ ProcessInstanceWrapper wrapper =
+ new ProcessInstanceWrapper(getProcessDAO(request).getInstancesByProcessId(processId));
+ return createJsonResponse(wrapper);
}
@POST
@Path("instances/{id}/remove")
@Produces("application/json")
- public ProcessInstanceWrapper removeInstancesJSON(
+ public Response removeInstancesJSON(
@PathParam("id")
long instanceId,
@Context
HttpServletRequest request)
{
- return new ProcessInstanceWrapper( getProcessDAO(request).removeInstance(instanceId) );
+ ProcessInstanceWrapper wrapper =
+ new ProcessInstanceWrapper(getProcessDAO(request).removeInstance(instanceId));
+ return createJsonResponse(wrapper);
}
+
+ private Response createJsonResponse(Object wrapper)
+ {
+ Gson gson = GsonFactory.createInstance();
+ String json = gson.toJson(wrapper);
+ return Response.ok(json).type("application/json").build();
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -34,5 +34,5 @@
DiagramInfo getDiagramInfo(long processId);
- ActiveNodeInfo getActivNodeInfo(ProcessDAO processDAO, long instanceId);
+ ActiveNodeInfo getActivNodeInfo(long instanceId);
}
Added: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.server.dao.internal;
+
+import org.jbpm.command.GetProcessDefinitionsCommand;
+import org.jbpm.command.GetProcessInstanceCommand;
+import org.jbpm.command.GetProcessInstancesCommand;
+import org.jbpm.ejb.LocalCommandService;
+import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.graph.def.ProcessDefinition;
+
+import javax.ejb.CreateException;
+import java.util.List;
+
+/**
+ * Adopts a business interface to the command facade.<br>
+ * Depends on the CommandServiceBean (<code>java:ejb/CommandServiceBean</code>).
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+class JBPM3CommandDelegate
+{
+
+ private LocalCommandService facade;
+ private static final String DEFAULT_JNDI_NAME = "java:ejb/CommandServiceBean";
+
+ /**
+ * Lookup with particluar JNDI name.
+ * @param jndiName
+ */
+ public JBPM3CommandDelegate(String jndiName)
+ {
+ ejbLookup(jndiName);
+ }
+
+ /**
+ * Lookup using default JNDI name.
+ *
+ * @see #DEFAULT_JNDI_NAME
+ */
+
+ public JBPM3CommandDelegate()
+ {
+ ejbLookup(DEFAULT_JNDI_NAME);
+ }
+
+ private void ejbLookup(String jndiName)
+ {
+ try
+ {
+ LocalCommandServiceHome home = (LocalCommandServiceHome)
+ ServiceLocator.getEjbLocalHome(jndiName);
+ this.facade = home.create();
+ }
+ catch (CreateException e)
+ {
+ throw new RuntimeException("Failed to create LocalCommandService", e);
+ }
+ }
+
+ public List<ProcessDefinition> getActualDefinitions()
+ {
+ List<org.jbpm.graph.def.ProcessDefinition> defs = (List<org.jbpm.graph.def.ProcessDefinition>)
+ facade.execute( new GetProcessDefinitionsCommand() );
+ return defs;
+ }
+
+ public org.jbpm.graph.def.ProcessDefinition getActualDefinition(long processId)
+ {
+ List<org.jbpm.graph.def.ProcessDefinition> defs = getActualDefinitions();
+
+ org.jbpm.graph.def.ProcessDefinition match = null;
+ for(org.jbpm.graph.def.ProcessDefinition p0 : defs)
+ {
+ if(processId == p0.getId())
+ {
+ match = p0;
+ break;
+ }
+ }
+
+ if(null==match)
+ throw new IllegalArgumentException("No process definition with ID " + processId);
+
+ return match;
+ }
+
+ public org.jbpm.graph.exe.ProcessInstance getActualInstance(long instanceId)
+ {
+ org.jbpm.graph.exe.ProcessInstance instance = (org.jbpm.graph.exe.ProcessInstance)
+ facade.execute( new GetProcessInstanceCommand(instanceId));
+ return instance;
+ }
+
+ public List<org.jbpm.graph.exe.ProcessInstance> getActualInstances(long processId)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = getActualDefinition(processId);
+ GetProcessInstancesCommand command = new GetProcessInstancesCommand();
+ command.setProcessName(p0.getName());
+
+ List<org.jbpm.graph.exe.ProcessInstance> instances =
+ (List<org.jbpm.graph.exe.ProcessInstance>) facade.execute(command);
+
+ return instances;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3DiagramDAO.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -21,29 +21,43 @@
*/
package org.jboss.bpm.console.server.dao.internal;
+import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
import org.jboss.bpm.console.server.dao.DiagramDAO;
-import org.jboss.bpm.console.server.dao.ProcessDAO;
-import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
-import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import java.io.InputStream;
+
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public class JBPM3DiagramDAO implements DiagramDAO
{
+ private JBPM3CommandDelegate delegate;
+
+ private static final String PROCESSIMAGE_FILENAME = "processimage.jpg";
+ private static final String GPD_XML_FILENAME = "gpd.xml";
+ public JBPM3DiagramDAO()
+ {
+ this.delegate = new JBPM3CommandDelegate();
+ }
+
public byte[] getProcessImage(long processId)
{
- return new byte[0];
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ return p0.getFileDefinition().getBytes(PROCESSIMAGE_FILENAME);
}
public DiagramInfo getDiagramInfo(long processId)
{
- return null;
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
+ InputStream in = p0.getFileDefinition().getInputStream(GPD_XML_FILENAME);
+ return DiagramInfoParser.parse(in);
}
- public ActiveNodeInfo getActivNodeInfo(ProcessDAO processDAO, long instanceId)
+ public ActiveNodeInfo getActivNodeInfo(long instanceId)
{
- return null;
+
+ throw new RuntimeException("Not implemented");
}
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -24,42 +24,25 @@
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.server.dao.ProcessDAO;
-import org.jbpm.ejb.LocalCommandService;
-import org.jbpm.ejb.LocalCommandServiceHome;
-import org.jbpm.command.GetProcessDefinitionsCommand;
-import org.jbpm.command.GetProcessDefinitionCommand;
-import org.jbpm.command.GetProcessInstanceCommand;
-import org.jbpm.command.GetProcessInstancesCommand;
-import javax.ejb.CreateException;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public class JBPM3ProcessDAO implements ProcessDAO
{
- private LocalCommandService facade;
+ private JBPM3CommandDelegate delegate;
public JBPM3ProcessDAO()
{
- try
- {
- LocalCommandServiceHome home = (LocalCommandServiceHome)
- ServiceLocator.getEjbLocalHome("java:ejb/CommandServiceBean");
- this.facade = home.create();
- }
- catch (CreateException e)
- {
- throw new RuntimeException("Failed to create LocalCommandService", e);
- }
+ this.delegate = new JBPM3CommandDelegate();
}
public List<ProcessDefinition> getAllDefinitions()
{
- List<org.jbpm.graph.def.ProcessDefinition> defs = (List<org.jbpm.graph.def.ProcessDefinition>)
- facade.execute( new GetProcessDefinitionsCommand() );
+ List<org.jbpm.graph.def.ProcessDefinition> defs = delegate.getActualDefinitions();
List<ProcessDefinition> results = new ArrayList<ProcessDefinition>(defs.size());
for(org.jbpm.graph.def.ProcessDefinition p0 : defs)
@@ -71,25 +54,7 @@
public ProcessDefinition getDefinitionById(long processId)
{
- List<ProcessDefinition> defs = getAllDefinitions();
- ProcessDefinition parent = null;
- for(ProcessDefinition p : defs)
- {
- if(processId == p.getProcessId())
- {
- parent = p;
- break;
- }
- }
-
- if(null==parent)
- throw new IllegalArgumentException("No process definition with ID " + processId);
-
- GetProcessDefinitionCommand command = new GetProcessDefinitionCommand();
- command.setName(parent.getName());
-
- org.jbpm.graph.def.ProcessDefinition p0 = (org.jbpm.graph.def.ProcessDefinition)
- facade.execute(command);
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.getActualDefinition(processId);
return Transform.processDefinition(p0);
}
@@ -100,13 +65,7 @@
public List<ProcessInstance> getInstancesByProcessId(long processId)
{
- ProcessDefinition parent = getDefinitionById(processId);
- GetProcessInstancesCommand command = new GetProcessInstancesCommand();
- command.setProcessName(parent.getName());
-
- List<org.jbpm.graph.exe.ProcessInstance> instances =
- (List<org.jbpm.graph.exe.ProcessInstance>) facade.execute(command);
-
+ List<org.jbpm.graph.exe.ProcessInstance> instances = delegate.getActualInstances(processId);
List<ProcessInstance> results = new ArrayList<ProcessInstance>(instances.size());
for(org.jbpm.graph.exe.ProcessInstance i0 : instances)
{
@@ -117,9 +76,7 @@
public ProcessInstance getInstanceById(long instanceId)
{
- org.jbpm.graph.exe.ProcessInstance instance = (org.jbpm.graph.exe.ProcessInstance)
- facade.execute( new GetProcessInstanceCommand(instanceId));
-
+ org.jbpm.graph.exe.ProcessInstance instance = delegate.getActualInstance(instanceId);
return Transform.processInstance(instance);
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -35,9 +35,14 @@
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
-public class MockDiagramDAO implements DiagramDAO
+public class MockDiagramDAO extends MockProcessDAO implements DiagramDAO
{
+ public MockDiagramDAO()
+ {
+ super();
+ }
+
public byte[] getProcessImage(long processId)
{
byte[] imageBytes = null;
@@ -67,10 +72,10 @@
return DiagramInfoParser.parse(in);
}
- public ActiveNodeInfo getActivNodeInfo(ProcessDAO processDAO, long instanceId)
+ public ActiveNodeInfo getActivNodeInfo(long instanceId)
{
- ProcessInstance pi = processDAO.getInstanceById(instanceId);
+ ProcessInstance pi = super.getInstanceById(instanceId);
DiagramInfo diagram = getDiagramInfo(pi.getParentId());
List<DiagramNodeInfo> nodes = diagram.getNodeList();
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -111,7 +111,7 @@
ProcessInstance toBeRemoved = null;
for(ProcessInstance instance : instances)
{
- if(instanceId == instance.getId())
+ if(instanceId == instance.getInstanceId())
toBeRemoved = instance;
}
@@ -129,7 +129,7 @@
ProcessInstance match = null;
for(ProcessInstance instance : instances)
{
- if(instanceId == instance.getId())
+ if(instanceId == instance.getInstanceId())
match = instance;
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-15 07:58:33 UTC (rev 2541)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -24,6 +24,8 @@
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.model.ProcessInstance;
+import java.util.Date;
+
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@@ -37,6 +39,8 @@
public static ProcessInstance processInstance(org.jbpm.graph.exe.ProcessInstance i0)
{
// TODO: status?
- return new ProcessInstance(i0.getId(), i0.getProcessDefinition().getId(), "Unknown", i0.getStart(), i0.getEnd());
+ Date start = i0.getStart();
+ Date end = i0.getEnd();
+ return new ProcessInstance(i0.getId(), i0.getProcessDefinition().getId(), "Unknown", start, end);
}
}
Added: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.server.gson;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class GsonFactory
+{
+ public static Gson createInstance()
+ {
+ Gson gson = new GsonBuilder()
+ .setDateFormat("y-M-d H:m:s")
+ .registerTypeAdapter(java.sql.Timestamp.class, new SQLDateTypeAdapter())
+ .create();
+ return gson;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java 2008-10-15 07:59:29 UTC (rev 2542)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.server.gson;
+
+import com.google.gson.*;
+
+import java.util.Date;
+import java.text.*;
+import java.lang.reflect.Type;
+
+
+/**
+ * A default type adapter for a {@link java.util.Date} object.<br>
+ * Create a GSON instance that can serialize/deserialize "java.util.Date" objects:
+ * <pre>
+ * Gson gson = new GsonBuilder()
+ * .registerTypeAdapter(new DateTypeAdapter())
+ * .create();
+ * </pre>
+ *
+ * @author Joel Leitch
+ */
+public class SQLDateTypeAdapter implements JsonSerializer<java.sql.Timestamp>, JsonDeserializer<Date>
+{
+ private final DateFormat format = new SimpleDateFormat("y-M-d H:m:s");
+
+ public JsonElement serialize(java.sql.Timestamp src, Type typeOfSrc, JsonSerializationContext context)
+ {
+ String dateFormatAsString = format.format(src);
+ return new JsonPrimitive(dateFormatAsString);
+ }
+
+ public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException
+ {
+ if (!(json instanceof JsonPrimitive)) {
+ throw new JsonParseException("The date should be a string value");
+ }
+
+ try
+ {
+ return format.parse(json.getAsString());
+ }
+ catch (ParseException e)
+ {
+ throw new JsonParseException(e);
+ }
+
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 6 months
JBoss JBPM SVN: r2541 - in jbpm3/trunk/modules/gwt-console/war: src/main/java/org/jboss/bpm/console/client/model/internal and 1 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-15 03:58:33 -0400 (Wed, 15 Oct 2008)
New Revision: 2541
Modified:
jbpm3/trunk/modules/gwt-console/war/pom.xml
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockMetricsDAO.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceEditor.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
Log:
Update to mvn GWT plugin 2.0-beta24
Modified: jbpm3/trunk/modules/gwt-console/war/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/pom.xml 2008-10-14 23:45:01 UTC (rev 2540)
+++ jbpm3/trunk/modules/gwt-console/war/pom.xml 2008-10-15 07:58:33 UTC (rev 2541)
@@ -77,7 +77,7 @@
<plugin>
<groupId>com.totsp.gwt</groupId>
<artifactId>maven-googlewebtoolkit2-plugin</artifactId>
- <version>2.0-beta23</version>
+ <version>2.0-beta24</version>
<configuration>
<logLevel>INFO</logLevel>
<compileTargets><value>org.jboss.bpm.console.Application</value></compileTargets>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockMetricsDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockMetricsDAO.java 2008-10-14 23:45:01 UTC (rev 2540)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockMetricsDAO.java 2008-10-15 07:58:33 UTC (rev 2541)
@@ -54,7 +54,7 @@
for(int i=0; i<instances.size(); i++)
{
ProcessInstance pi = (ProcessInstance)instances.get(i);
- metrics.put( new Long(pi.getId()) , new Double(Math.random()* MAX_EXEC_TIME) );
+ metrics.put( new Long(pi.getInstanceId()) , new Double(Math.random()* MAX_EXEC_TIME) );
}
return metrics;
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java 2008-10-14 23:45:01 UTC (rev 2540)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageView.java 2008-10-15 07:58:33 UTC (rev 2541)
@@ -23,7 +23,6 @@
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.Panel;
@@ -92,7 +91,7 @@
private void loadActiveNodeInfo()
{
- String url = view.getRestURL().getActiveNodeInfoURL(this.instance.getId());
+ String url = view.getRestURL().getActiveNodeInfoURL(this.instance.getInstanceId());
System.out.println("Loading activeNodeInfo: " + url);
JSONRequest.get(url,
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceEditor.java 2008-10-14 23:45:01 UTC (rev 2540)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceEditor.java 2008-10-15 07:58:33 UTC (rev 2541)
@@ -54,7 +54,7 @@
public ProcessInstanceEditor(final ProcessDefinition proc, final ProcessInstance instance, final ConsoleView view)
{
super();
- this.setId(ProcessInstanceEditor.ID+"."+instance.getId());
+ this.setId(ProcessInstanceEditor.ID+"."+instance.getInstanceId());
this.processDefinition = proc;
this.processInstance = instance;
@@ -161,7 +161,7 @@
public String getTitle()
{
- return "#"+processInstance.getId()+" ("+processDefinition.getName()+")";
+ return "#"+processInstance.getInstanceId()+" ("+processDefinition.getName()+")";
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-14 23:45:01 UTC (rev 2540)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-15 07:58:33 UTC (rev 2541)
@@ -59,7 +59,7 @@
protected void onExamine(final int row)
{
ProcessInstance instance = row2InstanceMap.get(row);
- String id = ProcessInstanceEditor.ID+"."+instance.getId();
+ String id = ProcessInstanceEditor.ID+"."+instance.getInstanceId();
if(view.hasEditorView(id))
view.showEditor(id);
else
@@ -79,7 +79,7 @@
if("yes".equals( btnID) )
{
ProcessInstance instance = row2InstanceMap.get(row);
- String url = view.getRestURL().getRemoveInstanceURL(instance.getId());
+ String url = view.getRestURL().getRemoveInstanceURL(instance.getInstanceId());
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
try
@@ -122,8 +122,8 @@
id,
Long.valueOf( r.getAsString("parentId")),
r.getAsString("status"),
- r.getAsDate("start"),
- r.getAsDate("end")
+ r.getAsDate("startDate"),
+ r.getAsDate("endDate")
);
row2InstanceMap.put(i, pd);
@@ -142,8 +142,8 @@
//new ColumnConfig("Process ID", "parentId", 25, true),
//new ColumnConfig("Key", "key", 50, true),
new ColumnConfig("Status", "status", 100, true, null, "expand"),
- new ColumnConfig("Start Date", "start", 125, true),
- new ColumnConfig("End Date", "end", 125, true)
+ new ColumnConfig("Start Date", "startDate", 125, true),
+ new ColumnConfig("End Date", "endDate", 125, true)
}
);
@@ -158,8 +158,8 @@
new IntegerFieldDef("parentId"),
new StringFieldDef("key"),
new StringFieldDef("status"),
- new DateFieldDef("start", DATE_FORMAT),
- new DateFieldDef("end", DATE_FORMAT)
+ new DateFieldDef("startDate", DATE_FORMAT),
+ new DateFieldDef("endDate", DATE_FORMAT)
}
);
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-14 23:45:01 UTC (rev 2540)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-15 07:58:33 UTC (rev 2541)
@@ -92,8 +92,8 @@
fieldSet.add(new TextField("Id", "instanceId", 230));
fieldSet.add(new TextField("Key", "key", 230));
fieldSet.add(new TextField("Status", "status", 230));
- fieldSet.add(new DateField("Start Date", "start", 230));
- fieldSet.add(new DateField("End Date", "end", 230));
+ fieldSet.add(new DateField("Start Date", "startDate", 230));
+ fieldSet.add(new DateField("End Date", "endDate", 230));
Panel inner = new PaddedPanel(fieldSet, 0, 10, 0, 0);
formPanel.add(inner);
17 years, 6 months