JBoss JBPM SVN: r3727 - in jbpm3/trunk/hudson/hudson-home/jobs: jBPM3-Container-Matrix and 1 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-01-28 23:13:45 -0500 (Wed, 28 Jan 2009)
New Revision: 3727
Added:
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Container-Matrix/
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Database-Matrix/
Removed:
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix/
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix/
Modified:
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml
Log:
Move to two dimensional test matricies
Copied: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Container-Matrix (from rev 3726, jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix)
Property changes on: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Container-Matrix
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml
===================================================================
--- jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix/config.xml 2009-01-28 18:06:29 UTC (rev 3726)
+++ jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml 2009-01-29 04:13:45 UTC (rev 3727)
@@ -44,8 +44,6 @@
<values>
<string>hsqldb</string>
<string>mysql</string>
- <string>postgresql</string>
- <string>sybase</string>
</values>
</axis>
<axis>
Copied: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Database-Matrix (from rev 3726, jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix)
Property changes on: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Database-Matrix
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml
===================================================================
--- jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix/config.xml 2009-01-28 18:06:29 UTC (rev 3726)
+++ jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml 2009-01-29 04:13:45 UTC (rev 3727)
@@ -25,7 +25,11 @@
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
- <triggers class="vector"/>
+ <triggers class="vector">
+ <hudson.triggers.TimerTrigger>
+ <spec>0 4 * * *</spec>
+ </hudson.triggers.TimerTrigger>
+ </triggers>
<axes>
<axis>
<name>container</name>
@@ -46,6 +50,7 @@
<name>jdk</name>
<values>
<string>jdk1.5</string>
+ <string>jdk1.6</string>
</values>
</axis>
</axes>
15 years, 3 months
JBoss JBPM SVN: r3726 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-28 13:06:29 -0500 (Wed, 28 Jan 2009)
New Revision: 3726
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
Log:
restore deprecation comments, add deprecation annotations
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-01-28 05:23:55 UTC (rev 3725)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-01-28 18:06:29 UTC (rev 3726)
@@ -56,7 +56,7 @@
}
}
- /*
+ /**
* signals to all threads in this job executor to stop. It may be that threads are in the middle of something and they will finish that first. Use {@link
* #stopAndJoin()} in case you want a method that blocks until all the threads are actually finished.
* @return a list of all the stopped threads. In case no threads were stopped an empty list will be returned.
@@ -164,10 +164,11 @@
monitoredJobIds.remove(threadName);
}
- /*
+ /**
* @throws UnsupportedOperationException to prevent invocation
* @deprecated <code>monitoredJobIds</code> is an internal control field
*/
+ @Deprecated
public void setMonitoredJobIds(Map<String, Long> monitoredJobIds)
{
throw new UnsupportedOperationException();
@@ -193,7 +194,7 @@
this.idleInterval = idleInterval;
}
- /*
+ /**
* Tells whether this job executor has been {@linkplain #start() started}.
*/
public boolean isStarted()
@@ -201,10 +202,11 @@
return isStarted;
}
- /*
+ /**
* @throws UnsupportedOperationException to prevent invocation
* @deprecated <code>isStarted</code> is an internal control field
*/
+ @Deprecated
public void setStarted(boolean isStarted)
{
throw new UnsupportedOperationException();
@@ -240,11 +242,19 @@
this.name = name;
}
+ /**
+ * @deprecated Replaced by {{@link #getNbrOfThreads()}
+ */
+ @Deprecated
public int getSize()
{
return nbrOfThreads;
}
+ /**
+ * @deprecated Replaced by {@link #setNbrOfThreads(int)}
+ */
+ @Deprecated
public void setSize(int nbrOfThreads)
{
this.nbrOfThreads = nbrOfThreads;
@@ -255,10 +265,11 @@
return threads;
}
- /*
+ /**
* @throws UnsupportedOperationException to prevent invocation
- * @deprecated <code>thread</code> is an internal control field
+ * @deprecated <code>threads</code> is an internal control field
*/
+ @Deprecated
public void setThreads(Map<String, Thread> threads)
{
throw new UnsupportedOperationException();
15 years, 3 months
JBoss JBPM SVN: r3725 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/logging/exe and 6 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-28 00:23:55 -0500 (Wed, 28 Jan 2009)
New Revision: 3725
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/exe/LoggingInstance.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/CompositeLog.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CascadeSaveOperation.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CheckUnpersistableVariablesOperation.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/SaveLogsOperation.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ActionLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/NodeLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessInstanceLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessLogsTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/SignalLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/TransitionLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/CompositeLogTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/log/ProcessLogDbTest.java
Log:
generalized logging and save operations
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -30,25 +30,23 @@
public class DbLoggingService implements LoggingService {
private static final long serialVersionUID = 1L;
-
+
Session session = null;
-
+
public DbLoggingService() {
- JbpmContext currentJbpmContext = JbpmContext.getCurrentJbpmContext();
- if (currentJbpmContext==null) {
+ JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
+ if (jbpmContext == null) {
throw new JbpmException("instantiation of the DbLoggingService requires a current JbpmContext");
}
- session = currentJbpmContext.getSession();
+ session = jbpmContext.getSession();
}
public void log(ProcessLog processLog) {
- if (session!=null) {
- // Improvement suggestions by Max :
- // db-level: use some hilo based id strategy to avoid repetitive insert. (dependent on db-lock)
- // sessionwise: use statelesssession or at least different session
- // can we borrow connection safely. Nag Steve. (open ontop of another session)
- session.save(processLog);
- }
+ // Improvement suggestions by Max :
+ // db-level: use some hilo based id strategy to avoid repetitive insert. (dependent on db-lock)
+ // session-level: use stateless session or at least different session
+ // can we borrow connection safely. Nag Steve. (open on top of another session)
+ session.save(processLog);
}
public void close() {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/exe/LoggingInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/exe/LoggingInstance.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/exe/LoggingInstance.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -21,118 +21,112 @@
*/
package org.jbpm.logging.exe;
-import java.util.*;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
-import org.apache.commons.logging.*;
-import org.jbpm.graph.log.*;
-import org.jbpm.logging.log.*;
-import org.jbpm.module.exe.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.logging.log.CompositeLog;
+import org.jbpm.logging.log.ProcessLog;
+import org.jbpm.module.exe.ModuleInstance;
import org.jbpm.util.Clock;
/**
- * non persisted class that collects {@link org.jbpm.logging.log.ProcessLog}s
- * during process execution. When the process instance gets saved, the
- * process logs will be saved by the {@link org.jbpm.db.LoggingSession}.
+ * non persisted class that collects {@link org.jbpm.logging.log.ProcessLog}s during process
+ * execution. When the process instance gets saved, the process logs will be saved by the
+ * {@link org.jbpm.db.LoggingSession}.
*/
public class LoggingInstance extends ModuleInstance {
private static final long serialVersionUID = 1L;
-
- List logs = new ArrayList();
- transient LinkedList compositeLogStack = new LinkedList();
-
+
+ List<ProcessLog> logs = new ArrayList<ProcessLog>();
+ transient List<CompositeLog> compositeLogStack = new ArrayList<CompositeLog>();
+
public LoggingInstance() {
}
-
+
public void startCompositeLog(CompositeLog compositeLog) {
addLog(compositeLog);
- compositeLogStack.addFirst(compositeLog);
+ compositeLogStack.add(compositeLog);
}
-
+
public void endCompositeLog() {
- compositeLogStack.removeFirst();
+ compositeLogStack.remove(compositeLogStack.size() - 1);
}
public void addLog(ProcessLog processLog) {
if (!compositeLogStack.isEmpty()) {
- CompositeLog currentCompositeLog = (CompositeLog) compositeLogStack.getFirst();
+ CompositeLog currentCompositeLog = compositeLogStack.get(compositeLogStack.size() - 1);
processLog.setParent(currentCompositeLog);
currentCompositeLog.addChild(processLog);
}
processLog.setDate(Clock.getCurrentTime());
-
+
logs.add(processLog);
}
-
- public List getLogs() {
+
+ public List<ProcessLog> getLogs() {
return logs;
}
/**
- * get logs, filetered by log type.
+ * get logs, filtered by log type.
*/
- public List getLogs(Class filterClass) {
- return getLogs(logs, filterClass);
+ public <L extends ProcessLog> List<L> getLogs(Class<L> logType) {
+ return getLogs(logs, logType);
}
-
- public static List getLogs(Collection logs, Class filterClass) {
- List filteredLogs = new ArrayList();
- if (logs!=null) {
- Iterator iter = logs.iterator();
- while (iter.hasNext()) {
- Object log = iter.next();
- if (filterClass.isAssignableFrom(log.getClass())) {
- filteredLogs.add(log);
+
+ public static <L extends ProcessLog> List<L> getLogs(Collection<ProcessLog> logs, Class<L> logType) {
+ List<L> filteredLogs = new ArrayList<L>();
+ if (logs != null) {
+ for (ProcessLog log : logs) {
+ if (logType.isInstance(log)) {
+ filteredLogs.add(logType.cast(log));
}
}
}
return filteredLogs;
}
- LinkedList getCompositeLogStack() {
+ List<CompositeLog> getCompositeLogStack() {
return compositeLogStack;
}
- List getCurrentOperationReversedActionLogs() {
- List actionLogs = new ArrayList();
- ProcessLog operationLog = (ProcessLog) compositeLogStack.getFirst();
- ListIterator listIterator = logs.listIterator(logs.size());
- ProcessLog processLog = (ProcessLog) listIterator.previous();
- while ( (listIterator.hasNext())
- && (processLog!=operationLog) ) {
- if (processLog instanceof ActionLog) {
- actionLogs.add(0, processLog);
- }
- }
- return actionLogs;
- }
-
public void logLogs() {
- Iterator iter = logs.iterator();
- while (iter.hasNext()) {
- ProcessLog processLog = (ProcessLog) iter.next();
- if (processLog.getParent()==null) {
- logLog("+-", processLog);
+ for (ProcessLog processLog : logs) {
+ if (processLog.getParent() == null) {
+ logLog("", processLog);
}
}
}
void logLog(String indentation, ProcessLog processLog) {
- log.debug(processLog.getToken()+"["+processLog.getIndex()+"] "+processLog+" on "+processLog.getToken());
- if (processLog instanceof CompositeLog) {
+ boolean isComposite = processLog instanceof CompositeLog;
+ log.debug(indentation
+ + (isComposite ? "+ [" : " [")
+ + processLog.getIndex()
+ + "] "
+ + processLog
+ + " on "
+ + processLog.getToken());
+ if (isComposite) {
CompositeLog compositeLog = (CompositeLog) processLog;
- if (compositeLog.getChildren()!=null) {
- Iterator iter = compositeLog.getChildren().iterator();
- while (iter.hasNext()) {
- logLog("| "+indentation, (ProcessLog) iter.next());
+ List<ProcessLog> children = compositeLog.getChildren();
+ if (children != null) {
+ for (ProcessLog childLog : children) {
+ logLog(indentation + " ", childLog);
}
}
}
}
-
- Object readResolve() {
- compositeLogStack = new LinkedList();
- return this;
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ compositeLogStack = new ArrayList<CompositeLog>();
}
private static final Log log = LogFactory.getLog(LoggingInstance.class);
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/CompositeLog.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/CompositeLog.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/CompositeLog.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -28,15 +28,16 @@
private static final long serialVersionUID = 1L;
- List children = null;
+ List<ProcessLog> children = null;
public CompositeLog() {
}
- public List getChildren() {
+ public List<ProcessLog> getChildren() {
return children;
}
- public void setChildren(List children) {
+
+ public void setChildren(List<ProcessLog> children) {
this.children = children;
}
@@ -45,7 +46,7 @@
}
public void addChild(ProcessLog processLog) {
- if (children==null) children = new ArrayList();
+ if (children == null) children = new ArrayList<ProcessLog>();
children.add(processLog);
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -26,7 +26,7 @@
import org.jbpm.graph.exe.*;
public abstract class ProcessLog implements Serializable {
-
+
private static final long serialVersionUID = 1L;
long id = 0;
@@ -34,25 +34,26 @@
protected Date date = null;
protected Token token = null;
protected CompositeLog parent = null;
-
+
public ProcessLog() {
}
-
+
/**
- * provides a text description for this update
- * which can be used e.g. in the admin web console.
+ * provides a text description for this update which can be used e.g. in the admin web console.
*/
- public abstract String toString();
-
+ public String toString() {
+ return super.toString();
+ }
+
public String getActorId() {
String actorId = null;
- if (parent!=null) {
- // AuthenticationLog overriddes the getActorId
+ if (parent != null) {
+ // AuthenticationLog overrides the getActorId
actorId = parent.getActorId();
}
return actorId;
}
-
+
public void setToken(Token token) {
this.token = token;
this.index = token.nextLogIndex();
@@ -61,28 +62,36 @@
public void setParent(CompositeLog parent) {
this.parent = parent;
}
+
public long getId() {
return id;
}
+
public Date getDate() {
return date;
}
+
public void setDate(Date date) {
this.date = date;
}
+
public CompositeLog getParent() {
return parent;
}
+
public Token getToken() {
return token;
}
+
public void setIndex(int index) {
this.index = index;
}
+
public int getIndex() {
return index;
}
- public List getChildren() {
+
+ public List<ProcessLog> getChildren() {
return null;
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CascadeSaveOperation.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CascadeSaveOperation.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CascadeSaveOperation.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -23,7 +23,6 @@
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -36,26 +35,27 @@
private static final long serialVersionUID = 1L;
public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
- log.debug("cascading save of '"+processInstance+"'");
- Set cascadedProcessInstances = new HashSet();
+ log.debug("cascading save of '" + processInstance + "'");
+ Set<ProcessInstance> cascadedProcessInstances = new HashSet<ProcessInstance>();
cascadedProcessInstances.add(processInstance);
- cascadeSave(processInstance.removeCascadeProcessInstances(), jbpmContext, cascadedProcessInstances);
+ cascadeSave(processInstance.removeCascadeProcessInstances(), jbpmContext,
+ cascadedProcessInstances);
}
- void cascadeSave(Collection cascadeProcessInstances, JbpmContext jbpmContext, Set cascadedProcessInstances) {
- if (cascadeProcessInstances!=null) {
- Iterator iter = cascadeProcessInstances.iterator();
- while (iter.hasNext()) {
- ProcessInstance cascadeInstance = (ProcessInstance) iter.next();
+ void cascadeSave(Collection<ProcessInstance> cascadeProcessInstances, JbpmContext jbpmContext,
+ Set<ProcessInstance> cascadedProcessInstances) {
+ if (cascadeProcessInstances != null) {
+ for (ProcessInstance cascadeInstance : cascadeProcessInstances) {
saveCascadeInstance(cascadeInstance, jbpmContext, cascadedProcessInstances);
}
}
}
-
- void saveCascadeInstance(ProcessInstance cascadeInstance, JbpmContext jbpmContext, Set cascadedProcessInstances) {
- if (! cascadedProcessInstances.contains(cascadeInstance)) {
- Collection cascadeProcessInstances = cascadeInstance.removeCascadeProcessInstances();
- log.debug("cascading save to process instance '"+cascadeInstance+"'");
+
+ void saveCascadeInstance(ProcessInstance cascadeInstance, JbpmContext jbpmContext,
+ Set<ProcessInstance> cascadedProcessInstances) {
+ if (!cascadedProcessInstances.contains(cascadeInstance)) {
+ Collection<ProcessInstance> cascadeProcessInstances = cascadeInstance.removeCascadeProcessInstances();
+ log.debug("cascading save to process instance '" + cascadeInstance + "'");
jbpmContext.save(cascadeInstance);
cascadedProcessInstances.add(cascadeInstance);
cascadeSave(cascadeProcessInstances, jbpmContext, cascadedProcessInstances);
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CheckUnpersistableVariablesOperation.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CheckUnpersistableVariablesOperation.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/CheckUnpersistableVariablesOperation.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -22,7 +22,6 @@
package org.jbpm.svc.save;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
import org.jbpm.JbpmContext;
@@ -37,37 +36,41 @@
private static final long serialVersionUID = 1L;
public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
- Collection updatedVariableContainers = VariableContainer.getUpdatedVariableContainers(processInstance);
- if (updatedVariableContainers!=null) {
+ Collection<VariableContainer> updatedVariableContainers = VariableContainer.getUpdatedVariableContainers(processInstance);
+ if (updatedVariableContainers == null) return;
- // loop over all updated variable containers
- Iterator iter = updatedVariableContainers.iterator();
- while (iter.hasNext()) {
- VariableContainer variableContainer = (VariableContainer) iter.next();
- Map variableInstances = variableContainer.getVariableInstances();
- if (variableInstances!=null) {
+ // loop over all updated variable containers
+ for (VariableContainer variableContainer : updatedVariableContainers) {
+ Map<String, VariableInstance> variableInstances = variableContainer.getVariableInstances();
+ if (variableInstances == null) continue;
- // loop over all variable instances in the container
- Iterator varInstancesIter = variableInstances.entrySet().iterator();
- while (varInstancesIter.hasNext()) {
- Map.Entry entry = (Map.Entry) varInstancesIter.next();
- String name = (String) entry.getKey();
- VariableInstance variableInstance = (VariableInstance) entry.getValue();
+ // loop over all variable instances in the container
+ for (Map.Entry<String, VariableInstance> entry : variableInstances.entrySet()) {
+ VariableInstance variableInstance = entry.getValue();
+ if (!(variableInstance instanceof UnpersistableInstance)) continue;
- // if the variable is of the unpersistable type... booom!
- if (variableInstance instanceof UnpersistableInstance) {
- Object value = variableInstance.getValue();
- if (value!=null) {
- throw new JbpmException("variable '"+name+"' in '"+variableContainer+"' contains '"+value+"': type '"+value.getClass().getName()+"' is unpersistable according to the jbpm.varmapping.xml configuration");
- } else {
- throw new JbpmException("variable '"+name+"' in '"+variableContainer+"' was created with a non persistable value");
- }
- }
- }
+ // the variable is unpersistable... booom!
+ String name = entry.getKey();
+ Object value = variableInstance.getValue();
+ if (value != null) {
+ throw new JbpmException("variable '"
+ + name
+ + "' in "
+ + variableContainer
+ + " contains value '"
+ + value
+ + "': type '"
+ + value.getClass().getName()
+ + "' is not mapped in jbpm.varmapping.xml");
}
+ else {
+ throw new JbpmException("variable '"
+ + name
+ + "' in '"
+ + variableContainer
+ + "' was created with a non persistable value");
+ }
}
}
}
-
- // private static Log log = LogFactory.getLog(CheckUnpersistableVariablesOperation.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/SaveLogsOperation.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/SaveLogsOperation.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/save/SaveLogsOperation.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -21,8 +21,6 @@
*/
package org.jbpm.svc.save;
-import java.util.Iterator;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmContext;
@@ -37,20 +35,18 @@
public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
LoggingService loggingService = jbpmContext.getServices().getLoggingService();
-
- if (loggingService!=null) {
+
+ if (loggingService != null) {
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- log.debug("flushing logs to logging service.");
- Iterator iter = loggingInstance.getLogs().iterator();
- while (iter.hasNext()) {
- ProcessLog processLog = (ProcessLog) iter.next();
+ log.debug("posting logs to logging service.");
+ for (ProcessLog processLog : loggingInstance.getLogs()) {
loggingService.log(processLog);
}
-
- } else {
+ }
+ else {
log.debug("ignoring logs. no logging service available.");
}
}
-
+
private static Log log = LogFactory.getLog(SaveLogsOperation.class);
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -23,7 +23,6 @@
import java.util.Arrays;
import java.util.Date;
-import java.util.List;
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.bytes.ByteArray;
@@ -35,56 +34,52 @@
import org.jbpm.logging.exe.LoggingInstance;
public class VariableLogTest extends AbstractJbpmTestCase {
-
+
private ProcessDefinition processDefinition = null;
private ProcessInstance processInstance = null;
private ContextInstance contextInstance = null;
private LoggingInstance loggingInstance = null;
-
- protected void setUp() throws Exception
- {
+
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
- processInstance = new ProcessInstance( processDefinition );
- contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
- loggingInstance = (LoggingInstance) processInstance.getInstance(LoggingInstance.class);
+ processInstance = new ProcessInstance(processDefinition);
+ contextInstance = processInstance.getInstance(ContextInstance.class);
+ loggingInstance = processInstance.getInstance(LoggingInstance.class);
}
-
+
public void testVariableCreateLogs() {
contextInstance.setVariable("a", new Integer(3));
- // // contextSession.updateProcessContextVariables(contextInstance);
-
- VariableCreateLog createLog = (VariableCreateLog)loggingInstance.getLogs(VariableCreateLog.class).get(0);
+
+ VariableCreateLog createLog = loggingInstance.getLogs(VariableCreateLog.class).get(0);
assertEquals("a", createLog.getVariableInstance().getName());
-
- LongUpdateLog updateLog = (LongUpdateLog)loggingInstance.getLogs(LongUpdateLog.class).get(0);
+ LongUpdateLog updateLog = loggingInstance.getLogs(LongUpdateLog.class).get(0);
assertNull(updateLog.getOldValue());
assertEquals(new Long(3), updateLog.getNewValue());
}
-
+
public void testByteArrayUpdateLog() {
contextInstance.setVariable("a", "first value".getBytes());
contextInstance.setVariable("a", "second value".getBytes());
-
- // System.out.println(loggingInstance.getLogs());
-
- List logs = loggingInstance.getLogs(VariableUpdateLog.class);
- VariableUpdateLog variableLog = (VariableUpdateLog)logs.get(1);
-
- assertTrue(Arrays.equals("first value".getBytes(), ((ByteArray) variableLog.getOldValue()).getBytes()));
- assertTrue(Arrays.equals("second value".getBytes(), ((ByteArray) variableLog.getNewValue()).getBytes()));
+
+ VariableUpdateLog variableLog = loggingInstance.getLogs(VariableUpdateLog.class).get(1);
+
+ assertTrue(Arrays.equals("first value".getBytes(),
+ ((ByteArray) variableLog.getOldValue()).getBytes()));
+ assertTrue(Arrays.equals("second value".getBytes(),
+ ((ByteArray) variableLog.getNewValue()).getBytes()));
}
public void testDateUpdateLog() {
Date now = new Date();
- Date future = new Date(now.getTime()+5);
+ Date future = new Date(now.getTime() + 5);
contextInstance.setVariable("a", now);
contextInstance.setVariable("a", future);
- VariableUpdateLog variableLog = (VariableUpdateLog)loggingInstance.getLogs(VariableUpdateLog.class).get(1);
-
+ VariableUpdateLog variableLog = loggingInstance.getLogs(VariableUpdateLog.class).get(1);
+
assertEquals(now, variableLog.getOldValue());
assertEquals(future, variableLog.getNewValue());
}
@@ -93,8 +88,8 @@
contextInstance.setVariable("a", new Double(3.3));
contextInstance.setVariable("a", new Double(4.4));
- VariableUpdateLog variableLog = (VariableUpdateLog)loggingInstance.getLogs(VariableUpdateLog.class).get(1);
-
+ VariableUpdateLog variableLog = loggingInstance.getLogs(VariableUpdateLog.class).get(1);
+
assertEquals(new Double(3.3), variableLog.getOldValue());
assertEquals(new Double(4.4), variableLog.getNewValue());
}
@@ -103,7 +98,7 @@
contextInstance.setVariable("a", new Integer(3));
contextInstance.setVariable("a", new Integer(5));
- VariableUpdateLog variableLog = (VariableUpdateLog)loggingInstance.getLogs(VariableUpdateLog.class).get(1);
+ VariableUpdateLog variableLog = loggingInstance.getLogs(VariableUpdateLog.class).get(1);
assertEquals(new Long(3), variableLog.getOldValue());
assertEquals(new Long(5), variableLog.getNewValue());
@@ -113,7 +108,7 @@
contextInstance.setVariable("a", "pope");
contextInstance.setVariable("a", "me");
- VariableUpdateLog variableLog = (VariableUpdateLog)loggingInstance.getLogs(VariableUpdateLog.class).get(1);
+ VariableUpdateLog variableLog = loggingInstance.getLogs(VariableUpdateLog.class).get(1);
assertEquals("pope", variableLog.getOldValue());
assertEquals("me", variableLog.getNewValue());
@@ -123,8 +118,8 @@
contextInstance.setVariable("a", new Integer(3));
contextInstance.deleteVariable("a");
- VariableDeleteLog deleteLog = (VariableDeleteLog)loggingInstance.getLogs(VariableDeleteLog.class).get(0);
-
+ VariableDeleteLog deleteLog = loggingInstance.getLogs(VariableDeleteLog.class).get(0);
+
assertEquals("a", deleteLog.getVariableInstance().getName());
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -33,16 +33,15 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.logging.exe.LoggingInstance;
+import org.jbpm.logging.log.ProcessLog;
import org.jbpm.util.DateDbTestUtil;
-public class VariableUpdateDbTest extends AbstractDbTestCase
-{
+public class VariableUpdateDbTest extends AbstractDbTestCase {
private ProcessDefinition processDefinition;
private ProcessInstance processInstance;
private ContextInstance contextInstance;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
@@ -53,38 +52,36 @@
}
@Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testVariableCreateLogs()
- {
+ public void testVariableCreateLogs() {
contextInstance.setVariable("a", new Integer(3));
jbpmContext.save(processInstance);
newTransaction();
- List logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
- VariableCreateLog createLog = (VariableCreateLog)LoggingInstance.getLogs(logs, VariableCreateLog.class).get(0);
+ List<ProcessLog> logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
+ VariableCreateLog createLog = LoggingInstance.getLogs(logs, VariableCreateLog.class).get(0);
assertEquals("a", createLog.getVariableInstance().getName());
}
- public void testByteArrayUpdateLog()
- {
+ public void testByteArrayUpdateLog() {
contextInstance.setVariable("a", "first value".getBytes());
jbpmContext.save(processInstance);
contextInstance.setVariable("a", "second value".getBytes());
VariableUpdateLog variableLog = saveAndReloadUpdateLog(processInstance);
- assertTrue(Arrays.equals("first value".getBytes(), ((ByteArray)variableLog.getOldValue()).getBytes()));
- assertTrue(Arrays.equals("second value".getBytes(), ((ByteArray)variableLog.getNewValue()).getBytes()));
+ assertTrue(Arrays.equals("first value".getBytes(),
+ ((ByteArray) variableLog.getOldValue()).getBytes()));
+ assertTrue(Arrays.equals("second value".getBytes(),
+ ((ByteArray) variableLog.getNewValue()).getBytes()));
}
- public void testDateUpdateLog()
- {
+ public void testDateUpdateLog() {
final Date now = Calendar.getInstance().getTime();
final Date future = new Date(now.getTime() + 5);
contextInstance.setVariable("a", now);
@@ -94,12 +91,13 @@
VariableUpdateLog variableLog = saveAndReloadUpdateLog(processInstance);
DateDbTestUtil dbUtilInst = DateDbTestUtil.getInstance();
- assertEquals(dbUtilInst.convertDateToSeconds(now), dbUtilInst.convertDateToSeconds((Date)variableLog.getOldValue()));
- assertEquals(dbUtilInst.convertDateToSeconds(future), dbUtilInst.convertDateToSeconds((Date)variableLog.getNewValue()));
+ assertEquals(dbUtilInst.convertDateToSeconds(now),
+ dbUtilInst.convertDateToSeconds((Date) variableLog.getOldValue()));
+ assertEquals(dbUtilInst.convertDateToSeconds(future),
+ dbUtilInst.convertDateToSeconds((Date) variableLog.getNewValue()));
}
- public void testDoubleUpdateLog()
- {
+ public void testDoubleUpdateLog() {
contextInstance.setVariable("a", new Double(3.3));
jbpmContext.save(processInstance);
contextInstance.setVariable("a", new Double(4.4));
@@ -110,8 +108,7 @@
assertEquals(new Double(4.4), variableLog.getNewValue());
}
- public void testLongUpdateLog()
- {
+ public void testLongUpdateLog() {
contextInstance.setVariable("a", new Integer(3));
jbpmContext.save(processInstance);
contextInstance.setVariable("a", new Integer(5));
@@ -122,8 +119,7 @@
assertEquals(new Long(5), variableLog.getNewValue());
}
- public void testStringUpdateLog()
- {
+ public void testStringUpdateLog() {
contextInstance.setVariable("a", "pope");
jbpmContext.save(processInstance);
contextInstance.setVariable("a", "me");
@@ -134,25 +130,23 @@
assertEquals("me", variableLog.getNewValue());
}
- public void testVariableDeleteLog()
- {
+ public void testVariableDeleteLog() {
contextInstance.setVariable("a", new Integer(3));
jbpmContext.save(processInstance);
contextInstance.deleteVariable("a");
jbpmContext.save(processInstance);
newTransaction();
- List logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
- VariableDeleteLog deleteLog = (VariableDeleteLog)LoggingInstance.getLogs(logs, VariableDeleteLog.class).get(0);
+ List<ProcessLog> logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
+ VariableDeleteLog deleteLog = LoggingInstance.getLogs(logs, VariableDeleteLog.class).get(0);
assertEquals("a", deleteLog.getVariableInstance().getName());
}
- private VariableUpdateLog saveAndReloadUpdateLog(ProcessInstance processInstance)
- {
+ private VariableUpdateLog saveAndReloadUpdateLog(ProcessInstance processInstance) {
jbpmContext.save(processInstance);
newTransaction();
- List logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
- return (VariableUpdateLog)LoggingInstance.getLogs(logs, VariableUpdateLog.class).get(1);
+ List<ProcessLog> logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
+ return LoggingInstance.getLogs(logs, VariableUpdateLog.class).get(1);
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ActionLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ActionLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ActionLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -59,11 +59,11 @@
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List actionLogs = loggingInstance.getLogs(ActionLog.class);
+ List<ActionLog> actionLogs = loggingInstance.getLogs(ActionLog.class);
assertEquals(1, actionLogs.size());
- ActionLog actionLog = (ActionLog) actionLogs.get(0);
+ ActionLog actionLog = actionLogs.get(0);
assertSame(token, actionLog.getToken());
assertSame(LoggedAction.class, actionLog.getAction().getActionDelegation().getInstance().getClass());
assertNull(actionLog.getException());
@@ -99,11 +99,11 @@
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List actionLogs = loggingInstance.getLogs(ActionLog.class);
+ List<ActionLog> actionLogs = loggingInstance.getLogs(ActionLog.class);
assertEquals(1, actionLogs.size());
- ActionLog actionLog = (ActionLog) actionLogs.get(0);
+ ActionLog actionLog = actionLogs.get(0);
assertSame(token, actionLog.getToken());
assertSame(LoggedExceptionAction.class, actionLog.getAction().getActionDelegation().getInstance().getClass());
assertNotNull(actionLog.getException());
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/NodeLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/NodeLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/NodeLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -50,9 +50,9 @@
processInstance.signal();
- List nodeLogs = loggingInstance.getLogs(NodeLog.class);
+ List<NodeLog> nodeLogs = loggingInstance.getLogs(NodeLog.class);
assertEquals(1, nodeLogs.size());
- NodeLog nodeLog = (NodeLog) nodeLogs.get(0);
+ NodeLog nodeLog = nodeLogs.get(0);
assertSame(processDefinition.getNode("s"), nodeLog.node);
assertNotNull(nodeLog.enter);
assertNotNull(nodeLog.leave);
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessInstanceLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessInstanceLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessInstanceLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -34,9 +34,9 @@
ProcessDefinition processDefinition = new ProcessDefinition();
ProcessInstance processInstance = new ProcessInstance(processDefinition);
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List processInstanceCreateLogs = loggingInstance.getLogs(ProcessInstanceCreateLog.class);
+ List<ProcessInstanceCreateLog> processInstanceCreateLogs = loggingInstance.getLogs(ProcessInstanceCreateLog.class);
assertEquals(1, processInstanceCreateLogs.size());
- ProcessInstanceCreateLog processInstanceCreateLog = (ProcessInstanceCreateLog) processInstanceCreateLogs.get(0);
+ ProcessInstanceCreateLog processInstanceCreateLog = processInstanceCreateLogs.get(0);
assertSame(processInstance.getRootToken(), processInstanceCreateLog.getToken());
}
@@ -53,9 +53,9 @@
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.end();
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List processInstanceEndLogs = loggingInstance.getLogs(ProcessInstanceEndLog.class);
+ List<ProcessInstanceEndLog> processInstanceEndLogs = loggingInstance.getLogs(ProcessInstanceEndLog.class);
assertEquals(1, processInstanceEndLogs.size());
- ProcessInstanceEndLog processInstanceEndLog = (ProcessInstanceEndLog) processInstanceEndLogs.get(0);
+ ProcessInstanceEndLog processInstanceEndLog = processInstanceEndLogs.get(0);
assertSame(processInstance.getRootToken(), processInstanceEndLog.getToken());
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessLogsTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessLogsTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/ProcessLogsTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -32,47 +32,42 @@
public class ProcessLogsTest extends AbstractJbpmTestCase {
public void testProcessInstanceStartLog() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition />"
- );
-
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition />");
+
// start a process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
-
+
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List processLogs = loggingInstance.getLogs(ProcessInstanceCreateLog.class);
-
+ List<ProcessInstanceCreateLog> processLogs = loggingInstance.getLogs(ProcessInstanceCreateLog.class);
+
assertEquals(1, processLogs.size());
- ProcessInstanceCreateLog processInstanceCreateLog = (ProcessInstanceCreateLog) processLogs.get(0);
+ ProcessInstanceCreateLog processInstanceCreateLog = processLogs.get(0);
assertSame(token, processInstanceCreateLog.getToken());
assertNotNull(processInstanceCreateLog.getDate());
}
public void testProcessInstanceEndLog() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='end' />" +
- " </start-state>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
-
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='end' />"
+ + " </start-state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+
// start a process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
processInstance.signal();
-
+
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List processLogs = loggingInstance.getLogs(ProcessInstanceEndLog.class);
-
+ List<ProcessInstanceEndLog> processLogs = loggingInstance.getLogs(ProcessInstanceEndLog.class);
assertEquals(1, processLogs.size());
- ProcessInstanceEndLog processInstanceEndLog = (ProcessInstanceEndLog) processLogs.get(0);
+ ProcessInstanceEndLog processInstanceEndLog = processLogs.get(0);
assertSame(token, processInstanceEndLog.getToken());
assertNotNull(processInstanceEndLog.getDate());
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/SignalLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/SignalLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/SignalLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -32,38 +32,35 @@
public class SignalLogTest extends AbstractJbpmTestCase {
public void testSignalLog() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='s' />" +
- " </start-state>" +
- " <state name='s'>" +
- " <transition to='s' />" +
- " </state>" +
- "</process-definition>"
- );
-
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='s' />"
+ + " </start-state>"
+ + " <state name='s'>"
+ + " <transition to='s' />"
+ + " </state>"
+ + "</process-definition>");
+
// start a process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
processInstance.signal();
-
+
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List processLogs = loggingInstance.getLogs(SignalLog.class);
+ List<SignalLog> processLogs = loggingInstance.getLogs(SignalLog.class);
// check that there is exactly one signal log
assertEquals(1, processLogs.size());
- SignalLog signalLog = (SignalLog) processLogs.get(0);
+ SignalLog signalLog = processLogs.get(0);
assertSame(token, signalLog.getToken());
assertNotNull(signalLog.getDate());
-
+
// now we signal a second time
processInstance.signal();
// and check if there are exactly 2 signal logs
assertEquals(2, loggingInstance.getLogs(SignalLog.class).size());
}
-
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/TransitionLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/TransitionLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/log/TransitionLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -32,40 +32,40 @@
public class TransitionLogTest extends AbstractJbpmTestCase {
public void testBasicTransitionLogs() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='state' />" +
- " </start-state>" +
- " <state name='state'>" +
- " <transition to='end' />" +
- " </state>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='state' />"
+ + " </start-state>"
+ + " <state name='state'>"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
// start a process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
processInstance.signal();
-
+
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List transitionLogs = loggingInstance.getLogs(TransitionLog.class);
+ List<TransitionLog> transitionLogs = loggingInstance.getLogs(TransitionLog.class);
assertEquals(1, transitionLogs.size());
- TransitionLog transitionLog = (TransitionLog) transitionLogs.get(0);
+
+ TransitionLog transitionLog = transitionLogs.get(0);
assertSame(token, transitionLog.getToken());
assertNotNull(transitionLog.getDate());
assertSame(processDefinition.getStartState(), transitionLog.getSourceNode());
assertSame(processDefinition.getNode("state"), transitionLog.getDestinationNode());
- // signal the process to continue (which will move it to the end state)
+ // signal the process to continue (which will move it to the end state)
processInstance.signal();
-
+
// check the transition log (from the state to the end state)
transitionLogs = loggingInstance.getLogs(TransitionLog.class);
assertEquals(2, transitionLogs.size());
- transitionLog = (TransitionLog) transitionLogs.get(1);
+
+ transitionLog = transitionLogs.get(1);
assertSame(token, transitionLog.getToken());
assertNotNull(transitionLog.getDate());
assertSame(processDefinition.getNode("state"), transitionLog.getSourceNode());
@@ -73,30 +73,29 @@
}
public void testUseSuperStateTransitionLogs() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='superstate/state' />" +
- " </start-state>" +
- " <super-state name='superstate'>" +
- " <state name='state'/>" +
- " <transition to='end' />" +
- " </super-state>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='superstate/state' />"
+ + " </start-state>"
+ + " <super-state name='superstate'>"
+ + " <state name='state'/>"
+ + " <transition to='end' />"
+ + " </super-state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
// start a process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
processInstance.signal();
processInstance.signal();
-
+
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List transitionLogs = loggingInstance.getLogs(TransitionLog.class);
+ List<TransitionLog> transitionLogs = loggingInstance.getLogs(TransitionLog.class);
assertEquals(2, transitionLogs.size());
- TransitionLog transitionLog = (TransitionLog) transitionLogs.get(1);
+
+ TransitionLog transitionLog = transitionLogs.get(1);
assertSame(token, transitionLog.getToken());
assertNotNull(transitionLog.getDate());
assertSame(processDefinition.findNode("superstate/state"), transitionLog.getSourceNode());
@@ -104,27 +103,26 @@
}
public void testTransitionToSuperStateFirstChildLogs() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='superstate' />" +
- " </start-state>" +
- " <super-state name='superstate'>" +
- " <state name='state'/>" +
- " </super-state>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='superstate' />"
+ + " </start-state>"
+ + " <super-state name='superstate'>"
+ + " <state name='state'/>"
+ + " </super-state>"
+ + "</process-definition>");
// start a process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
processInstance.signal();
-
+
// check the transition log (from the start state to the state)
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
- List transitionLogs = loggingInstance.getLogs(TransitionLog.class);
+ List<TransitionLog> transitionLogs = loggingInstance.getLogs(TransitionLog.class);
assertEquals(1, transitionLogs.size());
- TransitionLog transitionLog = (TransitionLog) transitionLogs.get(0);
+
+ TransitionLog transitionLog = transitionLogs.get(0);
assertSame(token, transitionLog.getToken());
assertNotNull(transitionLog.getDate());
assertSame(processDefinition.getStartState(), transitionLog.getSourceNode());
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/CompositeLogTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/CompositeLogTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/CompositeLogTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -30,72 +30,72 @@
import org.jbpm.logging.log.ProcessLog;
public class CompositeLogTest extends AbstractJbpmTestCase {
-
+
public void testCompositeLogs() {
ProcessDefinition processDefinition = new ProcessDefinition();
ProcessInstance pi = new ProcessInstance(processDefinition);
Token root = pi.getRootToken();
- LoggingInstance li = (LoggingInstance) pi.getInstance(LoggingInstance.class);
-
+ LoggingInstance li = pi.getInstance(LoggingInstance.class);
+
ProcessLog one = new MessageLog(null);
li.addLog(one);
-
- assertNull( one.getParent() );
- assertSame( one, li.getLogs().get(1) );
- assertEquals( 2, li.getLogs().size() );
- assertEquals( 0, li.getCompositeLogStack().size() );
+ assertNull(one.getParent());
+ assertSame(one, li.getLogs().get(1));
+ assertEquals(2, li.getLogs().size());
+ assertEquals(0, li.getCompositeLogStack().size());
+
CompositeLog two = new CompositeLog();
two.setToken(root);
li.startCompositeLog(two);
- assertNull( two.getParent() );
- assertSame( two, li.getLogs().get(2) );
- assertEquals( 3, li.getLogs().size() );
- assertEquals( 1, li.getCompositeLogStack().size() );
+ assertNull(two.getParent());
+ assertSame(two, li.getLogs().get(2));
+ assertEquals(3, li.getLogs().size());
+ assertEquals(1, li.getCompositeLogStack().size());
ProcessLog three = new MessageLog(null);
li.addLog(three);
- assertSame( two, three.getParent() );
- assertSame( three, li.getLogs().get(3) );
- assertEquals( 4, li.getLogs().size() );
- assertEquals( 1, li.getCompositeLogStack().size() );
+ assertSame(two, three.getParent());
+ assertSame(three, li.getLogs().get(3));
+ assertEquals(4, li.getLogs().size());
+ assertEquals(1, li.getCompositeLogStack().size());
CompositeLog four = new CompositeLog();
four.setToken(root);
li.startCompositeLog(four);
- assertSame( two, four.getParent() );
- assertSame( four, li.getLogs().get(4) );
- assertEquals( 5, li.getLogs().size() );
- assertEquals( 2, li.getCompositeLogStack().size() );
+ assertSame(two, four.getParent());
+ assertSame(four, li.getLogs().get(4));
+ assertEquals(5, li.getLogs().size());
+ assertEquals(2, li.getCompositeLogStack().size());
ProcessLog five = new MessageLog(null);
li.addLog(five);
- assertSame( four, five.getParent() );
- assertSame( two, five.getParent().getParent() );
- assertNull( five.getParent().getParent().getParent() );
- assertSame( five, li.getLogs().get(5) );
- assertEquals( 6, li.getLogs().size() );
- assertEquals( 2, li.getCompositeLogStack().size() );
+ assertSame(four, five.getParent());
+ assertSame(two, five.getParent().getParent());
+ assertNull(five.getParent().getParent().getParent());
+ assertSame(five, li.getLogs().get(5));
+ assertEquals(6, li.getLogs().size());
+ assertEquals(2, li.getCompositeLogStack().size());
li.endCompositeLog();
- assertEquals( 1, li.getCompositeLogStack().size() );
+ assertEquals(1, li.getCompositeLogStack().size());
ProcessLog six = new MessageLog(null);
li.addLog(six);
- assertSame( two, six.getParent() );
- assertNull( six.getParent().getParent() );
- assertSame( six, li.getLogs().get(6) );
- assertEquals( 7, li.getLogs().size() );
- assertEquals( 1, li.getCompositeLogStack().size() );
+ assertSame(two, six.getParent());
+ assertNull(six.getParent().getParent());
+ assertSame(six, li.getLogs().get(6));
+ assertEquals(7, li.getLogs().size());
+ assertEquals(1, li.getCompositeLogStack().size());
li.endCompositeLog();
-
- assertEquals( 0, li.getCompositeLogStack().size() );
+
+ assertEquals(0, li.getCompositeLogStack().size());
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/log/ProcessLogDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/log/ProcessLogDbTest.java 2009-01-28 03:17:25 UTC (rev 3724)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/log/ProcessLogDbTest.java 2009-01-28 05:23:55 UTC (rev 3725)
@@ -22,38 +22,34 @@
package org.jbpm.logging.log;
import java.util.Date;
-import java.util.Iterator;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.exe.Token;
import org.jbpm.util.DateDbTestUtil;
-public class ProcessLogDbTest extends AbstractDbTestCase
-{
+public class ProcessLogDbTest extends AbstractDbTestCase {
- public void testMessageLogMessage()
- {
+ public void testMessageLogMessage() {
MessageLog messageLog = new MessageLog("piece of cake");
- messageLog = (MessageLog)saveAndReload(messageLog);
+ messageLog = (MessageLog) saveAndReload(messageLog);
assertEquals("piece of cake", messageLog.getMessage());
session.delete(messageLog);
}
- public void testProcessLogDate()
- {
+ public void testProcessLogDate() {
Date now = new Date();
ProcessLog processLog = new MessageLog();
processLog.setDate(now);
processLog = saveAndReload(processLog);
// assertEquals(now, processLog.getDate());
// assertEquals(now.getTime(), processLog.getDate().getTime());
- assertEquals(DateDbTestUtil.getInstance().convertDateToSeconds(now), DateDbTestUtil.getInstance().convertDateToSeconds(processLog.getDate()));
+ assertEquals(DateDbTestUtil.getInstance().convertDateToSeconds(now),
+ DateDbTestUtil.getInstance().convertDateToSeconds(processLog.getDate()));
session.delete(processLog);
}
- public void testProcessLogToken()
- {
+ public void testProcessLogToken() {
Token token = new Token();
session.save(token);
ProcessLog processLog = new MessageLog();
@@ -65,8 +61,7 @@
session.delete(token);
}
- public void testParentChildRelation()
- {
+ public void testParentChildRelation() {
CompositeLog compositeLog = new CompositeLog();
ProcessLog procLog = new MessageLog("one");
session.save(procLog);
@@ -78,16 +73,13 @@
session.save(procLog);
compositeLog.addChild(procLog);
- compositeLog = (CompositeLog)saveAndReload(compositeLog);
+ compositeLog = (CompositeLog) saveAndReload(compositeLog);
assertEquals(3, compositeLog.getChildren().size());
- Iterator iter = compositeLog.getChildren().iterator();
- while (iter.hasNext())
- {
- ProcessLog childLog = (ProcessLog)iter.next();
+ for (ProcessLog childLog : compositeLog.getChildren()) {
assertSame(compositeLog, childLog.getParent());
}
-
+
session.delete(compositeLog);
}
15 years, 3 months
JBoss JBPM SVN: r3724 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/persistence/db and 6 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-27 22:17:25 -0500 (Tue, 27 Jan 2009)
New Revision: 3724
Removed:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java
jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml
jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Invocation.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Recorded.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
Log:
JBPM-1988 throw JbpmPersistenceException from JtaDbPersistenceService
improve inheritance between JtaDbPersistenceService and its superclass
treat stale state exceptions uniformly
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -59,8 +59,7 @@
if (!acquiredJobs.isEmpty()) {
for (Job job : acquiredJobs) {
executeJob(job);
- if (!isActive)
- break;
+ if (!isActive) break;
}
}
else if (isActive) {
@@ -144,10 +143,9 @@
catch (JbpmPersistenceException e) {
// if this is a stale object exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("problem acquiring jobs " + acquiredJobs + ": optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("problem acquiring jobs "
- + acquiredJobs
- + ": optimistic locking failed", e);
+ log.debug("optimistic locking failed, could not acquire jobs " + acquiredJobs);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed, could not acquire jobs " + acquiredJobs, e);
acquiredJobs = Collections.emptyList();
}
else {
@@ -198,7 +196,9 @@
catch (JbpmPersistenceException e) {
// if this is a stale state exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("optimistic locking failed, couldn't complete job " + job);
+ log.debug("optimistic locking failed, could not complete job " + job);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed, could not complete job " + job, e);
}
else {
throw e;
@@ -209,8 +209,7 @@
private static boolean isPersistenceException(Throwable throwable) {
do {
- if (throwable instanceof HibernateException)
- return true;
+ if (throwable instanceof HibernateException) return true;
throwable = throwable.getCause();
} while (throwable != null);
return false;
@@ -235,7 +234,9 @@
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");
+ log.debug("optimistic locking failed, could not return next due date: " + nextDueDate);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed, could not return next due date: " + nextDueDate, e);
nextDueDate = null;
}
else {
@@ -266,8 +267,7 @@
* @deprecated As of jBPM 3.2.3, replaced by {@link #deactivate()}
*/
public void setActive(boolean isActive) {
- if (isActive == false)
- deactivate();
+ if (isActive == false) deactivate();
}
/**
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -10,10 +10,11 @@
import org.jbpm.db.JobSession;
import org.jbpm.job.Job;
import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.persistence.db.StaleObjectLogConfigurer;
import org.jbpm.svc.Services;
public class LockMonitorThread extends Thread {
-
+
JbpmConfiguration jbpmConfiguration;
int lockMonitorInterval;
int maxLockTime;
@@ -21,7 +22,8 @@
boolean isActive = true;
- public LockMonitorThread(JbpmConfiguration jbpmConfiguration, int lockMonitorInterval, int maxLockTime, int lockBufferTime) {
+ public LockMonitorThread(JbpmConfiguration jbpmConfiguration, int lockMonitorInterval,
+ int maxLockTime, int lockBufferTime) {
this.jbpmConfiguration = jbpmConfiguration;
this.lockMonitorInterval = lockMonitorInterval;
this.maxLockTime = maxLockTime;
@@ -33,51 +35,59 @@
while (isActive) {
try {
unlockOverdueJobs();
- if ( (isActive)
- && (lockMonitorInterval>0)
- ) {
+ if ((isActive) && (lockMonitorInterval > 0)) {
sleep(lockMonitorInterval);
}
- } catch (InterruptedException e) {
- log.info("lock monitor thread '"+getName()+"' got interrupted");
- } catch (Exception e) {
- log.error("exception in lock monitor thread. waiting "+lockMonitorInterval+" milliseconds", e);
+ }
+ catch (InterruptedException e) {
+ log.info("lock monitor thread '" + getName() + "' got interrupted");
+ }
+ catch (Exception e) {
+ log.error("exception in lock monitor thread. waiting "
+ + lockMonitorInterval
+ + " milliseconds", e);
try {
sleep(lockMonitorInterval);
- } catch (InterruptedException e2) {
+ }
+ catch (InterruptedException e2) {
log.debug("delay after exception got interrupted", e2);
}
}
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
log.error("exception in lock monitor thread", e);
- } finally {
- log.info(getName()+" leaves cyberspace");
}
+ finally {
+ log.info(getName() + " leaves cyberspace");
+ }
}
-
protected void unlockOverdueJobs() {
+ List<Job> overdueJobs = null;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
+ Date treshold = new Date(System.currentTimeMillis() - maxLockTime - lockBufferTime);
JobSession jobSession = jbpmContext.getJobSession();
-
- Date treshold = new Date(System.currentTimeMillis()-maxLockTime-lockBufferTime);
- List<Job> jobsWithOverdueLockTime = jobSession.findJobsWithOverdueLockTime(treshold);
- for (Job job : jobsWithOverdueLockTime) {
- log.debug("unlocking "+job+ " owned by thread "+job.getLockOwner());
+ overdueJobs = jobSession.findJobsWithOverdueLockTime(treshold);
+ for (Job job : overdueJobs) {
+ log.debug("unlocking " + job + " owned by thread " + job.getLockOwner());
job.setLockOwner(null);
job.setLockTime(null);
- jobSession.saveJob(job);
}
- } finally {
+ }
+ finally {
try {
jbpmContext.close();
- } catch (JbpmPersistenceException 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 {
+ log.debug("optimistic locking failed, could not unlock overdue jobs: " + overdueJobs);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "problem unlocking overdue jobs: optimistic locking failed", e);
+ }
+ else {
throw e;
}
}
@@ -88,18 +98,16 @@
* @deprecated As of jBPM 3.2.3, replaced by {@link #deactivate()}
*/
public void setActive(boolean isActive) {
- if (isActive == false)
- deactivate();
+ if (isActive == false) deactivate();
}
/**
- * Indicates that this thread should stop running.
- * Execution will cease shortly afterwards.
+ * Indicates that this thread should stop running. Execution will cease shortly afterwards.
*/
public void deactivate() {
if (isActive) {
isActive = false;
- interrupt();
+ interrupt();
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -45,60 +45,44 @@
import org.jbpm.tx.TxService;
public class DbPersistenceService implements Service, PersistenceService {
-
+
private static final long serialVersionUID = 1L;
- protected DbPersistenceServiceFactory persistenceServiceFactory = null;
+ protected final DbPersistenceServiceFactory persistenceServiceFactory;
- protected Connection connection = null;
- protected boolean mustConnectionBeClosed = false;
+ protected Connection connection;
+ protected boolean mustConnectionBeClosed;
- protected Transaction transaction = null;
+ protected Transaction transaction;
protected boolean isTransactionEnabled = true;
- protected boolean isCurrentSessionEnabled = false;
+ protected boolean isCurrentSessionEnabled;
- // boolean isRollbackOnly = false;
-
protected Session session;
- protected boolean mustSessionBeFlushed = false;
- protected boolean mustSessionBeClosed = false;
+ protected boolean mustSessionBeFlushed;
+ protected boolean mustSessionBeClosed;
- protected Services services = null;
+ protected GraphSession graphSession;
+ protected TaskMgmtSession taskMgmtSession;
+ protected JobSession jobSession;
+ protected ContextSession contextSession;
+ protected LoggingSession loggingSession;
- protected GraphSession graphSession = null;
- protected TaskMgmtSession taskMgmtSession = null;
- protected JobSession jobSession = null;
- protected ContextSession contextSession = null;
- protected LoggingSession loggingSession = null;
+ /** @deprecated for access to other services, invoke {@link JbpmContext#getServices()} */
+ protected Services services;
public DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
- this(persistenceServiceFactory, getCurrentServices());
- }
-
- static Services getCurrentServices() {
- Services services = null;
- JbpmContext currentJbpmContext = JbpmContext.getCurrentJbpmContext();
- if (currentJbpmContext!=null) {
- services = currentJbpmContext.getServices();
- }
- return services;
- }
-
- DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory, Services services) {
this.persistenceServiceFactory = persistenceServiceFactory;
this.isTransactionEnabled = persistenceServiceFactory.isTransactionEnabled();
this.isCurrentSessionEnabled = persistenceServiceFactory.isCurrentSessionEnabled();
- this.services = services;
}
public SessionFactory getSessionFactory() {
- return session != null ? session.getSessionFactory() : persistenceServiceFactory.getSessionFactory();
+ return session != null ? session.getSessionFactory()
+ : persistenceServiceFactory.getSessionFactory();
}
public Session getSession() {
- if ( (session==null)
- && (getSessionFactory()!=null)
- ) {
+ if (session == null && getSessionFactory() != null) {
Connection connection = getConnection(false);
if (isCurrentSessionEnabled) {
log.debug("using current hibernate session");
@@ -106,20 +90,22 @@
mustSessionBeClosed = false;
mustSessionBeFlushed = false;
mustConnectionBeClosed = false;
- } else if (connection!=null) {
- log.debug("creating hibernate session with connection "+connection);
+ }
+ else if (connection != null) {
+ log.debug("creating hibernate session on " + connection);
session = getSessionFactory().openSession(connection);
mustSessionBeClosed = true;
mustSessionBeFlushed = true;
mustConnectionBeClosed = false;
- } else {
+ }
+ else {
log.debug("creating hibernate session");
session = getSessionFactory().openSession();
mustSessionBeClosed = true;
mustSessionBeFlushed = true;
mustConnectionBeClosed = false;
}
-
+
if (isTransactionEnabled) {
beginTransaction();
}
@@ -130,41 +116,34 @@
public void beginTransaction() {
log.debug("beginning hibernate transaction");
transaction = session.beginTransaction();
- log.debug("begun hibernate transaction " + transaction.toString());
+ log.debug("begun " + transaction);
}
public void endTransaction() {
- if ( (isTransactionEnabled)
- && (transaction!=null)
- ) {
- if (isRollbackOnly()) {
- try {
- log.debug("rolling back hibernate transaction " + transaction.toString());
- mustSessionBeFlushed = false; // flushing updates that will be rolled back is not very clever :-)
- transaction.rollback();
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- throw new JbpmPersistenceException("couldn't rollback hibernate session", e);
- }
- } else {
- try {
- log.debug("committing hibernate transaction " + transaction.toString());
- mustSessionBeFlushed = false; // commit does a flush anyway
- transaction.commit();
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- try {
- // if the commit fails, we must do a rollback
- transaction.rollback();
- } catch (Exception e2) {
- // if the rollback fails, we did what we could and you're in
- // deep shit :-(
- log.error("problem rolling back after failed commit", e2);
- }
- throw new JbpmPersistenceException("couldn't commit hibernate session", e);
- }
+ if (isTransactionManagedExternally()) {
+ if (session != null && getTxService().isRollbackOnly()) {
+ throw new JbpmException("cannot mark externally managed transaction for rollback");
}
+ return;
}
+
+ if (!isTransactionRollbackOnly()) {
+ Exception commitException = commit();
+ if (commitException != null) {
+ rollback();
+ closeSession();
+ closeConnection();
+ throw new JbpmPersistenceException("transaction commit failed", commitException);
+ }
+ }
+ else { // isRollbackOnly==true
+ Exception rollbackException = rollback();
+ if (rollbackException != null) {
+ closeSession();
+ closeConnection();
+ throw new JbpmPersistenceException("transaction rollback failed", rollbackException);
+ }
+ }
}
public Connection getConnection() {
@@ -172,119 +151,120 @@
}
public Connection getConnection(boolean resolveSession) {
- if (connection==null) {
- if (persistenceServiceFactory.getDataSource()!=null) {
+ if (connection == null) {
+ if (persistenceServiceFactory.getDataSource() != null) {
try {
log.debug("fetching jdbc connection from datasource");
connection = persistenceServiceFactory.getDataSource().getConnection();
mustConnectionBeClosed = true;
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- throw new JbpmException("couldn't obtain connection from datasource", e);
}
- } else {
+ catch (Exception e) {
+ // NOTE that Errors are not caught because that might halt the JVM
+ // and mask the original Error.
+ throw new JbpmException("could not obtain connection from datasource", e);
+ }
+ }
+ else {
if (resolveSession) {
// initializes the session member
getSession();
}
- if (session!=null) {
+ if (session != null) {
connection = session.connection();
- log.debug("fetching connection from hibernate session. this transfers responsibility for closing the jdbc connection to the user! "+connection);
+ log.debug("fetched "
+ + connection
+ + " from hibernate session, client is responsible for closing it!");
mustConnectionBeClosed = false;
}
}
}
return connection;
}
-
+
public boolean isTransactionActive() {
return transaction != null && transaction.isActive();
}
- protected boolean isTransactionExternallyManaged() {
- return !(isTransactionEnabled && transaction != null);
+ protected boolean isTransactionManagedExternally() {
+ return !isTransactionEnabled || transaction == null;
}
+ protected boolean isTransactionRollbackOnly() {
+ return getTxService().isRollbackOnly();
+ }
+
public void close() {
+ endTransaction();
- if ( (session!=null)
- && isTransactionExternallyManaged()
- && (isRollbackOnly())
- ) {
- throw new JbpmException("setRollbackOnly was invoked while transaction is being managed externally");
- }
-
- if ( (isTransactionEnabled)
- && (transaction!=null)
- ) {
-
- if (! isRollbackOnly()) {
- Exception commitException = commit();
- if (commitException!=null) {
- rollback();
- closeSession();
- closeConnection();
- throw new JbpmPersistenceException("hibernate commit failed", commitException);
- }
-
- } else { // isRollbackOnly==true
- Exception rollbackException = rollback();
- if (rollbackException!=null) {
- closeSession();
- closeConnection();
- throw new JbpmPersistenceException("hibernate rollback failed", rollbackException);
- }
- }
- }
-
Exception flushException = flushSession();
- if (flushException!=null) {
- // JBPM-1465: transaction is either committed or rolled back at this point;
- // it is also possible that the transaction was initiated externally
+ if (flushException != null) {
+ // JBPM-1465: at this point, the transaction is already committed or rolled back
+ // alternatively, the transaction is being managed externally
// hence rolling back here is redundant and possibly dangerous
closeSession();
closeConnection();
- throw new JbpmPersistenceException("hibernate flush failed", flushException);
+ throw new JbpmPersistenceException("hibernate flush session failed", flushException);
}
Exception closeSessionException = closeSession();
- if (closeSessionException!=null) {
+ if (closeSessionException != null) {
closeConnection();
throw new JbpmPersistenceException("hibernate close session failed", closeSessionException);
}
Exception closeConnectionException = closeConnection();
- if (closeConnectionException!=null) {
- throw new JbpmPersistenceException("hibernate close connection failed", closeConnectionException);
+ if (closeConnectionException != null) {
+ throw new JbpmPersistenceException("hibernate close connection failed",
+ closeConnectionException);
}
}
- Exception commit() {
+ protected Exception commit() {
try {
log.debug("committing " + transaction);
- mustSessionBeFlushed = false; // commit does a flush anyway
+ mustSessionBeFlushed = false; // commit does a flush anyway
transaction.commit();
- } catch (StaleStateException e) {
+ }
+ catch (StaleStateException e) {
log.info("problem committing transaction: optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("optimistic locking failed while committing " + transaction, e);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed while committing " + transaction, e);
return e;
- } catch (Exception e) {
- log.error("hibernate commit failed", e);
+ }
+ catch (Exception e) {
+ log.error("transaction commit failed", e);
return e;
}
return null;
}
- Exception flushSession() {
+ protected Exception rollback() {
+ try {
+ log.debug("rolling back " + transaction);
+ // flushing updates that will be rolled back is not very clever :-)
+ mustSessionBeFlushed = false;
+ transaction.rollback();
+ }
+ catch (Exception e) {
+ log.error("transaction rollback failed", e);
+ return e;
+ }
+ return null;
+ }
+
+ private Exception flushSession() {
if (mustSessionBeFlushed) {
try {
log.debug("flushing " + session);
session.flush();
- } catch (StaleStateException e) {
+ }
+ catch (StaleStateException e) {
log.info("problem flushing session: optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("optimistic locking failed while flushing " + session, e);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed while flushing " + session, e);
return e;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
log.error("hibernate flush failed", e);
return e;
}
@@ -292,47 +272,37 @@
return null;
}
- Exception closeConnection() {
- if (mustConnectionBeClosed) {
+ private Exception closeSession() {
+ if (mustSessionBeClosed) {
try {
- if ( (connection!=null)
- && (! connection.isClosed())
- ) {
- log.debug("closing jdbc connection");
- connection.close();
- } else {
- log.warn("jdbc connection was already closed");
+ if (session.isOpen()) {
+ log.debug("closing hibernate session");
+ session.close();
}
- } catch (Exception e) {
- log.error("hibernate session close failed", e);
+ else {
+ log.warn("hibernate session was already closed");
+ }
+ }
+ catch (Exception e) {
return e;
}
}
return null;
}
- Exception rollback() {
- try {
- log.debug("rolling back hibernate transaction");
- mustSessionBeFlushed = false; // flushing updates that will be rolled back is not very clever :-)
- transaction.rollback();
- } catch (Exception e) {
- log.error("hibernate rollback failed", e);
- return e;
- }
- return null;
- }
-
- Exception closeSession() {
- if (mustSessionBeClosed) {
+ private Exception closeConnection() {
+ if (mustConnectionBeClosed) {
try {
- if(session.isOpen()) {
- log.debug("closing hibernate session");
- session.close();
- } else {
- log.warn("hibernate session was already closed");
+ if (connection != null) {
+ log.debug("closing jdbc connection");
+ connection.close();
}
- } catch (Exception e) {
+ else {
+ log.warn("jdbc connection was already closed");
+ }
+ }
+ catch (Exception e) {
+ log.error("hibernate session close failed", e);
return e;
}
}
@@ -342,54 +312,60 @@
public void assignId(Object object) {
try {
getSession().save(object);
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- throw new JbpmPersistenceException("couldn't assign id to "+object, e);
}
+ catch (Exception e) {
+ // NOTE that Errors are not caught because that might halt the JVM
+ // and mask the original Error.
+ throw new JbpmPersistenceException("couldn't assign id to " + object, e);
+ }
}
// getters and setters //////////////////////////////////////////////////////
public GraphSession getGraphSession() {
- if (graphSession==null) {
+ if (graphSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
graphSession = new GraphSession(session);
}
}
return graphSession;
}
+
public LoggingSession getLoggingSession() {
- if (loggingSession==null) {
+ if (loggingSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
loggingSession = new LoggingSession(session);
}
}
return loggingSession;
}
+
public JobSession getJobSession() {
- if (jobSession==null) {
+ if (jobSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
jobSession = new JobSession(session);
}
}
return jobSession;
}
+
public ContextSession getContextSession() {
- if (contextSession==null) {
+ if (contextSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
contextSession = new ContextSession(session);
}
}
return contextSession;
}
+
public TaskMgmtSession getTaskMgmtSession() {
- if (taskMgmtSession==null) {
+ if (taskMgmtSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
taskMgmtSession = new TaskMgmtSession(session);
}
}
@@ -401,77 +377,132 @@
}
/**
- * @deprecated use {@link org.jbpm.tx.TxService} instead.
+ * @deprecated use {@link TxService#isRollbackOnly()} instead
*/
public boolean isRollbackOnly() {
- TxService txService = (services!=null ? services.getTxService() : null);
- if (txService==null) {
- throw new JbpmException("no jbpm tx service configured");
- }
- return txService.isRollbackOnly();
+ return getTxService().isRollbackOnly();
}
+
/**
- * @deprecated use {@link org.jbpm.tx.TxService} instead.
+ * @deprecated use {@link TxService#setRollbackOnly()} instead
*/
- public void setRollbackOnly(boolean isRollbackOnly) {
- throw new UnsupportedOperationException("method setRollbackOnly has been removed. Use TxService instead.");
+ public void setRollbackOnly() {
+ getTxService().setRollbackOnly();
}
+
/**
- * @deprecated use {@link org.jbpm.tx.TxService} instead.
+ * @throws UnsupportedOperationException if <code>rollbackOnly</code> is <code>false</code>
+ * @deprecated use {@link TxService#setRollbackOnly()} instead
*/
- public void setRollbackOnly() {
- TxService txService = (services!=null ? services.getTxService() : null);
- if (txService==null) {
- throw new JbpmException("no jbpm tx service configured");
+ public void setRollbackOnly(boolean rollbackOnly) {
+ if (!rollbackOnly) {
+ throw new UnsupportedOperationException();
}
- txService.setRollbackOnly();
+ setRollbackOnly();
}
+ private TxService getTxService() {
+ return (TxService) Services.getCurrentService(Services.SERVICENAME_TX);
+ }
+
+ /**
+ * Injects an external Hibernate session, disabling transaction management.
+ */
public void setSession(Session session) {
- this.session = session;
- log.debug("injecting a session disables transaction");
- isTransactionEnabled = false;
+ setSession(session, false);
}
+ /**
+ * Injects an external Hibernate session without affecting transaction management.
+ *
+ * @deprecated use {@link #setSession(Session, boolean) setSession(session, true)} instead
+ */
public void setSessionWithoutDisablingTx(Session session) {
+ setSession(session, true);
+ }
+
+ /**
+ * Injects an external Hibernate session. Injecting a session would normally disable transaction
+ * management. The <code>keepTransactionEnabled</code> parameter can be used to prevent
+ * transaction management from being disabled, according to the following table.
+ * <table border="1">
+ * <tr>
+ * <th>is currently enabled?</th>
+ * <th>keep enabled?</th>
+ * <th>enabled onward</th>
+ * </tr>
+ * <tr>
+ * <td>true</td>
+ * <td>true</td>
+ * <td>true (no change)</td>
+ * </tr>
+ * <tr>
+ * <td>true</td>
+ * <td>false</td>
+ * <td>false</td>
+ * </tr>
+ * <tr>
+ * <td>false</td>
+ * <td>n/a</td>
+ * <td>false (no change)</td>
+ * </tr>
+ * </table>
+ */
+ public void setSession(Session session, boolean keepTransactionEnabled) {
this.session = session;
+ if (isTransactionEnabled && !keepTransactionEnabled) {
+ log.debug("disabling transaction due to session injection");
+ isTransactionEnabled = false;
+ }
}
public void setConnection(Connection connection) {
this.connection = connection;
}
+
public void setContextSession(ContextSession contextSession) {
this.contextSession = contextSession;
}
+
public void setDataSource(DataSource dataSource) {
this.persistenceServiceFactory.dataSource = dataSource;
}
+
public void setGraphSession(GraphSession graphSession) {
this.graphSession = graphSession;
}
+
public void setLoggingSession(LoggingSession loggingSession) {
this.loggingSession = loggingSession;
}
+
public void setJobSession(JobSession jobSession) {
this.jobSession = jobSession;
}
+
public void setTaskMgmtSession(TaskMgmtSession taskMgmtSession) {
this.taskMgmtSession = taskMgmtSession;
}
+
public void setSessionFactory(SessionFactory sessionFactory) {
this.persistenceServiceFactory.sessionFactory = sessionFactory;
}
+
public Transaction getTransaction() {
return transaction;
}
+
public void setTransaction(Transaction transaction) {
this.transaction = transaction;
}
+
public boolean isTransactionEnabled() {
return isTransactionEnabled;
}
+
public void setTransactionEnabled(boolean isTransactionEnabled) {
this.isTransactionEnabled = isTransactionEnabled;
}
+
private static Log log = LogFactory.getLog(DbPersistenceService.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -21,6 +21,7 @@
*/
package org.jbpm.persistence.jta;
+import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
@@ -30,82 +31,93 @@
import org.hibernate.util.JTAHelper;
import org.jbpm.JbpmException;
import org.jbpm.persistence.db.DbPersistenceService;
+import org.jbpm.persistence.db.StaleObjectLogConfigurer;
+import org.jbpm.svc.Services;
public class JtaDbPersistenceService extends DbPersistenceService {
+ private UserTransaction transaction;
+
private static final long serialVersionUID = 1L;
private static Log log = LogFactory.getLog(JtaDbPersistenceService.class);
- private UserTransaction userTransaction;
-
public JtaDbPersistenceService(JtaDbPersistenceServiceFactory persistenceServiceFactory) {
super(persistenceServiceFactory);
- if (!isJtaTransactionInProgress()) {
- beginUserTransaction();
+ if (!isTransactionActive()) {
+ beginTransaction();
}
}
public boolean isTransactionActive() {
- return isJtaTransactionInProgress();
+ SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
+ return JTAHelper.isTransactionInProgress(sessionFactory);
}
- protected boolean isTransactionExternallyManaged() {
- return !isJtaTxCreated();
+ protected boolean isTransactionManagedExternally() {
+ return transaction == null;
}
- public void close() {
- super.close();
+ protected boolean isTransactionRollbackOnly() {
+ return super.isTransactionRollbackOnly()
+ || JTAHelper.isMarkedForRollback(getTransactionStatus());
+ }
- if (userTransaction != null) {
- endUserTransaction();
+ public void beginTransaction() {
+ try {
+ log.debug("beginning " + transaction);
+ JtaDbPersistenceServiceFactory jtaFactory = (JtaDbPersistenceServiceFactory) persistenceServiceFactory;
+ transaction = jtaFactory.getUserTransaction();
+ transaction.begin();
}
+ catch (Exception e) {
+ throw new JbpmException("transaction begin failed", e);
+ }
}
- boolean isJtaTransactionInProgress() {
- SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
- return JTAHelper.isTransactionInProgress(sessionFactory);
+ private int getTransactionStatus() {
+ try {
+ return transaction.getStatus();
+ }
+ catch (SystemException e) {
+ log.error("could not get transaction status", e);
+ return Status.STATUS_UNKNOWN;
+ }
}
- void beginUserTransaction() {
+ protected Exception commit() {
+ log.debug("committing " + transaction);
try {
- log.debug("begin user transaction");
- userTransaction = ((JtaDbPersistenceServiceFactory) persistenceServiceFactory)
- .getUserTransaction();
- userTransaction.begin();
- } catch (Exception e) {
- throw new JbpmException("couldn't begin user transaction", e);
+ transaction.commit();
+ return null;
}
- }
-
- void endUserTransaction() {
- if (isRollbackOnly() || JTAHelper.isRollback(getUserTransactionStatus())) {
- log.debug("rolling back user transaction");
- try {
- userTransaction.rollback();
- } catch (Exception e) {
- throw new JbpmException("couldn't rollback user transaction", e);
+ catch (Exception e) {
+ if (Services.isCausedByStaleState(e)) {
+ log.info("optimistic locking failed, could not commit " + transaction);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed, could not commit " + transaction, e);
}
- } else {
- log.debug("committing user transaction");
- try {
- userTransaction.commit();
- } catch (Exception e) {
- throw new JbpmException("couldn't commit user transaction", e);
+ else {
+ log.error("transaction commit failed", e);
}
+ return e;
}
}
- int getUserTransactionStatus() {
+ protected Exception rollback() {
+ log.debug("rolling back " + transaction);
try {
- return userTransaction.getStatus();
- } catch (SystemException e) {
- throw new JbpmException("couldn't get status for user transaction", e);
+ transaction.rollback();
+ return null;
}
+ catch (Exception e) {
+ log.error("transaction rollback failed", e);
+ return e;
+ }
}
public boolean isJtaTxCreated() {
- return userTransaction != null;
+ return !isTransactionManagedExternally();
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -68,11 +68,11 @@
private static List<SaveOperation> createDefaultSaveOperations() {
SaveOperation[] operations = new SaveOperation[4];
operations[0] = new CheckUnpersistableVariablesOperation();
- // first we save the runtime data (process instance)
+ // first, save the execution data (process instance)
operations[1] = new HibernateSaveOperation();
- // then we insert the logs cause the logs can have references
- // to the runtime data
+ // then, insert the logs, which may have references to the execution data
operations[2] = new SaveLogsOperation();
+ // last, save subprocess instances in cascade
operations[3] = new CascadeSaveOperation();
return Arrays.asList(operations);
}
@@ -246,9 +246,9 @@
// if this is a stale state exception, the jbpm configuration has control over the
// logging
if (isCausedByStaleState(e)) {
- log.info("problem closing service '" + serviceName + "': optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
- .error("problem closing service '" + serviceName + "': optimistic locking failed", e);
+ log.info("optimistic locking failed, could not close service: " + serviceName);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed, could not close service: " + serviceName, e);
}
else {
log.error("problem closing service '" + serviceName + "'", e);
@@ -258,8 +258,8 @@
}
}
catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the
- // original Error.
+ // NOTE that Error's are not caught because that might halt the JVM
+ // and mask the original Error.
log.error("problem closing service '" + serviceName + "'", e);
if (firstException == null) {
firstException = e;
@@ -274,10 +274,9 @@
}
}
- public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException) {
- for (Throwable cause = persistenceException.getCause(); cause != null; cause = cause.getCause()) {
- if (cause instanceof StaleStateException)
- return true;
+ public static boolean isCausedByStaleState(Exception exception) {
+ for (Throwable cause = exception.getCause(); cause != null; cause = cause.getCause()) {
+ if (cause instanceof StaleStateException) return true;
}
return false;
}
@@ -285,7 +284,7 @@
public static void assignId(Object object) {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
if (jbpmContext != null) {
- // give this process instance an id
+ // assign id to the given object
Services services = jbpmContext.getServices();
if (services.hasService(Services.SERVICENAME_PERSISTENCE)) {
PersistenceService persistenceService = services.getPersistenceService();
Deleted: jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.util;
-
-public class ArrayUtil {
-
- private ArrayUtil() {
- // hide default constructor to prevent instantiation
- }
-
- public static String toString(Object[] array) {
- if (array==null) {
- return "null";
- } else {
- StringBuffer buffer = new StringBuffer();
- buffer.append("<[");
- for (int i=0; i<array.length; i++) {
- Object o = array[i];
- if (o!=null) {
- buffer.append(o);
- } else {
- buffer.append("null");
- }
- if (i!=array.length-1) {
- buffer.append("|");
- }
- }
- buffer.append("]>");
- return buffer.toString();
- }
- }
-
-}
Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml 2009-01-28 03:17:25 UTC (rev 3724)
@@ -15,4 +15,3 @@
<property name="hibernate.connection.username">${jdbc.postgresql.username}</property>
<property name="hibernate.connection.password">${jdbc.postgresql.password}</property>
<!-- JDBC connection properties (end) -->
-
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Invocation.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Invocation.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Invocation.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -21,55 +21,52 @@
*/
package org.jbpm.mock;
-import java.util.Iterator;
+import java.util.Arrays;
import java.util.List;
-import org.jbpm.util.ArrayUtil;
-
public class Invocation {
String methodName = null;
Object[] args = null;
-
+
public Invocation(String method) {
this.methodName = method;
}
+
public Invocation(String method, Object[] args) {
this.methodName = method;
this.args = args;
}
-
+
public String getMethodName() {
return methodName;
}
-
+
public Object getArg(int i) {
return args[i];
}
-
+
public String toString() {
- if (args!=null) {
- return methodName+ArrayUtil.toString(args);
- } else {
- return methodName+"()";
+ if (args != null) {
+ return methodName + Arrays.toString(args);
}
+ else {
+ return methodName + "[]";
+ }
}
-
- public static Invocation getInvocation(List invocations, String methodName, int index) {
- Invocation i = null;
+
+ public static Invocation getInvocation(List<Invocation> invocations, String methodName, int index) {
int count = 0;
- Iterator iter = invocations.iterator();
- while (i==null && iter.hasNext()) {
- Invocation invocation = (Invocation) iter.next();
+ for (Invocation invocation : invocations) {
if (methodName.equals(invocation.getMethodName())) {
-
- if (count==index) {
- i = invocation;
- } else {
+ if (count == index) {
+ return invocation;
+ }
+ else {
count++;
}
}
}
- return i;
+ return null;
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Recorded.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Recorded.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/mock/Recorded.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -25,5 +25,6 @@
public interface Recorded {
- List getInvocations();
+ List<Invocation> getInvocations();
+
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2009-01-27 10:14:30 UTC (rev 3723)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2009-01-28 03:17:25 UTC (rev 3724)
@@ -22,6 +22,7 @@
package org.jbpm.persistence.db;
import java.sql.Connection;
+import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
@@ -38,21 +39,20 @@
import org.jbpm.svc.Services;
public class PersistenceServiceDbTest extends AbstractJbpmTestCase {
-
- public void testDefaults() throws Exception {
+
+ public void testDefaults() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
DbPersistenceServiceFactory persistenceServiceFactory = null;
DbPersistenceService persistenceService = null;
-
try {
persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
persistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
-
+
assertNotNull(persistenceService);
assertSame(persistenceServiceFactory, persistenceService.persistenceServiceFactory);
-
+
assertNull(persistenceServiceFactory.configuration);
assertNull(persistenceServiceFactory.dataSource);
assertNull(persistenceServiceFactory.dataSourceJndiName);
@@ -67,12 +67,12 @@
assertNull(persistenceService.loggingSession);
assertNull(persistenceService.jobSession);
assertNull(persistenceService.taskMgmtSession);
-
+
Session session = persistenceService.getSession();
assertSame(session, persistenceService.session);
assertNull(persistenceService.connection);
-
+
assertNotNull(persistenceServiceFactory.configuration);
assertNotNull(persistenceServiceFactory.sessionFactory);
assertNotNull(persistenceService.transaction);
@@ -88,13 +88,13 @@
assertNull(persistenceService.loggingSession);
assertNull(persistenceService.jobSession);
assertNull(persistenceService.taskMgmtSession);
-
+
assertTrue(persistenceService.transaction.isActive());
assertTrue(persistenceService.session.isOpen());
assertFalse(persistenceService.transaction.wasCommitted());
assertFalse(persistenceService.transaction.wasRolledBack());
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
@@ -108,33 +108,32 @@
assertFalse(persistenceService.session.isConnected());
}
- public void testRollbackWithoutSessionCreation() throws Exception {
+ public void testRollbackWithoutSessionCreation() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
DbPersistenceService persistenceService = null;
-
try {
persistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
-
jbpmContext.setRollbackOnly();
- } finally {
+ }
+ finally {
jbpmContext.close();
}
assertNull(persistenceService.transaction);
}
- public void testRollback() throws Exception {
+ public void testRollback() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
DbPersistenceService persistenceService = null;
-
try {
persistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
jbpmContext.setRollbackOnly();
persistenceService.getSession();
- } finally {
+ }
+ finally {
jbpmContext.close();
}
@@ -143,14 +142,13 @@
assertTrue(persistenceService.transaction.wasRolledBack());
assertFalse(persistenceService.session.isOpen());
}
-
- public void testUserSuppliedConnection() throws Exception {
+
+ public void testUserSuppliedConnection() throws SQLException {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
DbPersistenceService persistenceService = null;
- Recorded recordedConnection = null;
-
+ Recorded recordedConnection = null;
try {
persistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
@@ -159,29 +157,28 @@
persistenceService.setConnection(connection);
Session session = persistenceService.getSession();
-
+
assertNotNull(persistenceService.transaction);
assertSame(session, persistenceService.session);
recordedConnection = (Recorded) connection;
- List invocations = recordedConnection.getInvocations();
+ List<Invocation> invocations = recordedConnection.getInvocations();
assertNull(Invocation.getInvocation(invocations, "commit", 0));
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
- List invocations = recordedConnection.getInvocations();
+ List<Invocation> invocations = recordedConnection.getInvocations();
assertNotNull(Invocation.getInvocation(invocations, "commit", 0));
assertNull(Invocation.getInvocation(invocations, "close", 0));
}
-
- public void testUserSuppliedConnectionWithRollback() throws Exception {
+
+ public void testUserSuppliedConnectionWithRollback() throws SQLException {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
DbPersistenceService persistenceService = null;
- Recorded recordedConnection = null;
-
+ Recorded recordedConnection = null;
try {
persistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
@@ -191,92 +188,93 @@
Session session = persistenceService.getSession();
jbpmContext.setRollbackOnly();
-
+
assertNotNull(persistenceService.transaction);
assertSame(session, persistenceService.session);
- recordedConnection = (Recorded)connection;
- List invocations = recordedConnection.getInvocations();
+ recordedConnection = (Recorded) connection;
+ List<Invocation> invocations = recordedConnection.getInvocations();
assertNull(Invocation.getInvocation(invocations, "commit", 0));
assertNull(Invocation.getInvocation(invocations, "rollback", 0));
- } finally {
+ }
+ finally {
jbpmContext.close();
}
-
- List invocations = recordedConnection.getInvocations();
+
+ List<Invocation> invocations = recordedConnection.getInvocations();
assertNull(Invocation.getInvocation(invocations, "commit", 0));
assertNotNull(Invocation.getInvocation(invocations, "rollback", 0));
}
-
- public void testUserSuppliedSession() throws Exception {
+
+ public void testUserSuppliedSession() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
DbPersistenceService persistenceService = null;
-
try {
persistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
- Session session = sessionFactory.openSession();
-
+ Session session = persistenceServiceFactory.getSessionFactory().openSession();
+
jbpmContext.setSession(session);
-
+
persistenceService.getSession();
assertNull(persistenceService.transaction);
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
- persistenceService.close();
assertNull(persistenceService.transaction);
assertNotNull(persistenceService.session);
assertTrue(persistenceService.session.isOpen());
}
- public void testUserSuppliedSessionWithRollback() throws Exception {
+ public void testUserSuppliedSessionWithRollback() throws SQLException {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
try {
DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
-
+
DataSource dataSource = Jdbc.createRecordedDataSource();
Connection connection = dataSource.getConnection();
Session session = sessionFactory.openSession(connection);
jbpmContext.setSession(session);
jbpmContext.setRollbackOnly();
-
- } finally {
+ }
+ finally {
try {
jbpmContext.close();
fail("expected exception");
- } catch (JbpmException e) {
+ }
+ catch (JbpmException e) {
// OK
}
}
}
- public void testTransferResponsibility() throws Exception {
+ public void testTransferResponsibility() throws SQLException {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService dbPersistenceService = null;
- Connection connection = null;
+
+ DbPersistenceService dbPersistenceService;
+ Connection connection;
try {
- dbPersistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
+ dbPersistenceService = (DbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
connection = jbpmContext.getConnection();
- } finally {
+ }
+ finally {
jbpmContext.close();
}
assertFalse(dbPersistenceService.session.isOpen());
assertFalse(dbPersistenceService.session.isConnected());
- // Since 3.2.1, hibernate hides direct access to the connecion after session has closed. Bummer...
- // assertFalse(connection.isClosed());
+
+ connection.close();
}
}
15 years, 3 months
JBoss JBPM SVN: r3723 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-01-27 05:14:30 -0500 (Tue, 27 Jan 2009)
New Revision: 3723
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
Log:
[JBPM-1989] Null Pointer Exception in jBPM JobExecutor on server shutdown
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-01-27 10:06:02 UTC (rev 3722)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-01-27 10:14:30 UTC (rev 3723)
@@ -15,8 +15,8 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
-public class JobExecutor implements Serializable {
-
+public class JobExecutor implements Serializable
+{
private static final long serialVersionUID = 1L;
protected JbpmConfiguration jbpmConfiguration;
@@ -38,53 +38,65 @@
protected static String hostName;
- public synchronized void start() {
- if (!isStarted) {
+ public synchronized void start()
+ {
+ if (!isStarted)
+ {
log.debug("starting thread group '" + name + "'...");
- for (int i = 0; i < nbrOfThreads; i++) {
+ for (int i = 0; i < nbrOfThreads; i++)
+ {
startThread();
}
- lockMonitorThread = new LockMonitorThread(jbpmConfiguration, lockMonitorInterval,
- maxLockTime, lockBufferTime);
+ lockMonitorThread = new LockMonitorThread(jbpmConfiguration, lockMonitorInterval, maxLockTime, lockBufferTime);
isStarted = true;
}
- else {
+ else
+ {
log.debug("ignoring start: thread group '" + name + "' is already started'");
}
}
- /**
- * signals to all threads in this job executor to stop. It may be that threads are in the middle
- * of something and they will finish that first. Use {@link #stopAndJoin()} in case you want a
- * method that blocks until all the threads are actually finished.
- *
- * @return a list of all the stopped threads. In case no threads were stopped an empty list will
- * be returned.
+ /*
+ * signals to all threads in this job executor to stop. It may be that threads are in the middle of something and they will finish that first. Use {@link
+ * #stopAndJoin()} in case you want a method that blocks until all the threads are actually finished.
+ * @return a list of all the stopped threads. In case no threads were stopped an empty list will be returned.
*/
- public synchronized List<Thread> stop() {
+ public synchronized List<Thread> stop()
+ {
List<Thread> stoppedThreads = new ArrayList<Thread>(threads.size());
- if (isStarted) {
+ if (isStarted)
+ {
log.debug("stopping thread group '" + name + "'...");
- for (int i = 0; i < nbrOfThreads; i++) {
+ for (int i = 0; i < nbrOfThreads; i++)
+ {
stoppedThreads.add(stopThread());
}
- lockMonitorThread.deactivate();
+
+ if (lockMonitorThread != null)
+ lockMonitorThread.deactivate();
+
isStarted = false;
}
- else {
+ else
+ {
log.debug("ignoring stop: thread group '" + name + "' not started");
}
return stoppedThreads;
}
- public void stopAndJoin() throws InterruptedException {
- for (Thread thread : stop()) {
+ public void stopAndJoin() throws InterruptedException
+ {
+ for (Thread thread : stop())
+ {
thread.join();
}
- lockMonitorThread.join();
+
+ if (lockMonitorThread != null)
+ lockMonitorThread.join();
}
- protected synchronized void startThread() {
+ protected synchronized void startThread()
+ {
String threadName = getNextThreadName();
Thread thread = createThread(threadName);
threads.put(threadName, thread);
@@ -92,166 +104,203 @@
thread.start();
}
- protected Thread createThread(String threadName) {
+ protected Thread createThread(String threadName)
+ {
return new JobExecutorThread(threadName, this);
}
- protected String getNextThreadName() {
+ protected String getNextThreadName()
+ {
return getThreadName(threads.size() + 1);
}
- protected String getLastThreadName() {
+ protected String getLastThreadName()
+ {
return getThreadName(threads.size());
}
- private String getThreadName(int index) {
+ private String getThreadName(int index)
+ {
return name + ":" + getHostAddress() + ":" + index;
}
- private static String getHostAddress() {
- if (hostName == null) {
- try {
+ private static String getHostAddress()
+ {
+ if (hostName == null)
+ {
+ try
+ {
hostName = InetAddress.getLocalHost().getHostAddress();
}
- catch (UnknownHostException e) {
+ catch (UnknownHostException e)
+ {
hostName = "127.0.0.1";
}
}
return hostName;
}
- protected synchronized Thread stopThread() {
+ protected synchronized Thread stopThread()
+ {
String threadName = getLastThreadName();
- JobExecutorThread thread = (JobExecutorThread) threads.remove(threadName);
+ JobExecutorThread thread = (JobExecutorThread)threads.remove(threadName);
log.debug("removing job executor thread '" + threadName + "'");
thread.deactivate();
return thread;
}
- public Set<Long> getMonitoredJobIds() {
+ public Set<Long> getMonitoredJobIds()
+ {
return new HashSet<Long>(monitoredJobIds.values());
}
- public void addMonitoredJobId(String threadName, long jobId) {
+ public void addMonitoredJobId(String threadName, long jobId)
+ {
monitoredJobIds.put(threadName, new Long(jobId));
}
- public void removeMonitoredJobId(String threadName) {
+ public void removeMonitoredJobId(String threadName)
+ {
monitoredJobIds.remove(threadName);
}
- /**
+ /*
* @throws UnsupportedOperationException to prevent invocation
* @deprecated <code>monitoredJobIds</code> is an internal control field
*/
- public void setMonitoredJobIds(Map<String, Long> monitoredJobIds) {
+ public void setMonitoredJobIds(Map<String, Long> monitoredJobIds)
+ {
throw new UnsupportedOperationException();
}
- public int getHistoryMaxSize() {
+ public int getHistoryMaxSize()
+ {
return historyMaxSize;
}
- public void setHistoryMaxSize(int historyMaxSize) {
+ public void setHistoryMaxSize(int historyMaxSize)
+ {
this.historyMaxSize = historyMaxSize;
}
- public int getIdleInterval() {
+ public int getIdleInterval()
+ {
return idleInterval;
}
- public void setIdleInterval(int idleInterval) {
+ public void setIdleInterval(int idleInterval)
+ {
this.idleInterval = idleInterval;
}
- /**
+ /*
* Tells whether this job executor has been {@linkplain #start() started}.
*/
- public boolean isStarted() {
+ public boolean isStarted()
+ {
return isStarted;
}
- /**
+ /*
* @throws UnsupportedOperationException to prevent invocation
* @deprecated <code>isStarted</code> is an internal control field
*/
- public void setStarted(boolean isStarted) {
+ public void setStarted(boolean isStarted)
+ {
throw new UnsupportedOperationException();
}
- public JbpmConfiguration getJbpmConfiguration() {
+ public JbpmConfiguration getJbpmConfiguration()
+ {
return jbpmConfiguration;
}
- public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration) {
+ public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration)
+ {
this.jbpmConfiguration = jbpmConfiguration;
}
- public int getMaxIdleInterval() {
+ public int getMaxIdleInterval()
+ {
return maxIdleInterval;
}
- public void setMaxIdleInterval(int maxIdleInterval) {
+ public void setMaxIdleInterval(int maxIdleInterval)
+ {
this.maxIdleInterval = maxIdleInterval;
}
- public String getName() {
+ public String getName()
+ {
return name;
}
- public void setName(String name) {
+ public void setName(String name)
+ {
this.name = name;
}
- public int getSize() {
+ public int getSize()
+ {
return nbrOfThreads;
}
- public void setSize(int nbrOfThreads) {
+ public void setSize(int nbrOfThreads)
+ {
this.nbrOfThreads = nbrOfThreads;
}
- public Map<String, Thread> getThreads() {
+ public Map<String, Thread> getThreads()
+ {
return threads;
}
- /**
+ /*
* @throws UnsupportedOperationException to prevent invocation
* @deprecated <code>thread</code> is an internal control field
*/
- public void setThreads(Map<String, Thread> threads) {
+ public void setThreads(Map<String, Thread> threads)
+ {
throw new UnsupportedOperationException();
}
- public int getMaxLockTime() {
+ public int getMaxLockTime()
+ {
return maxLockTime;
}
- public void setMaxLockTime(int maxLockTime) {
+ public void setMaxLockTime(int maxLockTime)
+ {
this.maxLockTime = maxLockTime;
}
- public int getLockBufferTime() {
+ public int getLockBufferTime()
+ {
return lockBufferTime;
}
- public void setLockBufferTime(int lockBufferTime) {
+ public void setLockBufferTime(int lockBufferTime)
+ {
this.lockBufferTime = lockBufferTime;
}
- public int getLockMonitorInterval() {
+ public int getLockMonitorInterval()
+ {
return lockMonitorInterval;
}
- public void setLockMonitorInterval(int lockMonitorInterval) {
+ public void setLockMonitorInterval(int lockMonitorInterval)
+ {
this.lockMonitorInterval = lockMonitorInterval;
}
- public int getNbrOfThreads() {
+ public int getNbrOfThreads()
+ {
return nbrOfThreads;
}
- public void setNbrOfThreads(int nbrOfThreads) {
+ public void setNbrOfThreads(int nbrOfThreads)
+ {
this.nbrOfThreads = nbrOfThreads;
}
15 years, 3 months
JBoss JBPM SVN: r3722 - jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/job/executor.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-01-27 05:06:02 -0500 (Tue, 27 Jan 2009)
New Revision: 3722
Modified:
jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
Log:
[JBPM-1989] Null Pointer Exception in jBPM JobExecutor on server shutdown
Modified: jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-01-27 08:05:12 UTC (rev 3721)
+++ jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-01-27 10:06:02 UTC (rev 3722)
@@ -16,7 +16,8 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
-public class JobExecutor implements Serializable {
+public class JobExecutor implements Serializable
+{
private static final long serialVersionUID = 1L;
@@ -39,204 +40,255 @@
protected static String hostName;
- public synchronized void start() {
- if (! isStarted) {
- log.debug("starting thread group '"+name+"'...");
- for (int i=0; i<nbrOfThreads; i++) {
+ 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'");
}
+ else
+ {
+ log.debug("ignoring start: thread group '" + name + "' is already started'");
+ }
}
-
- /**
- * signals to all threads in this job executor to stop. It may be that
- * threads are in the middle of something and they will finish that firts.
- * Use {@link #stopAndJoin()} in case you want a method that blocks until
- * all the threads are actually finished.
- * @return a list of all the stopped threads. In case no threads were stopped
- * an empty list will be returned.
+
+ /*
+ * signals to all threads in this job executor to stop. It may be that threads are in the middle of something and they will finish that firts. Use {@link
+ * #stopAndJoin()} in case you want a method that blocks until all the threads are actually finished.
+ * @return a list of all the stopped threads. In case no threads were stopped an empty list will be returned.
*/
- public synchronized List stop() {
+ public synchronized List stop()
+ {
List stoppedThreads = new ArrayList(threads.size());
- if (isStarted) {
- log.debug("stopping thread group '"+name+"'...");
- for (int i=0; i<nbrOfThreads; i++) {
+ if (isStarted)
+ {
+ log.debug("stopping thread group '" + name + "'...");
+ for (int i = 0; i < nbrOfThreads; i++)
+ {
stoppedThreads.add(stopThread());
}
- lockMonitorThread.deactivate();
+ if (lockMonitorThread != null)
+ lockMonitorThread.deactivate();
isStarted = false;
- } else {
- log.debug("ignoring stop: thread group '"+name+"' not started");
}
+ else
+ {
+ log.debug("ignoring stop: thread group '" + name + "' not started");
+ }
return stoppedThreads;
}
- public void stopAndJoin() throws InterruptedException {
+ public void stopAndJoin() throws InterruptedException
+ {
Iterator iter = stop().iterator();
- while (iter.hasNext()) {
- Thread thread = (Thread) iter.next();
+ while (iter.hasNext())
+ {
+ Thread thread = (Thread)iter.next();
thread.join();
}
- lockMonitorThread.join();
+ if (lockMonitorThread != null)
+ lockMonitorThread.join();
}
- protected synchronized void startThread() {
+ protected synchronized void startThread()
+ {
String threadName = getNextThreadName();
Thread thread = createThread(threadName);
threads.put(threadName, thread);
- log.debug("starting new job executor thread '"+threadName+"'");
+ log.debug("starting new job executor thread '" + threadName + "'");
thread.start();
}
- protected Thread createThread(String threadName) {
+ protected Thread createThread(String threadName)
+ {
return new JobExecutorThread(threadName, this, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, historyMaxSize);
}
- protected String getNextThreadName() {
- return getThreadName(threads.size()+1);
+ protected String getNextThreadName()
+ {
+ return getThreadName(threads.size() + 1);
}
- protected String getLastThreadName() {
+
+ protected String getLastThreadName()
+ {
return getThreadName(threads.size());
}
-
- private String getThreadName(int index) {
+
+ private String getThreadName(int index)
+ {
return name + ":" + getHostName() + ":" + index;
}
- private static String getHostName() {
- if (hostName == null) {
- try {
+ private static String getHostName()
+ {
+ if (hostName == null)
+ {
+ try
+ {
hostName = InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
+ }
+ catch (UnknownHostException e)
+ {
hostName = "127.0.0.1";
- }
+ }
}
return hostName;
}
- protected synchronized Thread stopThread() {
+ protected synchronized Thread stopThread()
+ {
String threadName = getLastThreadName();
- JobExecutorThread thread = (JobExecutorThread) threads.remove(threadName);
- log.debug("removing job executor thread '"+threadName+"'");
+ JobExecutorThread thread = (JobExecutorThread)threads.remove(threadName);
+ log.debug("removing job executor thread '" + threadName + "'");
thread.deactivate();
return thread;
}
- public void setMonitoredJobIds(Map monitoredJobIds) {
- this.monitoredJobIds = monitoredJobIds;
- }
-
- public Set getMonitoredJobIds() {
+ public void setMonitoredJobIds(Map monitoredJobIds)
+ {
+ this.monitoredJobIds = monitoredJobIds;
+ }
+
+ public Set getMonitoredJobIds()
+ {
return new HashSet(monitoredJobIds.values());
}
-
- public void addMonitoredJobId(String threadName, long jobId) {
+
+ public void addMonitoredJobId(String threadName, long jobId)
+ {
monitoredJobIds.put(threadName, new Long(jobId));
}
-
- public void removeMonitoredJobId(String threadName) {
+
+ public void removeMonitoredJobId(String threadName)
+ {
monitoredJobIds.remove(threadName);
}
- public void setHistoryMaxSize(int historyMaxSize) {
- this.historyMaxSize = historyMaxSize;
- }
-
- public int getHistoryMaxSize() {
+ public void setHistoryMaxSize(int historyMaxSize)
+ {
+ this.historyMaxSize = historyMaxSize;
+ }
+
+ public int getHistoryMaxSize()
+ {
return historyMaxSize;
}
-
- public void setIdleInterval(int idleInterval) {
- this.idleInterval = idleInterval;
+
+ public void setIdleInterval(int idleInterval)
+ {
+ this.idleInterval = idleInterval;
}
-
- public int getIdleInterval() {
+
+ public int getIdleInterval()
+ {
return idleInterval;
}
-
- public void setStarted(boolean isStarted) {
- this.isStarted = isStarted;
+
+ public void setStarted(boolean isStarted)
+ {
+ this.isStarted = isStarted;
}
-
- public boolean isStarted() {
+
+ public boolean isStarted()
+ {
return isStarted;
}
-
- public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration) {
- this.jbpmConfiguration = jbpmConfiguration;
- }
-
- public JbpmConfiguration getJbpmConfiguration() {
+
+ public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration)
+ {
+ this.jbpmConfiguration = jbpmConfiguration;
+ }
+
+ public JbpmConfiguration getJbpmConfiguration()
+ {
return jbpmConfiguration;
}
-
- public void setMaxIdleInterval(int maxIdleInterval) {
- this.maxIdleInterval = maxIdleInterval;
- }
-
- public int getMaxIdleInterval() {
+
+ public void setMaxIdleInterval(int maxIdleInterval)
+ {
+ this.maxIdleInterval = maxIdleInterval;
+ }
+
+ public int getMaxIdleInterval()
+ {
return maxIdleInterval;
}
-
- public void setName(String name) {
- this.name = name;
+
+ public void setName(String name)
+ {
+ this.name = name;
}
-
- public String getName() {
+
+ public String getName()
+ {
return name;
}
-
- public void setSize(int nbrOfThreads) {
- this.nbrOfThreads = nbrOfThreads;
+
+ public void setSize(int nbrOfThreads)
+ {
+ this.nbrOfThreads = nbrOfThreads;
}
-
- public int getSize() {
+
+ public int getSize()
+ {
return nbrOfThreads;
}
-
- public void setThreads(Map threads) {
- this.threads = threads;
+
+ public void setThreads(Map threads)
+ {
+ this.threads = threads;
}
-
- public Map getThreads() {
+
+ public Map getThreads()
+ {
return threads;
}
-
- public void setMaxLockTime(int maxLockTime) {
- this.maxLockTime = maxLockTime;
+
+ public void setMaxLockTime(int maxLockTime)
+ {
+ this.maxLockTime = maxLockTime;
}
-
- public int getMaxLockTime() {
+
+ public int getMaxLockTime()
+ {
return maxLockTime;
}
-
- public void setLockBufferTime(int lockBufferTime) {
- this.lockBufferTime = lockBufferTime;
+
+ public void setLockBufferTime(int lockBufferTime)
+ {
+ this.lockBufferTime = lockBufferTime;
}
-
- public int getLockBufferTime() {
+
+ public int getLockBufferTime()
+ {
return lockBufferTime;
}
-
- public void setLockMonitorInterval(int lockMonitorInterval) {
- this.lockMonitorInterval = lockMonitorInterval;
+
+ public void setLockMonitorInterval(int lockMonitorInterval)
+ {
+ this.lockMonitorInterval = lockMonitorInterval;
}
-
- public int getLockMonitorInterval() {
+
+ public int getLockMonitorInterval()
+ {
return lockMonitorInterval;
}
-
- public void setNbrOfThreads(int nbrOfThreads) {
- this.nbrOfThreads = nbrOfThreads;
+
+ public void setNbrOfThreads(int nbrOfThreads)
+ {
+ this.nbrOfThreads = nbrOfThreads;
}
-
- public int getNbrOfThreads() {
+
+ public int getNbrOfThreads()
+ {
return nbrOfThreads;
}
-
+
private static Log log = LogFactory.getLog(JobExecutor.class);
}
15 years, 3 months
JBoss JBPM SVN: r3721 - jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/persistence/jta.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-27 03:05:12 -0500 (Tue, 27 Jan 2009)
New Revision: 3721
Modified:
jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
Log:
JBPM-1988 throw JbpmPersistenceException from JtaDbPersistenceService
Modified: jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2009-01-26 17:21:56 UTC (rev 3720)
+++ jbpm3/branches/jbpm-3.2.4.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2009-01-27 08:05:12 UTC (rev 3721)
@@ -29,6 +29,7 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.util.JTAHelper;
import org.jbpm.JbpmException;
+import org.jbpm.persistence.JbpmPersistenceException;
import org.jbpm.persistence.db.DbPersistenceService;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -81,14 +82,14 @@
try {
userTransaction.rollback();
} catch (Exception e) {
- throw new JbpmException("couldn't rollback user transaction", e);
+ throw new JbpmPersistenceException("couldn't rollback user transaction", e);
}
} else {
log.debug("committing user transaction");
try {
userTransaction.commit();
} catch (Exception e) {
- throw new JbpmException("couldn't commit user transaction", e);
+ throw new JbpmPersistenceException("couldn't commit user transaction", e);
}
}
}
@@ -97,7 +98,7 @@
try {
return userTransaction.getStatus();
} catch (SystemException e) {
- throw new JbpmException("couldn't get status for user transaction", e);
+ throw new JbpmPersistenceException("couldn't get status for user transaction", e);
}
}
15 years, 3 months
JBoss JBPM SVN: r3720 - jbpm3/branches.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-26 12:21:56 -0500 (Mon, 26 Jan 2009)
New Revision: 3720
Added:
jbpm3/branches/jbpm-3.2.4.SP/
Log:
creating 3.2.4.SP branch for inclusion in SOA-P
Copied: jbpm3/branches/jbpm-3.2.4.SP (from rev 3719, jbpm3/tags/jbpm-3.2.4.GA)
15 years, 3 months
JBoss JBPM SVN: r3719 - jbpm4/trunk/modules/test-db/src/main/resources.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-01-23 12:03:23 -0500 (Fri, 23 Jan 2009)
New Revision: 3719
Modified:
jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
Log:
rolled back unintended logging.properties update
Modified: jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2009-01-23 17:02:45 UTC (rev 3718)
+++ jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2009-01-23 17:03:23 UTC (rev 3719)
@@ -22,7 +22,7 @@
org.hibernate.level=INFO
org.hibernate.cfg.HbmBinder.level=SEVERE
org.hibernate.cfg.SettingsFactory.level=SEVERE
-org.hibernate.SQL.level=FINEST
-org.hibernate.type.level=FINEST
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
# org.hibernate.transaction.level=FINEST
15 years, 3 months
JBoss JBPM SVN: r3718 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal and 12 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-01-23 12:02:45 -0500 (Fri, 23 Jan 2009)
New Revision: 3718
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
Log:
improved query api on process, execution and task service
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionQuery.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -29,15 +29,18 @@
*/
public interface ExecutionQuery {
- ExecutionQuery onlyProcessInstances();
-
+ String PROPERTY_KEY = "key";
+
ExecutionQuery processDefinitionNameLike(String processDefinitionName);
ExecutionQuery processDefinitionKeyLike(String processDefinitionKey);
ExecutionQuery processDefinitionId(String processDefinitionId);
- ExecutionQuery orderByKeyAsc();
- ExecutionQuery orderByKeyDesc();
+ ExecutionQuery processInstanceId(String processInstanceId);
- List<Execution> list();
- List<Execution> list(int firstResult, int maxResults);
+ ExecutionQuery orderAsc(String property);
+ ExecutionQuery orderDesc(String property);
+
+ ExecutionQuery page(int firstResult, int maxResults);
+
+ List<Execution> execute();
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -117,6 +117,9 @@
/** search for executions with criteria */
ExecutionQuery createExecutionQuery();
+ /** search for process instances with criteria */
+ ExecutionQuery createProcessInstanceQuery();
+
/** creates or overwrites a variable value on the referenced execution */
Execution setVariable(String executionId, String name, Object value);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -28,15 +28,17 @@
*/
public interface ProcessDefinitionQuery {
+ String PROPERTY_NAME = "name";
+ String PROPERTY_KEY = "key";
+ String PROPERTY_PACKAGENAME = "packageName";
+ String PROPERTY_VERSION = "version";
+ String PROPERTY_DEPLOYMENTTIME = "deploymentTime";
+
ProcessDefinitionQuery nameLike(String name);
ProcessDefinitionQuery keyLike(String key);
- ProcessDefinitionQuery orderByNameAsc();
- ProcessDefinitionQuery orderByNameDesc();
+ ProcessDefinitionQuery orderAsc(String property);
+ ProcessDefinitionQuery orderDesc(String property);
- ProcessDefinitionQuery orderByKeyAsc();
- ProcessDefinitionQuery orderByKeyDesc();
-
- List<ProcessDefinition> list();
- List<ProcessDefinition> list(int firstResult, int maxResults);
+ List<ProcessDefinition> execute();
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -31,11 +31,12 @@
*/
public interface TaskQuery {
- public static final String NAME = "name";
- public static final String ASSIGNEE = "assignee";
- public static final String CREATEDATE = "create-date";
- public static final String DUEDATE = "due-date";
- public static final String PRIORITY = "priority";
+ public static final String PROPERTY_NAME = "name";
+ public static final String PROPERTY_ASSIGNEE = "assignee";
+ public static final String PROPERTY_CREATEDATE = "create";
+ public static final String PROPERTY_DUEDATE = "dueDate";
+ public static final String PROPERTY_PRIORITY = "priority";
+ public static final String PROPERTY_PROGRESS = "progress";
TaskQuery assignee(String assignee);
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.jbpm.JbpmException;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HqlQueryOldCmd implements Command<List<Object>> {
-
- private static final long serialVersionUID = 1L;
-
- private static Log log = Log.getLog(HqlQueryOldCmd.class.getName());
-
- String hql;
- Integer firstResult;
- Integer maxResults;
-
- public HqlQueryOldCmd(String hql, Integer firstResult, Integer maxResults) {
- this.hql = hql;
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- }
-
- public List<Object> execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- if (session==null) {
- throw new JbpmException("no hibernate-session defined in configuration");
- }
-
- Query query = session.createQuery(hql);
- if (firstResult!=null) {
- query.setFirstResult(firstResult);
- }
- if (maxResults!=null) {
- query.setMaxResults(maxResults);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("executing hql: ");
- log.debug(hql);
- }
-
- return query.list();
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AbstractQuery implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected CommandService commandService;
+ protected String orderByClause = null;
+ protected Page page = null;
+ protected boolean isWhereAdded = false;
+
+ public AbstractQuery(CommandService commandService) {
+ this.commandService = commandService;
+ }
+
+ protected abstract void applyParameters(Query query);
+
+ public abstract String hql();
+
+ /* reuse by copy and paste:
+ * (return type can't be changed)
+ public ConcreteQuery page(int firstResult, int maxResults) {
+ this.page = new Page{firstResult, maxResults};
+ return this;
+ }
+ */
+
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ String hql = hql();
+ Query query = session.createQuery(hql);
+ applyParameters(query);
+ applyPage(query);
+ return query.list();
+ }
+
+ protected void appendWhereClause(String whereClause, StringBuffer hql) {
+ if (isWhereAdded) {
+ hql.append(" and ");
+ } else {
+ hql.append("where ");
+ }
+ hql.append(whereClause);
+ }
+
+ protected void appendOrderByClause(StringBuffer hql) {
+ if (orderByClause!=null) {
+ hql.append("order by ");
+ hql.append(orderByClause);
+ }
+ }
+
+ protected void applyPage(Query query) {
+ if (page!=null) {
+ query.setFirstResult(page.firstResult);
+ query.setMaxResults(page.maxResults);
+ }
+ }
+
+ protected void addOrderByClause(String clause) {
+ if (orderByClause==null) {
+ orderByClause = clause;
+ } else {
+ orderByClause += ", " + clause;
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java (from rev 3707, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.Execution;
+import org.jbpm.ExecutionQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionQueryImpl extends AbstractQuery implements ExecutionQuery {
+
+ private static final long serialVersionUID = 1L;
+
+ protected boolean onlyProcessInstances;
+ protected String processDefinitionNameLike;
+ protected String processDefinitionKeyLike;
+ protected String processDefinitionId;
+ protected String processInstanceId;
+
+ public ExecutionQueryImpl(CommandService commandService, boolean onlyProcessInstances) {
+ super(commandService);
+ this.onlyProcessInstances = onlyProcessInstances;
+ }
+
+ public List<Execution> execute() {
+ return (List<Execution>) commandService.execute(this);
+ }
+
+ public String hql() {
+ StringBuffer hql = new StringBuffer();
+ hql.append("select execution ");
+ hql.append("from ");
+ hql.append(ExecutionImpl.class.getName());
+ hql.append(" as execution ");
+
+ if (onlyProcessInstances) {
+ appendWhereClause("execution.processInstance.dbid = execution.dbid ", hql);
+ }
+
+ if (processInstanceId!=null) {
+ appendWhereClause("execution.processInstance.id = '"+processInstanceId+"' ", hql);
+ }
+
+ if (processDefinitionId!=null) {
+ appendWhereClause("e.processDefinition.id = '"+processDefinitionId+"' ", hql);
+ }
+
+ if (processDefinitionNameLike!=null) {
+ appendWhereClause("e.processDefinition.name like '"+processDefinitionNameLike+"' ", hql);
+ }
+
+ if (processDefinitionKeyLike!=null) {
+ appendWhereClause("e.processDefinition.key like '"+processDefinitionKeyLike+"' ", hql);
+ }
+
+ appendOrderByClause(hql);
+
+ return hql.toString();
+ }
+
+ protected void applyParameters(Query query) {
+ }
+
+ public ExecutionQuery orderAsc(String property) {
+ addOrderByClause("e."+property+" asc");
+ return this;
+ }
+
+ public ExecutionQuery orderDesc(String property) {
+ addOrderByClause("e."+property+" desc");
+ return this;
+ }
+
+ public ExecutionQuery processDefinitionId(String processDefinitionId) {
+ this.processDefinitionId = processDefinitionId;
+ return this;
+ }
+
+ public ExecutionQuery processDefinitionKeyLike(String processDefinitionKey) {
+ this.processDefinitionKeyLike = processDefinitionKey;
+ return this;
+ }
+
+ public ExecutionQuery processDefinitionNameLike(String processDefinitionName) {
+ this.processDefinitionNameLike = processDefinitionName;
+ return this;
+ }
+
+ public ExecutionQuery page(int firstResult, int maxResults) {
+ this.page = new Page(firstResult, maxResults);
+ return this;
+ }
+
+ public ExecutionQuery processInstanceId(String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ return this;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Page implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public int firstResult;
+ public int maxResults;
+
+ public Page(int firstResult, int maxResults) {
+ this.firstResult = firstResult;
+ this.maxResults = maxResults;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java (from rev 3707, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryImpl extends AbstractQuery implements ProcessDefinitionQuery {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String NEWLINE = System.getProperty("line.separator");
+
+ protected String nameLike;
+ protected String keyLike;
+
+ public ProcessDefinitionQueryImpl(CommandService commandService) {
+ super(commandService);
+ }
+
+ public List<ProcessDefinition> execute() {
+ return (List) commandService.execute(this);
+ }
+
+ public String hql() {
+ StringBuffer hql = new StringBuffer();
+ hql.append("select pd ");
+ hql.append("from ");
+ hql.append(ProcessDefinitionImpl.class.getName());
+ hql.append(" as pd ");
+
+ if (nameLike!=null) {
+ appendWhereClause("pd.name like '"+nameLike+"'", hql);
+ }
+
+ if (keyLike!=null) {
+ appendWhereClause("pd.key like '"+keyLike+"'", hql);
+ }
+
+ appendOrderByClause(hql);
+
+ return hql.toString();
+ }
+
+ protected void applyParameters(Query query) {
+ }
+
+ public ProcessDefinitionQuery nameLike(String name) {
+ this.nameLike = name;
+ return this;
+ }
+
+ public ProcessDefinitionQuery keyLike(String key) {
+ this.keyLike = key;
+ return this;
+ }
+
+ public ProcessDefinitionQuery orderAsc(String property) {
+ addOrderByClause("pd."+property+" asc");
+ return this;
+ }
+
+ public ProcessDefinitionQuery orderDesc(String property) {
+ addOrderByClause("pd."+property+" desc");
+ return this;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.svc;
-
-import java.util.List;
-
-import org.jbpm.Execution;
-import org.jbpm.ExecutionQuery;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.HqlQueryOldCmd;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExecutionQueryImpl implements ExecutionQuery {
-
- private static final String NEWLINE = System.getProperty("line.separator");
-
- protected boolean onlyProcessInstances;
- protected String processDefinitionNameLike;
- protected String processDefinitionKeyLike;
- protected String processDefinitionId;
- protected String order;
- protected Integer firstResult;
- protected Integer maxResults;
-
- protected CommandService commandService;
-
- public ExecutionQueryImpl(CommandService commandService) {
- this.commandService = commandService;
- }
-
- protected String buildHql() {
- StringBuffer hql = new StringBuffer();
- hql.append("select e ");
- hql.append(NEWLINE);
- hql.append("from "+ExecutionImpl.class.getName()+" as e ");
- hql.append(NEWLINE);
-
- boolean where = false;
-
- if (processDefinitionId!=null) {
- where = true;
- hql.append("where e.processDefinition.id = '"+processDefinitionId+"'");
- hql.append(NEWLINE);
- }
-
- if (processDefinitionNameLike!=null) {
- where = true;
- addWhereOrAnd(hql, where);
- hql.append("e.processDefinition.name like '"+processDefinitionNameLike+"'");
- hql.append(NEWLINE);
- }
-
- if (processDefinitionKeyLike!=null) {
- where = true;
- addWhereOrAnd(hql, where);
- hql.append("e.processDefinition.key like '"+processDefinitionKeyLike+"'");
- hql.append(NEWLINE);
- }
-
- if (order!=null) {
- hql.append("order by "+order);
- }
-
- return hql.toString();
- }
-
- private void addWhereOrAnd(StringBuffer hql, boolean where) {
- if (where) {
- hql.append(" and ");
- } else {
- hql.append("where ");
- }
- }
-
- protected List<Execution> execute() {
- String hql = buildHql();
- return (List) commandService.execute(new HqlQueryOldCmd(hql, firstResult, maxResults));
- }
-
- public ExecutionQuery onlyProcessInstances() {
- this.onlyProcessInstances = true;
- return this;
- }
-
- public ExecutionQuery orderByKeyAsc() {
- order = "e.key asc";
- return this;
- }
-
- public ExecutionQuery orderByKeyDesc() {
- order = "e.key desc";
- return this;
- }
-
- public ExecutionQuery processDefinitionId(String processDefinitionId) {
- this.processDefinitionId = processDefinitionId;
- return this;
- }
-
- public ExecutionQuery processDefinitionKeyLike(String processDefinitionKey) {
- this.processDefinitionKeyLike = processDefinitionKey;
- return this;
- }
-
- public ExecutionQuery processDefinitionNameLike(String processDefinitionName) {
- this.processDefinitionNameLike = processDefinitionName;
- return this;
- }
-
- public List<Execution> list() {
- return execute();
- }
-
- public List<Execution> list(int firstResult, int maxResults) {
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- return execute();
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -39,6 +39,7 @@
import org.jbpm.pvm.internal.cmd.SignalCmd;
import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
import org.jbpm.pvm.internal.cmd.StartExecutionInLatestCmd;
+import org.jbpm.pvm.internal.query.ExecutionQueryImpl;
/**
@@ -132,9 +133,13 @@
}
public ExecutionQuery createExecutionQuery() {
- return new ExecutionQueryImpl(commandService);
+ return new ExecutionQueryImpl(commandService, false);
}
+ public ExecutionQuery createProcessInstanceQuery() {
+ return new ExecutionQueryImpl(commandService, true);
+ }
+
public void deleteProcessInstance(String processInstanceId) {
commandService.execute(new DeleteProcessInstance(processInstanceId));
}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.svc;
-
-import java.util.List;
-
-import org.jbpm.ProcessDefinition;
-import org.jbpm.ProcessDefinitionQuery;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.HqlQueryOldCmd;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessDefinitionQueryImpl implements ProcessDefinitionQuery {
-
- private static final String NEWLINE = System.getProperty("line.separator");
-
- protected String nameLike;
- protected String keyLike;
- protected String order;
- protected Integer firstResult;
- protected Integer maxResults;
-
- protected CommandService commandService;
-
- public ProcessDefinitionQueryImpl(CommandService commandService) {
- this.commandService = commandService;
- }
-
- protected String buildHql() {
- StringBuffer hql = new StringBuffer();
- hql.append("select pd ");
- hql.append(NEWLINE);
- hql.append("from "+ProcessDefinitionImpl.class.getName()+" as pd ");
- hql.append(NEWLINE);
-
- if (nameLike!=null) {
- hql.append("where pd.name like '"+nameLike+"'");
- hql.append(NEWLINE);
- }
-
- if (keyLike!=null) {
- if (nameLike==null) {
- hql.append("where ");
- } else {
- hql.append(" and ");
- hql.append(NEWLINE);
- }
- hql.append("pd.key like '"+keyLike+"'");
- hql.append(NEWLINE);
- }
-
- if (order!=null) {
- hql.append("order by "+order);
- }
-
- return hql.toString();
- }
-
- protected List<ProcessDefinition> execute() {
- String hql = buildHql();
- return (List) commandService.execute(new HqlQueryOldCmd(hql, firstResult, maxResults));
- }
-
-
- public ProcessDefinitionQuery nameLike(String name) {
- nameLike = name;
- return this;
- }
-
- public ProcessDefinitionQuery keyLike(String key) {
- keyLike = key;
- return this;
- }
-
- public ProcessDefinitionQuery orderByKeyAsc() {
- order = "pd.key asc";
- return this;
- }
-
- public ProcessDefinitionQuery orderByKeyDesc() {
- order = "pd.key desc";
- return this;
- }
-
- public ProcessDefinitionQuery orderByNameAsc() {
- order = "pd.name asc";
- return this;
- }
-
- public ProcessDefinitionQuery orderByNameDesc() {
- order = "pd.name desc";
- return this;
- }
-
- public List<ProcessDefinition> list() {
- return execute();
- }
-
- public List<ProcessDefinition> list(int firstResult, int maxResults) {
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- return execute();
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -35,6 +35,7 @@
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionByIdCmd;
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionKeysCmd;
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionsByKeyCmd;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
/** {@link ProcessService} implementation that delegates execution of the
* methods to a {@link CommandService}.
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.task.internal.cmd;
-
-import java.util.List;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.task.Task;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HqlQueryCmd implements Command<List<Task>> {
-
- public List<Task> execute(Environment environment) throws Exception {
- return null;
- }
-
-}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -24,109 +24,78 @@
import java.util.List;
import org.hibernate.Query;
-import org.hibernate.Session;
import org.jbpm.TaskQuery;
-import org.jbpm.cmd.Command;
import org.jbpm.cmd.CommandService;
-import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.query.AbstractQuery;
+import org.jbpm.pvm.internal.query.Page;
import org.jbpm.task.Task;
/**
* @author Tom Baeyens
*/
-public class TaskQueryImpl implements TaskQuery, Command<List<Task>> {
+public class TaskQueryImpl extends AbstractQuery implements TaskQuery {
private static final long serialVersionUID = 1L;
private static final String UNASSIGNED = "unassigned";
- protected CommandService commandService;
-
protected String assignee = null;
- protected int[] page = null;
- protected boolean hasWhereClause = false;
- protected String orderByClause = null;
public TaskQueryImpl(CommandService commandService) {
- this.commandService = commandService;
+ super(commandService);
}
-
+
public TaskQuery assignee(String assignee) {
this.assignee = assignee;
- this.hasWhereClause = true;
return this;
}
public TaskQuery unassigned() {
this.assignee = UNASSIGNED;
- this.hasWhereClause = true;
return this;
}
public TaskQuery orderAsc(String property) {
- addOrderByClause(property, "asc");
+ orderByClause = "task."+property+" asc ";
return this;
}
public TaskQuery orderDesc(String property) {
- addOrderByClause(property, "desc");
+ orderByClause = "task."+property+" desc ";
return this;
}
- protected void addOrderByClause(String property, String direction) {
- if (orderByClause==null) {
- orderByClause = "";
- } else {
- orderByClause += ", ";
- }
- orderByClause += "task."+property+" "+direction;
- }
-
public TaskQuery page(int firstResult, int maxResults) {
- page = new int[]{firstResult, maxResults};
+ page = new Page(firstResult, maxResults);
return this;
}
public List<Task> execute() {
- return commandService.execute(this);
+ return (List<Task>) commandService.execute(this);
}
- public List<Task> execute(Environment environment){
+ protected void applyParameters(Query query) {
+ if ( (assignee!=UNASSIGNED) && (assignee!=null) ) {
+ query.setString("assignee", assignee);
+ }
+ }
+
+ public String hql() {
StringBuffer hql = new StringBuffer();
hql.append("select task ");
hql.append("from ");
hql.append(TaskImpl.class.getName());
hql.append(" as task ");
- if (hasWhereClause) {
- hql.append("where ");
- }
-
if (assignee==UNASSIGNED) {
- hql.append("task.assignee is null ");
+ appendWhereClause("task.assignee is null ", hql);
} else if (assignee!=null) {
- hql.append("task.assignee = :assignee ");
+ appendWhereClause("task.assignee = :assignee ", hql);
}
- if (orderByClause!=null) {
- hql.append("order by ");
- hql.append(orderByClause);
- }
+ appendOrderByClause(hql);
- Session session = environment.get(Session.class);
- String hqlText = hql.toString();
- Query query = session.createQuery(hqlText);
-
- if ( (assignee!=UNASSIGNED) && (assignee!=null) ) {
- query.setString("assignee", assignee);
- }
-
- if (page!=null) {
- query.setFirstResult(page[0]);
- query.setMaxResults(page[1]);
- }
-
- return query.list();
+ return hql.toString();
}
}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -91,7 +91,7 @@
public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
return createTaskQuery()
.assignee(assignee)
- .orderDesc(TaskQuery.PRIORITY)
+ .orderDesc(TaskQuery.PROPERTY_PRIORITY)
.page(firstResult, maxResults)
.execute();
}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -174,4 +174,42 @@
return null;
}
+
+ public static Task getTask(List<Task> taskList, String taskName) {
+ for (Task task : taskList) {
+ if (taskName.equals(task.getName())) {
+ return task;
+ }
+ }
+ return null;
+ }
+
+ public static void assertContainsTask(List<Task> taskList, String taskName) {
+ if (getTask(taskList, taskName)==null) {
+ fail("tasklist doesn't contain task '"+taskName+"': "+taskList);
+ }
+ }
+
+ public static Task getTask(List<Task> taskList, String taskName, String assignee) {
+ for (Task task : taskList) {
+ if (taskName.equals(task.getName())) {
+ if (assignee==null) {
+ if (task.getAssignee()==null) {
+ return task;
+ }
+ } else {
+ if (assignee.equals(task.getAssignee())) {
+ return task;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static void assertContainsTask(List<Task> taskList, String taskName, String assignee) {
+ if (getTask(taskList, taskName, assignee)==null) {
+ fail("tasklist doesn't contain task '"+taskName+"' for assignee '"+assignee+"': "+taskList);
+ }
+ }
}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.execution;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindExecutionTest extends DbTestCase {
+
+ public void testFindExecutionById() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("p");
+
+ // take the id and see if the execution service can still find it back
+ execution = executionService.findExecution(execution.getId());
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java (from rev 3685, jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,254 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SignalExecutionTest extends DbTestCase {
+
+ public void testSignalExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ assertEquals("a", execution.getActivityName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("b", execution.getActivityName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("c", execution.getActivityName());
+ }
+
+ public void testSignalExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ assertEquals("a", execution.getActivityName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("b", execution.getActivityName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("c", execution.getActivityName());
+ }
+
+ public void testSignalExecutionWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ execution = executionService.signalExecutionById("ICL/82436", variables);
+
+ assertNotNull(execution);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getActivityName());
+
+ Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
+ Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+
+ public void testDefaultSignalWithoutTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("p");
+ execution = executionService.signalExecutionById(execution.getId());
+ assertEquals("a", execution.getActivityName());
+ }
+
+ /*
+
+ public void testSetVariable()
+ {
+ Execution execution = startExecution();
+
+ String executionId = execution.getId();
+ // set variable a to value text
+ executionService.setVariable(executionId, "a", "text");
+ // check if we can read that value back
+ assertEquals("text", executionService.getVariable(executionId, "a"));
+
+ // overwrite the value of variable a with another text
+ executionService.setVariable(executionId, "a", "another text");
+ // see if we can read another text back from the variable
+ assertEquals("another text", executionService.getVariable(executionId, "a"));
+ }
+
+ public void testSetVariables()
+ {
+ Execution execution = startExecution();
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // set variables in bulk by providing a map
+ executionService.setVariables(execution.getId(), variables);
+
+ Map<String, Object> expected = new HashMap<String, Object>(variables);
+
+ Set<String> variableNames = new HashSet<String>();
+ variableNames.add("a");
+ variableNames.add("b");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+
+ // now set variables b and c with a map
+ variables = new HashMap<String, Object>();
+ variables.put("b", new Integer(99));
+ variables.put("c", "another text");
+
+ // this should leave a untouched, overwrite b and create c
+ executionService.setVariables(execution.getId(), variables);
+
+ // update the expected map
+ expected.put("b", new Integer(99));
+ expected.put("c", "another text");
+
+ // add c to the variable names that should be collected
+ variableNames.add("c");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ void deployMultipleVersionsOfProcesses()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(
+ WaitState.class).done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("publish book").key("PBO").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+ }
+
+ Execution startExecution()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").activity("initial").initial().behaviour(WaitState.class)
+ .done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ return executionService.startExecutionByName("nuclear fusion");
+ }
+
+ */
+}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartExecutionTest extends DbTestCase {
+
+ public void testStartNewExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+ }
+
+ public void testStartNewExecutionInLatestProcessDefinition() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("b", execution.getActivityName());
+ }
+
+ public void testStartExecutionInLatestByNameWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ // create variables that are fed into the process before it starts executing
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // feed the variables in
+ Execution execution = executionService.startExecutionByKey("ICL", variables);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getActivityName());
+
+ // verify that the variables are actually set
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue(execution.getId().startsWith("ICL/"));
+ }
+
+ public void testStartNewProcessInstanceWithAKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "one");
+
+ assertNotNull(execution);
+ assertEquals("ICL/one", execution.getId());
+ }
+
+ public void testStartNewProcessInstanceWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ Execution execution = executionService.startExecutionByKey("ICL", variables);
+
+ String executionId = execution.getId();
+
+ assertNotNull(execution);
+
+ Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
+ Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+ public void testStartExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findProcessDefinitionsByKey("ICL").get(0);
+
+ // start an execution for the process with the given id
+ Execution execution = executionService.startExecutionById("ICL:1");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("a", execution.getActivityName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertNull(execution.getKey());
+ // if there is no user defined name or key specified in the execution,
+ // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
+ assertTrue(execution.getId().startsWith("ICL/"));
+ // the last part of the execution key should be the dbid.
+ Long.parseLong(execution.getId().substring(4));
+ }
+
+ public void testStartExecutionByIdWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ // create the map with variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // provide the variables in the start execution method
+ Execution execution = executionService.startExecutionById("ICL:1", variables);
+ String executionId = execution.getId();
+
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java (from rev 3641, jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/mgmt/ManagementServiceTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.mgmt;
+
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceTest extends DbTestCase {
+
+ public void testGetJobs() {
+ assertEquals(0, managementService.getTimers(0, 10).size());
+ assertEquals(0, managementService.getMessages(0, 10).size());
+ }
+
+}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.process;
+
+import java.util.List;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryTest extends DbTestCase {
+
+ public void testQueryProcessDefinitionsEmpty() {
+ List<ProcessDefinition> processDefinitions = processService
+ .createProcessDefinitionQuery()
+ .execute();
+
+ assertEquals(0, processDefinitions.size());
+ }
+
+ public void testQueryProcessDefinitionsNameLike() {
+ deployJpdlXmlString(
+ "<process name='make print'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='use phone'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='clean whiteboard'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='fix coffeemaker'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ List<ProcessDefinition> processDefinitions = processService.createProcessDefinitionQuery()
+ .nameLike("%make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .execute();
+
+ assertEquals("fix coffeemaker", processDefinitions.get(0).getName());
+ assertEquals("make friends", processDefinitions.get(1).getName());
+ assertEquals("make print", processDefinitions.get(2).getName());
+ }
+
+ public void testQueryProcessDefinitionsKeyLike() {
+ deployJpdlXmlString(
+ "<process name='make print'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='use phone'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='clean whiteboard'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='fix coffeemaker'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ List<ProcessDefinition> processDefinitions = processService.createProcessDefinitionQuery()
+ .keyLike("make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .execute();
+
+ assertEquals("make_friends:3", processDefinitions.get(0).getId());
+ assertEquals("make_friends:2", processDefinitions.get(1).getId());
+ assertEquals("make_friends:1", processDefinitions.get(2).getId());
+ assertEquals("make_print:1", processDefinitions.get(3).getId());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java (from rev 3682, jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,356 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.process;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessServiceTest extends DbTestCase {
+
+ public void testProcessWithNameOnly() {
+ ProcessDefinition processDefinition = deployJpdlXmlString(
+ "<process name='Insurance claim'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("Insurance_claim", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Insurance_claim:1", processDefinition.getId());
+ }
+
+ public void testProcessWithNameAndKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("ICL", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("ICL:1", processDefinition.getId());
+ }
+
+ // interface methods ////////////////////////////////////////////////////////
+
+ public void testFindProcessDefinitionKeys() {
+ deployMultipleVersionsOfProcesses();
+
+ List<String> processKeys = processService.findProcessDefinitionKeys();
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("nuclear_fusion");
+ expected.add("publish_book");
+ expected.add("ultimate_seduction");
+
+ assertEquals(expected, processKeys);
+ }
+
+
+ public void testFindProcessByKey() {
+ deployJpdlXmlString(
+ "<process name='Name with spaces'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
+ assertNotNull(processDefinition);
+ assertEquals("Name with spaces", processDefinition.getName());
+ assertEquals("Name_with_spaces", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Name_with_spaces:1", processDefinition.getId());
+ }
+
+ public void testFindProcessDefinitions() {
+ deployMultipleVersionsOfProcesses();
+
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
+ assertNotNull(processDefinitions);
+
+ assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
+ assertEquals("nuclear fusion", processDefinitions.get(0).getName());
+ assertEquals(3, processDefinitions.get(0).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(1).getName());
+ assertEquals(2, processDefinitions.get(1).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(2).getName());
+ assertEquals(1, processDefinitions.get(2).getVersion());
+ }
+
+ public void testFindLatestProcessDefinition() {
+ deployMultipleVersionsOfProcesses();
+
+ ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
+ assertNotNull(retrieved);
+
+ assertEquals(3, retrieved.getVersion());
+ assertEquals("nuclear fusion", retrieved.getName());
+ assertEquals("nuclear_fusion", retrieved.getKey());
+ }
+
+ public void testFindProcessDefinitionById() {
+ deployJpdlXmlString(
+ "<process name='given' version='33'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ ProcessDefinition processDefinition = processService.findProcessDefinitionById("given:33");
+ assertNotNull(processDefinition);
+ assertEquals("given", processDefinition.getName());
+ assertEquals(33, processDefinition.getVersion());
+ }
+
+ public void testDeleteProcessDefinition() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start />" +
+ "</process>")
+ .deploy();
+
+ // delete it
+ processService.deleteProcessDefinition("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
+ }
+
+ public void testDeleteProcessDefinitionAndInstances() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>")
+ .deploy();
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ processService.deleteProcessDefinitionAndInstances("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
+ assertEquals(0, executionService.createExecutionQuery().execute().size());
+ }
+
+ public void testDeleteProcessDefinitionButNotInstances() {
+ deployJpdlXmlString(
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ try {
+ processService.deleteProcessDefinition("deleteme:33");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("still 4 process instances for process definition deleteme:33", e.getMessage());
+ }
+ }
+
+ // various other aspects ////////////////////////////////////////////////////
+
+ public void testAutomaticVersioning() {
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look it up again
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+ assertNotNull(processDefinitions);
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // and check that automatically assigned version starts with 1
+ assertEquals(1, processDefinition.getVersion());
+
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look them up again
+ processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
+ // and check that automatically assigned version starts with 1
+ assertEquals(2, processDefinitions.get(0).getVersion());
+ assertEquals(1, processDefinitions.get(1).getVersion());
+ }
+
+ public void testUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
+ assertNotNull(processDefinitions);
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // verify that the user specified version was used
+ // (and not overwritten by an automatically assigned versioning)
+ assertEquals(234, processDefinition.getVersion());
+ }
+
+ public void testDuplicateUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ try {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("process 'takethis:234' already exists", e.getMessage());
+ }
+ }
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ */
+ void deployMultipleVersionsOfProcesses() {
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='publish book'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+ }
+
+ public void testMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start>" +
+ " <flow to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertEquals("end", execution.getActivityName());
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+
+ public void testMostMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java (from rev 3701, jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.Date;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskCreateUpdateDeleteTest extends DbTestCase {
+
+ public void testNewTask() {
+ // creation of a new non-persisted task
+ Task task = taskService.newTask();
+ task = taskService.getTask(task.getId());
+ assertNull(task);
+ }
+
+ public void testGenerateTaskId() {
+ Task task = taskService.newTask();
+ String taskId = task.getId();
+ assertNull("expected null, but was " + taskId, taskId);
+ // save task to generate identifier
+ saveTask(task);
+ assertNotNull(task.getId());
+ }
+
+ public void testSaveTask() {
+ Task task = taskService.newTask();
+ saveTask(task);
+ String taskId = task.getId();
+ // task was made persistent
+ task = taskService.getTask(taskId);
+ assertNotNull("expected non-null task", task);
+ // make some change
+ Date dueDate = new Date();
+ task.setDueDate(dueDate);
+ taskService.saveTask(task);
+ // verify change is applied
+ task = taskService.getTask(taskId);
+ assertEquals(dueDate, task.getDueDate());
+ }
+
+ public void testDeleteTask() {
+ Task task = taskService.newTask();
+ taskService.saveTask(task);
+ String taskId = task.getId();
+
+ // task was made persistent
+ assertNotNull("expected non-null task", taskService.getTask(taskId));
+ // delete task and verify it does not exist
+ taskService.deleteTask(taskId);
+ task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ }
+}
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -23,7 +23,6 @@
import java.util.List;
-import org.jbpm.TaskQuery;
import org.jbpm.task.Task;
import org.jbpm.test.DbTestCase;
@@ -104,6 +103,7 @@
List<Task> taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
assertNotNull(taskList);
+ // default sort order is based on the priority
assertEquals("make profit", taskList.get(0).getName());
assertEquals("get good idea", taskList.get(1).getName());
assertEquals("find venture capital", taskList.get(2).getName());
@@ -112,88 +112,4 @@
assertEquals(5, taskList.size());
}
-
- public void testSimplestTaskQuery() {
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- task.setPriority(3);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("change dyper");
- task.setAssignee("johndoe");
- task.setPriority(1);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("start new business");
- task.setAssignee("joesmoe");
- task.setPriority(4);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("find venture capital");
- task.setPriority(4);
- saveTask(task);
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .execute();
- assertNotNull(taskList);
-
- assertContainsTask(taskList, "do laundry");
- assertContainsTask(taskList, "change dyper");
- assertContainsTask(taskList, "start new business");
- assertContainsTask(taskList, "find venture capital");
-
- assertEquals(4, taskList.size());
- }
-
- public void testSimplestTaskQuerySortBy() {
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- task.setPriority(3);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("change dyper");
- task.setAssignee("johndoe");
- task.setPriority(1);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("start new business");
- task.setAssignee("joesmoe");
- task.setPriority(4);
- saveTask(task);
-
- task = taskService.newTask();
- task.setName("find venture capital");
- task.setPriority(7);
- saveTask(task);
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .orderAsc(TaskQuery.NAME)
- .execute();
- assertNotNull(taskList);
-
- assertEquals("change dyper", taskList.get(0).getName());
- assertEquals("do laundry", taskList.get(1).getName());
- assertEquals("find venture capital", taskList.get(2).getName());
- assertEquals("start new business", taskList.get(3).getName());
-
- assertEquals(4, taskList.size());
- }
-
- public void assertContainsTask(List<Task> taskList, String taskName) {
- for (Task task : taskList) {
- if (taskName.equals(task.getName())) {
- return;
- }
- }
- fail("tasklist doesn't contain task '"+taskName+"': "+taskList);
- }
}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.List;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryTest extends DbTestCase {
+
+ public void testSimplestTaskQuery() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ task.setPriority(3);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ task.setPriority(1);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(4);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setPriority(4);
+ saveTask(task);
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .execute();
+ assertNotNull(taskList);
+
+ assertContainsTask(taskList, "do laundry");
+ assertContainsTask(taskList, "change dyper");
+ assertContainsTask(taskList, "start new business");
+ assertContainsTask(taskList, "find venture capital");
+
+ assertEquals(4, taskList.size());
+ }
+
+ public void testSimplestTaskQuerySortBy() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ task.setPriority(3);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ task.setPriority(1);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(4);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setPriority(7);
+ saveTask(task);
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .orderAsc(TaskQuery.PROPERTY_NAME)
+ .execute();
+ assertNotNull(taskList);
+
+ assertEquals("change dyper", taskList.get(0).getName());
+ assertEquals("do laundry", taskList.get(1).getName());
+ assertEquals("find venture capital", taskList.get(2).getName());
+ assertEquals("start new business", taskList.get(3).getName());
+
+ assertEquals(4, taskList.size());
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java 2009-01-23 17:02:45 UTC (rev 3718)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.task;
-
-import java.util.Date;
-
-import org.jbpm.task.Task;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskServiceTest extends DbTestCase {
-
- public void testNewTask() {
- // creation of a new non-persisted task
- Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
- assertNull(task);
- }
-
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveTask(task);
- assertNotNull(task.getId());
- }
-
- public void testSaveTask() {
- Task task = taskService.newTask();
- saveTask(task);
- String taskId = task.getId();
- // task was made persistent
- task = taskService.getTask(taskId);
- assertNotNull("expected non-null task", task);
- // make some change
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- taskService.saveTask(task);
- // verify change is applied
- task = taskService.getTask(taskId);
- assertEquals(dueDate, task.getDueDate());
- }
-
- public void testDeleteTask() {
- Task task = taskService.newTask();
- taskService.saveTask(task);
- String taskId = task.getId();
-
- // task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
- // delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- }
-}
Modified: jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2009-01-23 13:44:13 UTC (rev 3717)
+++ jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2009-01-23 17:02:45 UTC (rev 3718)
@@ -22,7 +22,7 @@
org.hibernate.level=INFO
org.hibernate.cfg.HbmBinder.level=SEVERE
org.hibernate.cfg.SettingsFactory.level=SEVERE
-# org.hibernate.SQL.level=FINEST
-# org.hibernate.type.level=FINEST
+org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST
# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
# org.hibernate.transaction.level=FINEST
15 years, 3 months