JBoss JBPM SVN: r3707 - jbpm3/trunk/modules/identity/src/test/resources.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-23 02:14:34 -0500 (Fri, 23 Jan 2009)
New Revision: 3707
Removed:
jbpm3/trunk/modules/identity/src/test/resources/ehcache.xml
Log:
remove unused ehcache configuration file
Deleted: jbpm3/trunk/modules/identity/src/test/resources/ehcache.xml
===================================================================
--- jbpm3/trunk/modules/identity/src/test/resources/ehcache.xml 2009-01-23 07:13:54 UTC (rev 3706)
+++ jbpm3/trunk/modules/identity/src/test/resources/ehcache.xml 2009-01-23 07:14:34 UTC (rev 3707)
@@ -1,48 +0,0 @@
-<ehcache>
- <!-- Sets the path to the directory where cache .data files are created.
-
- If the path is a Java System Property it is replaced by
- its value in the running VM.
-
- The following properties are translated:
- user.home - User's home directory
- user.dir - User's current working directory
- java.io.tmpdir - Default temp file path
- <diskStore path="java.io.tmpdir"/> -->
-
- <!--Default Cache configuration. These will applied to caches programmatically created through
- the CacheManager.
-
- The following attributes are required:
-
- maxElementsInMemory - Sets the maximum number of objects that will be created in memory
- eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the
- element is never expired.
- overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
- has reached the maxInMemory limit.
-
- The following attributes are optional:
- timeToIdleSeconds - Sets the time to idle for an element before it expires.
- i.e. The maximum amount of time between accesses before an element expires
- Is only used if the element is not eternal.
- Optional attribute. A value of 0 means that an Element can idle for infinity.
- The default value is 0.
- timeToLiveSeconds - Sets the time to live for an element before it expires.
- i.e. The maximum time between creation time and when an element expires.
- Is only used if the element is not eternal.
- Optional attribute. A value of 0 means that and Element can live for infinity.
- The default value is 0.
- diskPersistent - Whether the disk store persists between restarts of the Virtual Machine.
- The default value is false.
- diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
- is 120 seconds.
- -->
-
- <defaultCache
- maxElementsInMemory="100000"
- eternal="true"
- overflowToDisk="false"
- diskPersistent="false"
- />
-
-</ehcache>
\ No newline at end of file
15 years, 3 months
JBoss JBPM SVN: r3706 - in jbpm3/trunk/modules/enterprise/src/test: resources and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-23 02:13:54 -0500 (Fri, 23 Jan 2009)
New Revision: 3706
Modified:
jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
jbpm3/trunk/modules/enterprise/src/test/resources/log4j.xml
Log:
increase time differences in testScheduleFork to decrease deadlock occurrences
reuse existing commands and employ unambiguous names for definition and instance
Modified: jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java 2009-01-23 07:10:21 UTC (rev 3705)
+++ jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java 2009-01-23 07:13:54 UTC (rev 3706)
@@ -37,6 +37,8 @@
import org.jboss.bpm.api.test.IntegrationTestSetup;
import org.jbpm.command.Command;
import org.jbpm.command.DeployProcessCommand;
+import org.jbpm.command.GetProcessInstanceCommand;
+import org.jbpm.command.SignalCommand;
import org.jbpm.command.StartProcessInstanceCommand;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
@@ -54,7 +56,6 @@
public class EjbSchedulerTest extends ServletTestCase {
private LocalCommandService commandService;
-
private static LocalCommandServiceHome commandServiceHome;
private static final Log log = LogFactory.getLog(EjbSchedulerTest.class);
@@ -67,8 +68,7 @@
if (commandServiceHome == null) {
Context initialContext = new InitialContext();
try {
- commandServiceHome = (LocalCommandServiceHome) initialContext
- .lookup("java:comp/env/ejb/CommandServiceBean");
+ commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/CommandServiceBean");
}
finally {
initialContext.close();
@@ -84,7 +84,7 @@
}
public void testScheduleFuture() throws Exception {
- deployProcess("<process-definition name='future'>"
+ deployProcessDefinition("<process-definition name='future'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -97,13 +97,13 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("future").getId();
+ long processInstanceId = startProcessInstance("future").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue(hasProcessInstanceEnded(processInstanceId));
}
public void testSchedulePast() throws Exception {
- deployProcess("<process-definition name='past'>"
+ deployProcessDefinition("<process-definition name='past'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -116,13 +116,13 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("past").getId();
+ long processInstanceId = startProcessInstance("past").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue(hasProcessInstanceEnded(processInstanceId));
}
public void testScheduleRepeat() throws Exception {
- deployProcess("<process-definition name='repeat'>"
+ deployProcessDefinition("<process-definition name='repeat'>"
+ " <event type='timer'>"
+ " <action expression='#{eventCallback.timer}'/>"
+ " </event>"
@@ -135,17 +135,18 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("repeat").getId();
+ ProcessInstance processInstance = startProcessInstance("repeat");
+ long processInstanceId = processInstance.getId();
for (int i = 0; i < 3; i++) {
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals("a", getProcessState(processId));
+ assertEquals("a", getProcessInstanceState(processInstanceId));
}
- signalProcess(processId);
- assertTrue(isProcessFinished(processId));
+ signalToken(processInstance.getRootToken().getId());
+ assertTrue(hasProcessInstanceEnded(processInstanceId));
}
public void testCancel() throws Exception {
- deployProcess("<process-definition name='cancel'>"
+ deployProcessDefinition("<process-definition name='cancel'>"
+ " <event type='timer'>"
+ " <action expression='#{eventCallback.timer}'/>"
+ " </event>"
@@ -158,23 +159,26 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- ProcessInstance process = launchProcess("cancel");
- long processId = process.getId();
+ ProcessInstance processInstance = startProcessInstance("cancel");
+ long processInstanceId = processInstance.getId();
// first expiration
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals("a", getProcessState(processId));
+ assertEquals("a", getProcessInstanceState(processInstanceId));
// repeated expiration
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals("a", getProcessState(processId));
+ assertEquals("a", getProcessInstanceState(processInstanceId));
+ // cancel timer
+ long rootTokenId = processInstance.getRootToken().getId();
+ cancelTimer("a", rootTokenId);
// no more expirations
- cancelTimer("a", process.getRootToken().getId());
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 2000);
- signalProcess(processId);
- assertTrue(isProcessFinished(processId));
+
+ signalToken(rootTokenId);
+ assertTrue(hasProcessInstanceEnded(processInstanceId));
}
public void testScheduleSequence() throws Exception {
- deployProcess("<process-definition name='sequence'>"
+ deployProcessDefinition("<process-definition name='sequence'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -206,17 +210,17 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("sequence").getId();
+ long processInstanceId = startProcessInstance("sequence").getId();
for (char state = 'b'; state <= 'e'; state++) {
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals(Character.toString(state), getProcessState(processId));
+ assertEquals(Character.toString(state), getProcessInstanceState(processInstanceId));
}
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue(hasProcessInstanceEnded(processInstanceId));
}
public void testScheduleFork() throws Exception {
- deployProcess("<process-definition name='fork'>"
+ deployProcessDefinition("<process-definition name='fork'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -231,76 +235,64 @@
+ " <transition name='e' to='e' />"
+ " </fork>"
+ " <state name='a'>"
- + " <timer duedate='0.25 seconds' transition='timeout' />"
+ + " <timer duedate='0.5 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='b'>"
- + " <timer duedate='0.5 seconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='c'>"
- + " <timer duedate='0.75 seconds' transition='timeout' />"
+ + " <timer duedate='1.5 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='d'>"
- + " <timer duedate='1 second' transition='timeout' />"
+ + " <timer duedate='2 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='e'>"
- + " <timer duedate='1.25 second' transition='timeout' />"
+ + " <timer duedate='2.5 second' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
- + " <join name='j' async='exclusive'>"
+ + " <join name='j' async='exclusive' lock='UPGRADE'>"
+ " <transition to='end' />"
+ " </join>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("fork").getId();
+ long processInstanceId = startProcessInstance("fork").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue(hasProcessInstanceEnded(processInstanceId));
}
- private ProcessDefinition deployProcess(String xml) throws RemoteException {
+ private ProcessDefinition deployProcessDefinition(String xml) throws RemoteException {
return (ProcessDefinition) commandService.execute(new DeployProcessCommand(xml));
}
- private ProcessInstance launchProcess(String processName) throws RemoteException {
+ private ProcessInstance startProcessInstance(String processName) throws RemoteException {
StartProcessInstanceCommand command = new StartProcessInstanceCommand();
command.setProcessDefinitionName(processName);
command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
return (ProcessInstance) commandService.execute(command);
}
- private void signalProcess(final long processId) throws RemoteException {
- commandService.execute(new Command() {
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- jbpmContext.loadProcessInstanceForUpdate(processId).signal();
- return null;
- }
- });
+ private void signalToken(long tokenId) {
+ commandService.execute(new SignalCommand(tokenId, null));
}
- private String getProcessState(final long processId) throws RemoteException {
+ private String getProcessInstanceState(final long processInstanceId) throws RemoteException {
return (String) commandService.execute(new Command() {
private static final long serialVersionUID = 1L;
public Object execute(JbpmContext jbpmContext) throws Exception {
- return jbpmContext.loadProcessInstance(processId).getRootToken().getNode().getName();
+ return jbpmContext.loadProcessInstance(processInstanceId).getRootToken().getNode().getName();
}
});
}
- private boolean isProcessFinished(final long processId) throws RemoteException {
- Boolean isFinished = (Boolean) commandService.execute(new Command() {
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- return jbpmContext.loadProcessInstance(processId).hasEnded();
- }
- });
- return isFinished.booleanValue();
+ private boolean hasProcessInstanceEnded(final long processInstanceId) throws RemoteException {
+ ProcessInstance processInstance = (ProcessInstance) commandService.execute(new GetProcessInstanceCommand(
+ processInstanceId));
+ return processInstance.hasEnded();
}
private void cancelTimer(final String timerName, final long tokenId) throws RemoteException {
Modified: jbpm3/trunk/modules/enterprise/src/test/resources/log4j.xml
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/resources/log4j.xml 2009-01-23 07:10:21 UTC (rev 3705)
+++ jbpm3/trunk/modules/enterprise/src/test/resources/log4j.xml 2009-01-23 07:13:54 UTC (rev 3706)
@@ -32,10 +32,6 @@
<!-- Limit categories -->
<!-- ================ -->
- <category name="org.jbpm">
- <priority value="DEBUG" />
- </category>
-
<category name="org.hibernate">
<priority value="INFO" />
</category>
@@ -62,6 +58,11 @@
</category>
-->
+ <!-- hide httpclient wire dumps -->
+ <category name="httpclient.wire.header">
+ <priority value="INFO" />
+ </category>
+
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
15 years, 3 months
JBoss JBPM SVN: r3705 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/db and 6 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-23 02:10:21 -0500 (Fri, 23 Jan 2009)
New Revision: 3705
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
jbpm3/trunk/modules/core/src/test/resources/log4j.xml
Log:
JBPM-1812 remove hbm2ddl.auto property, set to 'create' in hsqldb only
support for custom table creation
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -42,7 +42,7 @@
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(EventCallback.class);
- private static Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
+ private static final Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
public void processStart() {
registerNotification(Event.EVENTTYPE_PROCESS_START);
@@ -92,8 +92,10 @@
Semaphore eventSemaphore = getEventSemaphore(event);
eventSemaphore.release();
}
+ else {
+ log.warn("not sending '" + event + "' notification, transaction is " + statusToString(status));
+ }
}
-
};
JbpmContext.getCurrentJbpmContext()
.getSession()
@@ -101,6 +103,44 @@
.registerSynchronization(notification);
}
+ private static String statusToString(int status) {
+ String text;
+ switch (status) {
+ case Status.STATUS_ACTIVE:
+ text = "active";
+ break;
+ case Status.STATUS_COMMITTED:
+ text = "committed";
+ break;
+ case Status.STATUS_COMMITTING:
+ text = "committing";
+ break;
+ case Status.STATUS_MARKED_ROLLBACK:
+ text = "marked for rollback";
+ break;
+ case Status.STATUS_NO_TRANSACTION:
+ text = "absent";
+ break;
+ case Status.STATUS_PREPARED:
+ text = "prepared";
+ break;
+ case Status.STATUS_PREPARING:
+ text = "preparing";
+ break;
+ case Status.STATUS_ROLLEDBACK:
+ text = "rolled back";
+ break;
+ case Status.STATUS_ROLLING_BACK:
+ text = "rolling back";
+ break;
+ case Status.STATUS_UNKNOWN:
+ default:
+ text = "in unknown status";
+ break;
+ }
+ return text;
+ }
+
public static void waitForEvent(String event) {
waitForEvent(event, DEFAULT_TIMEOUT);
}
@@ -134,11 +174,14 @@
}
public static void clear() {
- for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
- int permits = entry.getValue().drainPermits();
- if (permits != 0) {
- log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
+ synchronized (eventSemaphores) {
+ for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
+ int permits = entry.getValue().drainPermits();
+ if (permits != 0) {
+ log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
+ }
}
+ eventSemaphores.clear();
}
}
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -249,8 +249,7 @@
* </tr>
* </table>
*/
-public class JbpmConfiguration implements Serializable
-{
+public class JbpmConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
@@ -269,54 +268,47 @@
}
}
- public JbpmConfiguration(ObjectFactory objectFactory)
- {
+ public JbpmConfiguration(ObjectFactory objectFactory) {
this.objectFactory = objectFactory;
}
- public static JbpmConfiguration getInstance()
- {
+ public static JbpmConfiguration getInstance() {
return getInstance(null);
}
- public static JbpmConfiguration getInstance(String resource)
- {
- if (resource == null)
- {
+ public static JbpmConfiguration getInstance(String resource) {
+ if (resource == null) {
resource = "jbpm.cfg.xml";
}
JbpmConfiguration instance = null;
- synchronized (instances)
- {
+ synchronized (instances) {
instance = instances.get(resource);
- if (instance == null)
- {
- if (defaultObjectFactory != null)
- {
- log.debug("creating jbpm configuration from given default object factory '" + defaultObjectFactory + "'");
+ if (instance == null) {
+ if (defaultObjectFactory != null) {
+ log.debug("creating jbpm configuration from given default object factory '"
+ + defaultObjectFactory
+ + "'");
instance = new JbpmConfiguration(defaultObjectFactory);
}
- else
- {
- try
- {
+ else {
+ try {
log.info("using jbpm configuration resource '" + resource + "'");
InputStream jbpmCfgXmlStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
/*
- * if a custom resource is specified, but not found in the classpath log a warning
+ * if a custom resource is specified, but not found in the classpath, log a warning
* (otherwise, users who want to load custom stuff will be confused if the resource is
* not found and not loaded, without any notice)
*/
- if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource))
- {
+ if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource)) {
log.warn("jbpm configuration resource '" + resource + "' is not available");
}
ObjectFactory objectFactory = parseObjectFactory(jbpmCfgXmlStream);
instance = createJbpmConfiguration(objectFactory);
}
- catch (RuntimeException e)
- {
- throw new JbpmException("couldn't parse jbpm configuration from resource '" + resource + "'", e);
+ catch (RuntimeException e) {
+ throw new JbpmException("couldn't parse jbpm configuration from resource '"
+ + resource
+ + "'", e);
}
}
instances.put(resource, instance);
@@ -325,29 +317,24 @@
return instance;
}
- public static boolean hasInstance(String resource)
- {
+ public static boolean hasInstance(String resource) {
boolean hasInstance = false;
- if (resource == null)
- {
+ if (resource == null) {
resource = "jbpm.cfg.xml";
}
- if ((instances != null) && (instances.containsKey(resource)))
- {
+ if ((instances != null) && (instances.containsKey(resource))) {
hasInstance = true;
}
return hasInstance;
}
- protected static ObjectFactory parseObjectFactory(InputStream inputStream)
- {
+ protected static ObjectFactory parseObjectFactory(InputStream inputStream) {
log.debug("loading defaults in jbpm configuration");
ObjectFactoryParser objectFactoryParser = new ObjectFactoryParser();
ObjectFactoryImpl objectFactoryImpl = new ObjectFactoryImpl();
objectFactoryParser.parseElementsFromResource("org/jbpm/default.jbpm.cfg.xml", objectFactoryImpl);
- if (inputStream != null)
- {
+ if (inputStream != null) {
log.debug("loading specific configuration...");
objectFactoryParser.parseElementsStream(inputStream, objectFactoryImpl);
}
@@ -358,31 +345,26 @@
/**
* create an ObjectFacotory from an XML string.
*/
- public static JbpmConfiguration parseXmlString(String xml)
- {
+ public static JbpmConfiguration parseXmlString(String xml) {
log.debug("creating jbpm configuration from xml string");
InputStream inputStream = null;
- if (xml != null)
- {
+ if (xml != null) {
inputStream = new ByteArrayInputStream(xml.getBytes());
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory)
- {
+ protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory) {
JbpmConfiguration jbpmConfiguration = new JbpmConfiguration(objectFactory);
- // now we make the bean jbpm.configuration always availble
- if (objectFactory instanceof ObjectFactoryImpl)
- {
+ // make the bean jbpm.configuration always available
+ if (objectFactory instanceof ObjectFactoryImpl) {
ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl) objectFactory;
ObjectInfo jbpmConfigurationInfo = new ValueInfo("jbpmConfiguration", jbpmConfiguration);
objectFactoryImpl.addObjectInfo(jbpmConfigurationInfo);
- if (getHideStaleObjectExceptions(objectFactory))
- {
+ if (getHideStaleObjectExceptions(objectFactory)) {
StaleObjectLogConfigurer.hideStaleObjectExceptions();
}
}
@@ -390,77 +372,63 @@
return jbpmConfiguration;
}
- private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory)
- {
- if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions"))
- {
+ private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory) {
+ if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions")) {
return true;
}
Object object = objectFactory.createObject("jbpm.hide.stale.object.exceptions");
return object instanceof Boolean ? ((Boolean) object).booleanValue() : true;
}
- public static JbpmConfiguration parseInputStream(InputStream inputStream)
- {
+ public static JbpmConfiguration parseInputStream(InputStream inputStream) {
ObjectFactory objectFactory = parseObjectFactory(inputStream);
log.debug("creating jbpm configuration from input stream");
return createJbpmConfiguration(objectFactory);
}
- public static JbpmConfiguration parseResource(String resource)
- {
+ public static JbpmConfiguration parseResource(String resource) {
InputStream inputStream = null;
log.debug("creating jbpm configuration from resource '" + resource + "'");
- if (resource != null)
- {
+ if (resource != null) {
inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- public JbpmContext createJbpmContext()
- {
+ public JbpmContext createJbpmContext() {
return createJbpmContext(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public JbpmContext createJbpmContext(String name)
- {
+ public JbpmContext createJbpmContext(String name) {
JbpmContext jbpmContext = (JbpmContext) objectFactory.createObject(name);
jbpmContext.jbpmConfiguration = this;
jbpmContextCreated(jbpmContext);
return jbpmContext;
}
- public ServiceFactory getServiceFactory(String serviceName)
- {
+ public ServiceFactory getServiceFactory(String serviceName) {
return getServiceFactory(serviceName, JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName)
- {
+ public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName) {
ServiceFactory serviceFactory = null;
JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
+ try {
serviceFactory = jbpmContext.getServices().getServiceFactory(serviceName);
}
- finally
- {
+ finally {
jbpmContext.close();
}
return serviceFactory;
}
- public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition)
- {
+ public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
ProcessClassLoaderFactory factory = null;
- if (Configs.hasObject("jbpm.processClassLoader"))
- {
+ if (Configs.hasObject("jbpm.processClassLoader")) {
factory = (ProcessClassLoaderFactory) Configs.getObject("jbpm.processClassLoader");
}
- else
- {
+ else {
factory = new DefaultProcessClassLoaderFactory();
}
return factory.getProcessClassLoader(processDefinition);
@@ -469,158 +437,104 @@
/**
* gives the jbpm domain model access to configuration information via the current JbpmContext.
*/
- public static class Configs
- {
+ public static class Configs {
- private Configs()
- {
+ private Configs() {
// hide default constructor to prevent instantiation
}
- public static ObjectFactory getObjectFactory()
- {
+ public static ObjectFactory getObjectFactory() {
ObjectFactory objectFactory = null;
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null)
- {
+ if (jbpmContext != null) {
objectFactory = jbpmContext.objectFactory;
}
- else
- {
+ else {
objectFactory = getInstance().objectFactory;
}
return objectFactory;
}
- public static void setDefaultObjectFactory(ObjectFactory objectFactory)
- {
+ public static void setDefaultObjectFactory(ObjectFactory objectFactory) {
defaultObjectFactory = objectFactory;
}
- public static boolean hasObject(String name)
- {
+ public static boolean hasObject(String name) {
ObjectFactory objectFactory = getObjectFactory();
return objectFactory.hasObject(name);
}
- public static synchronized Object getObject(String name)
- {
+ public static synchronized Object getObject(String name) {
ObjectFactory objectFactory = getObjectFactory();
return objectFactory.createObject(name);
}
- public static String getString(String name)
- {
+ public static String getString(String name) {
return (String) getObject(name);
}
- public static long getLong(String name)
- {
+ public static long getLong(String name) {
return ((Long) getObject(name)).longValue();
}
- public static int getInt(String name)
- {
+ public static int getInt(String name) {
return ((Integer) getObject(name)).intValue();
}
- public static boolean getBoolean(String name)
- {
+ public static boolean getBoolean(String name) {
return ((Boolean) getObject(name)).booleanValue();
}
}
- public void cleanSchema()
- {
+ public void cleanSchema() {
cleanSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void cleanSchema(String jbpmContextName)
- {
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- Services services = jbpmContext.getServices();
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services
- .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.cleanSchema();
- }
- finally
- {
- jbpmContext.close();
- }
+ public void cleanSchema(String jbpmContextName) {
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
+ persistenceServiceFactory.cleanSchema();
}
- public void createSchema()
- {
+ public void createSchema() {
createSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void createSchema(String jbpmContextName)
- {
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- Services services = jbpmContext.getServices();
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services
- .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.createSchema();
- }
- finally
- {
- jbpmContext.close();
- }
+ public void createSchema(String jbpmContextName) {
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
+ persistenceServiceFactory.createSchema();
}
- public void dropSchema()
- {
+ public void dropSchema() {
dropSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void dropSchema(String jbpmContextName)
- {
- log.warn("Dropping schema: " + jbpmContextName);
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- Services services = jbpmContext.getServices();
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) services
- .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.dropSchema();
- }
- finally
- {
- jbpmContext.close();
- }
+ public void dropSchema(String jbpmContextName) {
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
+ persistenceServiceFactory.dropSchema();
}
- public void close()
- {
+ public void close() {
close(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void close(String jbpmContextName)
- {
+ public void close(String jbpmContextName) {
// stop job executor
- if (jobExecutor != null)
- {
+ if (jobExecutor != null) {
jobExecutor.stop();
}
JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
+ try {
// close service factories
- Map<String, ServiceFactory> serviceFactories = jbpmContext.getServices().getServiceFactories();
- if (serviceFactories != null)
- {
+ Map<String, ServiceFactory> serviceFactories = jbpmContext.getServices()
+ .getServiceFactories();
+ if (serviceFactories != null) {
for (ServiceFactory serviceFactory : serviceFactories.values()) {
serviceFactory.close();
}
}
}
- finally
- {
+ finally {
jbpmContext.close();
}
@@ -628,13 +542,10 @@
jbpmContextStacks.remove();
// remove from configurations map
- synchronized (instances)
- {
+ synchronized (instances) {
Iterator<JbpmConfiguration> iter = instances.values().iterator();
- while (iter.hasNext())
- {
- if (this == iter.next())
- {
+ while (iter.hasNext()) {
+ if (this == iter.next()) {
iter.remove();
break;
}
@@ -642,95 +553,78 @@
}
}
- static JbpmConfiguration getCurrentJbpmConfiguration()
- {
+ static JbpmConfiguration getCurrentJbpmConfiguration() {
JbpmConfiguration currentJbpmConfiguration = null;
List<JbpmConfiguration> stack = getJbpmConfigurationStack();
- if (!stack.isEmpty())
- {
+ if (!stack.isEmpty()) {
currentJbpmConfiguration = stack.get(stack.size() - 1);
}
return currentJbpmConfiguration;
}
- static List<JbpmConfiguration> getJbpmConfigurationStack()
- {
+ static List<JbpmConfiguration> getJbpmConfigurationStack() {
return jbpmConfigurationsStacks.get();
}
- synchronized void pushJbpmConfiguration()
- {
+ synchronized void pushJbpmConfiguration() {
getJbpmConfigurationStack().add(this);
}
- synchronized void popJbpmConfiguration()
- {
+ synchronized void popJbpmConfiguration() {
getJbpmConfigurationStack().remove(this);
}
- public JbpmContext getCurrentJbpmContext()
- {
+ public JbpmContext getCurrentJbpmContext() {
JbpmContext currentJbpmContext = null;
List<JbpmContext> stack = getJbpmContextStack();
- if (!stack.isEmpty())
- {
+ if (!stack.isEmpty()) {
currentJbpmContext = stack.get(stack.size() - 1);
}
return currentJbpmContext;
}
- List<JbpmContext> getJbpmContextStack()
- {
+ List<JbpmContext> getJbpmContextStack() {
return jbpmContextStacks.get();
}
- void pushJbpmContext(JbpmContext jbpmContext)
- {
+ void pushJbpmContext(JbpmContext jbpmContext) {
getJbpmContextStack().add(jbpmContext);
}
- void popJbpmContext(JbpmContext jbpmContext)
- {
+ void popJbpmContext(JbpmContext jbpmContext) {
List<JbpmContext> stack = getJbpmContextStack();
- if (stack.isEmpty())
- {
- throw new JbpmException("closed JbpmContext more than once... check your try-finally's around JbpmContexts blocks");
+ if (stack.isEmpty()) {
+ throw new JbpmException(
+ "closed JbpmContext more than once... check your try-finally's around JbpmContexts blocks");
}
JbpmContext popped = stack.remove(stack.size() - 1);
- if (jbpmContext != popped)
- {
+ if (jbpmContext != popped) {
stack.remove(jbpmContext); // prevent context from remaining in the stack
- throw new JbpmException("closed JbpmContext in some order that differs from creation... check your try-finally's around JbpmContexts blocks");
+ throw new JbpmException(
+ "closed JbpmContext in some order that differs from creation... check your try-finally's around JbpmContexts blocks");
}
}
- void jbpmContextCreated(JbpmContext jbpmContext)
- {
+ void jbpmContextCreated(JbpmContext jbpmContext) {
pushJbpmConfiguration();
pushJbpmContext(jbpmContext);
}
- void jbpmContextClosed(JbpmContext jbpmContext)
- {
+ void jbpmContextClosed(JbpmContext jbpmContext) {
popJbpmConfiguration();
popJbpmContext(jbpmContext);
}
- public void startJobExecutor()
- {
+ public void startJobExecutor() {
getJobExecutor().start();
}
- public synchronized JobExecutor getJobExecutor()
- {
- if (jobExecutor == null)
- {
- try
- {
+ public synchronized JobExecutor getJobExecutor() {
+ if (jobExecutor == null) {
+ try {
jobExecutor = (JobExecutor) this.objectFactory.createObject("jbpm.job.executor");
}
- catch (ClassCastException e)
- {
+ catch (ClassCastException e) {
throw new JbpmException("jbpm configuration object under key 'jbpm.job.executor' is not a "
+ JobExecutor.class.getName(), e);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -38,7 +38,6 @@
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.job.Job;
import org.jbpm.job.executor.JobExecutor;
import org.jbpm.logging.log.ProcessLog;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -81,8 +80,8 @@
Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
JbpmSchema jbpmSchema = new JbpmSchema(configuration);
- Map<String, Integer> jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
- for (Map.Entry<String, Integer> entry : jbpmTablesRecordCount.entrySet()) {
+ Map<String, Integer> recordCountPerTable = jbpmSchema.getRecordCountPerTable();
+ for (Map.Entry<String, Integer> entry : recordCountPerTable.entrySet()) {
// String tableName = entry.getKey();
Integer count = entry.getValue();
@@ -246,14 +245,10 @@
return timerCount.intValue();
}
- protected Job getJob() {
- return (Job) session.createQuery("from org.jbpm.job.Job").uniqueResult();
- }
-
protected void processJobs(long maxWait) {
commitAndCloseSession();
- startJobExecutor();
try {
+ startJobExecutor();
waitForJobs(maxWait);
}
finally {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -48,6 +48,8 @@
import org.hibernate.engine.Mapping;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.Table;
+import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
+import org.hibernate.tool.hbm2ddl.TableMetadata;
import org.hibernate.util.JDBCExceptionReporter;
import org.jbpm.JbpmException;
@@ -58,79 +60,61 @@
private static final long serialVersionUID = 1L;
- Configuration configuration = null;
- Settings settings;
- String[] createSql = null;
- String[] dropSql = null;
- String[] cleanSql = null;
+ final Configuration configuration;
+ final Settings settings;
ConnectionProvider connectionProvider = null;
Connection connection = null;
- private Statement statement;
-
public JbpmSchema(Configuration configuration) {
this.configuration = configuration;
this.settings = configuration.buildSettings();
}
public String[] getCreateSql() {
- if (createSql == null) {
- createSql = configuration.generateSchemaCreationScript(settings.getDialect());
- }
- return createSql;
+ return configuration.generateSchemaCreationScript(settings.getDialect());
}
public String[] getDropSql() {
- if (dropSql == null) {
- dropSql = configuration.generateDropSchemaScript(settings.getDialect());
- }
- return dropSql;
+ return configuration.generateDropSchemaScript(settings.getDialect());
}
public String[] getCleanSql() {
- if (cleanSql == null) {
- Dialect dialect = settings.getDialect();
- String catalog = settings.getDefaultCatalogName();
- String schema = settings.getDefaultSchemaName();
- Mapping mapping = configuration.buildMapping();
+ Dialect dialect = settings.getDialect();
+ String catalog = settings.getDefaultCatalogName();
+ String schema = settings.getDefaultSchemaName();
+ Mapping mapping = configuration.buildMapping();
- // loop over all foreign key constraints
- List<String> dropForeignKeysSql = new ArrayList<String>();
- List<String> createForeignKeysSql = new ArrayList<String>();
- List<String> deleteSql = new ArrayList<String>();
+ // loop over all foreign key constraints
+ List<String> dropForeignKeysSql = new ArrayList<String>();
+ List<String> createForeignKeysSql = new ArrayList<String>();
+ List<String> deleteSql = new ArrayList<String>();
- Iterator<?> iter = configuration.getTableMappings();
- while (iter.hasNext()) {
- Table table = (Table) iter.next();
+ for (Iterator<?> ti = configuration.getTableMappings(); ti.hasNext();) {
+ Table table = (Table) ti.next();
+ if (!table.isPhysicalTable()) continue;
- if (table.isPhysicalTable()) {
- Iterator<?> subIter = table.getForeignKeyIterator();
- while (subIter.hasNext()) {
- ForeignKey fk = (ForeignKey) subIter.next();
+ for (Iterator<?> fki = table.getForeignKeyIterator(); fki.hasNext();) {
+ ForeignKey fk = (ForeignKey) fki.next();
+ if (!fk.isPhysicalConstraint()) continue;
- if (fk.isPhysicalConstraint()) {
- // collect the drop foreign key constraint sql
- String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
- dropForeignKeysSql.add(sqlDropString);
+ // collect the drop foreign key sql
+ String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
+ dropForeignKeysSql.add(sqlDropString);
- // and collect the create foreign key constraint sql
- String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
- createForeignKeysSql.add(sqlCreateString);
- }
- }
- deleteSql.add("DELETE FROM " + table.getName());
- }
+ // and collect the create foreign key sql
+ String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
+ createForeignKeysSql.add(sqlCreateString);
}
+ deleteSql.add("DELETE FROM " + table.getName());
+ }
- // glue
- // - drop foreign key constraints
- // - delete contents of all tables
- // - create foreign key constraints
- // together to form the clean script
- cleanSql = concat(dropForeignKeysSql, deleteSql, createForeignKeysSql);
- }
- return cleanSql;
+ // glue
+ // - drop foreign key constraints
+ // - delete contents of all tables
+ // - create foreign key constraints
+ // together to form the clean script
+ return concat(dropForeignKeysSql, deleteSql, createForeignKeysSql);
}
private static String[] concat(List<?>... lists) {
@@ -148,45 +132,33 @@
return array;
}
- public boolean hasJbpmTables() {
- return (getJbpmTables().size() > 0);
- }
-
- public List<String> getJbpmTables() {
- // delete all the data in the jbpm tables
- List<String> jbpmTableNames = new ArrayList<String>();
- Iterator<?> iter = configuration.getTableMappings();
- while (iter.hasNext()) {
+ public List<String> getTableNames() {
+ List<String> tableNames = new ArrayList<String>();
+ for (Iterator<?> iter = configuration.getTableMappings(); iter.hasNext();) {
Table table = (Table) iter.next();
-
if (table.isPhysicalTable()) {
- jbpmTableNames.add(table.getName());
+ tableNames.add(table.getName());
}
}
- return jbpmTableNames;
+ return tableNames;
}
- public Map<String, Integer> getJbpmTablesRecordCount() {
+ public Map<String, Integer> getRecordCountPerTable() {
Map<String, Integer> recordCounts = new HashMap<String, Integer>();
try {
createConnection();
-
- statement = connection.createStatement();
- for (String tableName : getJbpmTables()) {
+ Statement statement = connection.createStatement();
+ for (String tableName : getTableNames()) {
String sql = "SELECT COUNT(*) FROM " + tableName;
- try {
- ResultSet resultSet = statement.executeQuery(sql);
- resultSet.next();
- recordCounts.put(tableName, resultSet.getInt(1));
- resultSet.close();
- }
- catch (SQLException e) {
- throw new JbpmException("could not execute sql '" + sql + "'", e);
- }
+ ResultSet resultSet = statement.executeQuery(sql);
+ resultSet.next();
+ recordCounts.put(tableName, resultSet.getInt(1));
+ resultSet.close();
}
+ statement.close();
}
catch (SQLException e) {
- throw new JbpmException("database connection failed", e);
+ throw new JbpmException("could not count records", e);
}
finally {
closeConnection();
@@ -195,16 +167,30 @@
}
public void dropSchema() {
- execute(getDropSql());
+ try {
+ execute(getDropSql());
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not drop schema", e);
+ }
}
public void createSchema() {
- execute(getCreateSql());
+ try {
+ execute(getCreateSql());
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not create schema", e);
+ }
}
public void cleanSchema() {
- if (!getJbpmTables().isEmpty())
+ try {
execute(getCleanSql());
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not clean schema", e);
+ }
}
public void saveSqlScripts(String dir, String prefix) {
@@ -229,6 +215,73 @@
return result;
}
+ public boolean tableExists(String tableName) {
+ Table table = findTableMapping(tableName);
+ try {
+ createConnection();
+ return getTableMetadata(table) != null;
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not tell whether table exists: " + tableName, e);
+ }
+ finally {
+ closeConnection();
+ }
+ }
+
+ public void createTable(String tableName) {
+ Table table = findTableMapping(tableName);
+ String sql = table.sqlCreateString(settings.getDialect(), configuration.buildMapping(),
+ settings.getDefaultCatalogName(), settings.getDefaultSchemaName());
+ try {
+ execute(sql);
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not create table: " + tableName, e);
+ }
+ }
+
+ public void updateTable(String tableName) {
+ Table table = findTableMapping(tableName);
+ try {
+ createConnection();
+ Iterator<?> sqls = table.sqlAlterStrings(settings.getDialect(), configuration.buildMapping(),
+ getTableMetadata(table), settings.getDefaultCatalogName(),
+ settings.getDefaultSchemaName());
+
+ Statement statement = connection.createStatement();
+ while (sqls.hasNext()) {
+ String sql = (String) sqls.next();
+ statement.executeUpdate(sql);
+ }
+ statement.close();
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not update table: " + tableName, e);
+ }
+ finally {
+ closeConnection();
+ }
+ }
+
+ private Table findTableMapping(String tableName) {
+ for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
+ Table table = (Table) i.next();
+ if (tableName.equals(table.getName())) {
+ return table;
+ }
+ }
+ throw new JbpmException("no mapping found for table: " + tableName);
+ }
+
+ private TableMetadata getTableMetadata(Table table) throws SQLException {
+ DatabaseMetadata databaseMetadata = new DatabaseMetadata(connection, settings.getDialect());
+ return databaseMetadata.getTableMetadata(table.getName(),
+ table.getSchema() == null ? settings.getDefaultSchemaName() : table.getSchema(),
+ table.getCatalog() == null ? settings.getDefaultCatalogName() : table.getCatalog(),
+ table.isQuoted());
+ }
+
public static void main(String[] args) {
if ((args == null) || (args.length == 0)) {
syntax();
@@ -295,40 +348,32 @@
}
}
- void execute(String[] sqls) {
+ void execute(String... sqls) throws SQLException {
boolean showSql = settings.isShowSqlEnabled();
try {
createConnection();
-
- statement = connection.createStatement();
+ Statement statement = connection.createStatement();
for (String sql : sqls) {
- if (showSql)
- log.debug(sql);
- try {
- statement.executeUpdate(sql);
- }
- catch (SQLException e) {
- throw new JbpmException("could not execute '" + sql + "'", e);
- }
+ if (showSql) System.out.println(sql);
+ statement.executeUpdate(sql);
}
+ statement.close();
}
- catch (SQLException e) {
- throw new JbpmException("database connection failed", e);
- }
finally {
closeConnection();
}
}
+ void createConnection() throws SQLException {
+ connectionProvider = settings.getConnectionProvider();
+ connection = connectionProvider.getConnection();
+ if (!connection.getAutoCommit()) {
+ connection.commit();
+ connection.setAutoCommit(true);
+ }
+ }
+
void closeConnection() {
- if (statement != null) {
- try {
- statement.close();
- }
- catch (SQLException e) {
- log.debug("could not close " + statement, e);
- }
- }
if (connection != null) {
try {
JDBCExceptionReporter.logAndClearWarnings(connection);
@@ -343,15 +388,6 @@
}
}
- void createConnection() throws SQLException {
- connectionProvider = settings.getConnectionProvider();
- connection = connectionProvider.getConnection();
- if (!connection.getAutoCommit()) {
- connection.commit();
- connection.setAutoCommit(true);
- }
- }
-
public Properties getProperties() {
return configuration.getProperties();
}
Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml 2009-01-23 07:10:21 UTC (rev 3705)
@@ -17,10 +17,6 @@
<!-- # common settings # -->
<!-- ################################### -->
- <!-- Automatic schema creation (begin) -->
- <property name="hibernate.hbm2ddl.auto">update</property>
- <!-- Automatic schema creation (end) -->
-
<!-- Simple memory-only cache -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
@@ -35,4 +31,3 @@
<!-- Additional mappings defined per module go here -->
<mapping resource="hibernate.extra.hbm.xml" />
<mapping resource="hibernate.identity.hbm.xml" />
-
Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.hsqldb.xml 2009-01-23 07:10:21 UTC (rev 3705)
@@ -9,3 +9,6 @@
<property name="hibernate.connection.password"></property>
<!-- JDBC connection properties (end) -->
+ <!-- Automatic schema creation (begin) -->
+ <property name="hibernate.hbm2ddl.auto">create</property>
+ <!-- Automatic schema creation (end) -->
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -21,10 +21,11 @@
*/
package org.jbpm.context.exe;
+import org.hibernate.cfg.Configuration;
import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
import org.jbpm.context.def.ContextDefinition;
import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.JbpmSchema;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -32,18 +33,20 @@
public class CustomVariableLongIdDbTest extends AbstractDbTestCase {
+ private static final String CUSTOM_TABLE = "JBPM_TEST_CUSTOMLONGID";
+
protected JbpmConfiguration getJbpmConfiguration() {
if (jbpmConfiguration == null) {
jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
- .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.getConfiguration().addClass(CustomLongClass.class);
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+
+ Configuration configuration = factory.getConfiguration();
+ configuration.addClass(CustomLongClass.class);
+
+ JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+ if (!jbpmSchema.tableExists(CUSTOM_TABLE)) {
+ jbpmSchema.createTable(CUSTOM_TABLE);
}
- finally {
- jbpmContext.close();
- }
}
return jbpmConfiguration;
}
@@ -77,7 +80,8 @@
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- if (customLongObject != null) session.delete(customLongObject);
+ if (customLongObject != null)
+ session.delete(customLongObject);
}
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -21,10 +21,11 @@
*/
package org.jbpm.context.exe;
+import org.hibernate.cfg.Configuration;
import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
import org.jbpm.context.def.ContextDefinition;
import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.JbpmSchema;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
@@ -32,18 +33,20 @@
public class CustomVariableStringIdDbTest extends AbstractDbTestCase {
+ private static final String CUSTOM_TABLE = "JBPM_TEST_CUSTOMSTRINGID";
+
protected JbpmConfiguration getJbpmConfiguration() {
if (jbpmConfiguration == null) {
jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
- .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.getConfiguration().addClass(CustomStringClass.class);
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+
+ Configuration configuration = factory.getConfiguration();
+ configuration.addClass(CustomStringClass.class);
+
+ JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+ if (!jbpmSchema.tableExists(CUSTOM_TABLE)) {
+ jbpmSchema.createTable(CUSTOM_TABLE);
}
- finally {
- jbpmContext.close();
- }
}
return jbpmConfiguration;
}
@@ -77,7 +80,8 @@
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- if (customStringObject != null) session.delete(customStringObject);
+ if (customStringObject != null)
+ session.delete(customStringObject);
}
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/scheduler/exe/TimerDbTest.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -25,13 +25,12 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
-import java.util.TimerTask;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Node;
@@ -39,14 +38,12 @@
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.job.Timer;
-import org.jbpm.job.executor.JobExecutorThread;
import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.util.CollectionUtil;
import org.jbpm.util.DateDbTestUtil;
public class TimerDbTest extends AbstractDbTestCase {
- private static Log log = LogFactory.getLog(Timer.class);
-
static boolean isNoOpExecuted = false;
protected void setUp() throws Exception {
@@ -182,9 +179,9 @@
try {
Node node = processDefinition.getNode("sometask");
- List actions = node.getEvent(Event.EVENTTYPE_NODE_ENTER).getActions();
+ List<Action> actions = node.getEvent(Event.EVENTTYPE_NODE_ENTER).getActions();
assertEquals(1, actions.size());
-
+
actions = node.getEvent(Event.EVENTTYPE_NODE_LEAVE).getActions();
assertEquals(1, actions.size());
@@ -193,7 +190,6 @@
jbpmContext.save(processInstance);
newTransaction();
-
assertEquals(1, getTimerCount());
}
finally {
@@ -251,7 +247,7 @@
processInstance = saveAndReload(processInstance);
assertEquals(1, getTimerCount());
processInstance.signal();
-
+
newTransaction();
assertEquals(1, getTimerCount());
@@ -285,13 +281,13 @@
processInstance = saveAndReload(processInstance);
- List timersByName = session.createCriteria(Timer.class)
- .add(Restrictions.eq("name", "reminder"))
- .list();
+ Criteria criteria = session.createCriteria(Timer.class).add(
+ Restrictions.eq("name", "reminder"));
+ List<Timer> timersByName = CollectionUtil.checkList(criteria.list(), Timer.class);
assertNotNull(timersByName);
assertEquals(1, timersByName.size());
- Timer timer = (Timer) timersByName.get(0);
+ Timer timer = timersByName.get(0);
assertEquals("geftem-eu-shuppe-oender-ze-konte", timer.getAction()
.getActionDelegation()
.getClassName());
@@ -328,7 +324,7 @@
newTransaction();
Timer timer = (Timer) jobSession.getFirstAcquirableJob(null);
-
+
assertNotNull(timer);
Date date = timer.getDueDate();
assertNotNull(date);
@@ -340,10 +336,11 @@
newTransaction();
- List timers = session.createQuery("from org.jbpm.job.Timer").list();
+ Criteria criteria = session.createCriteria(Timer.class);
+ List<Timer> timers = CollectionUtil.checkList(criteria.list(), Timer.class);
assertEquals(1, timers.size());
- timer = (Timer) timers.get(0);
+ timer = timers.get(0);
assertEquals(origDueDate + 5000, timer.getDueDate().getTime());
processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
@@ -374,7 +371,6 @@
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
}
public void testTimerUpdatingProcessVariables() throws Exception {
@@ -418,7 +414,7 @@
assertEquals("value a", contextInstance.getVariable("a"));
assertEquals("value b updated", contextInstance.getVariable("b"));
- TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
@@ -431,7 +427,6 @@
}
public static class ConcurrentUpdateAction implements ActionHandler {
-
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
@@ -440,7 +435,6 @@
}
public static class NoOp implements ActionHandler {
-
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
@@ -449,7 +443,6 @@
}
public static class UpdateVariables implements ActionHandler {
-
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/AsyncAction.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -25,7 +25,11 @@
import org.jbpm.graph.exe.ExecutionContext;
public class AsyncAction implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
public void execute(ExecutionContext executionContext) throws Exception {
- JobExecutorCustomizationTest.jobEvents.add("execute action");
+ JobExecutorCustomizationTest.addJobEvent("execute action");
}
+
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutor.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -3,9 +3,11 @@
import org.jbpm.job.executor.JobExecutor;
public class CustomJobExecutor extends JobExecutor {
+
private static final long serialVersionUID = 1L;
protected Thread createThread(String threadName) {
- return new CustomJobExecutorThread(threadName, this, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, historyMaxSize);
+ return new CustomJobExecutorThread(threadName, this);
}
+
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/CustomJobExecutorThread.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -1,24 +1,24 @@
package org.jbpm.seam;
-import org.jbpm.JbpmConfiguration;
import org.jbpm.job.Job;
import org.jbpm.job.executor.JobExecutor;
import org.jbpm.job.executor.JobExecutorThread;
public class CustomJobExecutorThread extends JobExecutorThread {
- public CustomJobExecutorThread(String name, JobExecutor jobExecutor, JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime, int maxHistory) {
- super(name, jobExecutor, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, maxHistory);
+ public CustomJobExecutorThread(String name, JobExecutor jobExecutor) {
+ super(name, jobExecutor);
}
protected void executeJob(Job job) {
// intercept before
- JobExecutorCustomizationTest.jobEvents.add("before");
+ JobExecutorCustomizationTest.addJobEvent("before");
try {
super.executeJob(job);
- } finally {
+ }
+ finally {
// intercept after
- JobExecutorCustomizationTest.jobEvents.add("after");
+ JobExecutorCustomizationTest.addJobEvent("after");
}
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -1,17 +1,17 @@
package org.jbpm.seam;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.job.executor.JobExecutor;
-
public class JobExecutorCustomizationTest extends AbstractDbTestCase {
-
- public static List jobEvents = new ArrayList();
-
+
+ private static List<String> jobEvents = new ArrayList<String>();
+
protected String getJbpmTestConfig() {
return "org/jbpm/seam/custom.job.executor.jbpm.cfg.xml";
}
@@ -25,45 +25,33 @@
public void testCustomJobExecutor() {
JobExecutor jobExecutor = getJbpmConfiguration().getJobExecutor();
assertEquals(CustomJobExecutor.class, jobExecutor.getClass());
-
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='customjobexecution' initial='start'>" +
- " <node name='start'>" +
- " <transition to='end'>" +
- " <action async='true' class='"+AsyncAction.class.getName()+"' />" +
- " </transition>" +
- " </node>" +
- " <state name='end' />" +
- "</process-definition>"
- );
+
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='customjobexecution' initial='start'>"
+ + " <node name='start'>"
+ + " <transition to='end'>"
+ + " <action async='true' class='"
+ + AsyncAction.class.getName()
+ + "' />"
+ + " </transition>"
+ + " </node>"
+ + " <state name='end' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
- long processDefinitionId = processDefinition.getId();
+ newTransaction();
try {
-
- newTransaction();
-
jbpmContext.newProcessInstanceForUpdate("customjobexecution");
-
- newTransaction();
-
- jobExecutor.start();
- try {
- waitForJobs(20000);
- } finally {
- jobExecutor.stop();
- }
+ processJobs(20 * 1000);
- } finally {
- newTransaction();
-
- graphSession.deleteProcessDefinition(processDefinitionId);
+ List<String> expectedJobEvents = Arrays.asList("before", "execute action", "after");
+ assertEquals(expectedJobEvents, jobEvents);
}
-
- List expectedJobEvents = new ArrayList();
- expectedJobEvents.add("before");
- expectedJobEvents.add("execute action");
- expectedJobEvents.add("after");
-
- assertEquals(expectedJobEvents, jobEvents);
+ finally {
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ }
}
+
+ public static void addJobEvent(String event) {
+ jobEvents.add(event);
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java 2009-01-23 07:10:21 UTC (rev 3705)
@@ -35,83 +35,78 @@
public class TaskTimerExecutionDbTest extends AbstractDbTestCase {
static int counter = 0;
-
+
public static class PlusPlus implements ActionHandler {
private static final long serialVersionUID = 1L;
+
public void execute(ExecutionContext executionContext) throws Exception {
counter++;
}
}
-
+
protected void setUp() throws Exception {
super.setUp();
counter = 0;
}
public void testTimerCreation() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling'>" +
- " <timer name='ceiling-timer' duedate='0 seconds'>" +
- " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
- " </timer>" +
- " </task>" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling'>"
+ + " <timer name='ceiling-timer' duedate='0 seconds'>"
+ + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " </timer>"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
+
processInstance = saveAndReload(processInstance);
- Timer timer = (Timer) getJob();
+ Timer timer = getTimer();
assertEquals("ceiling-timer", timer.getName());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
public void testTimerDeletion() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling'>" +
- " <timer name='ceiling-timer' duedate='0 seconds'>" +
- " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
- " </timer>" +
- " </task>" +
- " <transition to='b' />" +
- " </task-node>" +
- " <state name='b' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling'>"
+ + " <timer name='ceiling-timer' duedate='0 seconds'>"
+ + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " </timer>"
+ + " </task>"
+ + " <transition to='b' />"
+ + " </task-node>"
+ + " <state name='b' />"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
jbpmContext.save(processInstance);
newTransaction();
- List taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken().getId());
+ List<TaskInstance> taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken()
+ .getId());
assertEquals(1, taskInstances.size());
- TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
+ TaskInstance taskInstance = taskInstances.get(0);
taskInstance.end();
jbpmContext.save(taskInstance);
@@ -119,98 +114,86 @@
assertEquals(0, getTimerCount());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
public void testTimerExecution() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling'>" +
- " <timer name='ceiling-timer' duedate='0 seconds'>" +
- " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
- " </timer>" +
- " </task>" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling'>"
+ + " <timer name='ceiling-timer' duedate='0 seconds'>"
+ + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " </timer>"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
jbpmContext.save(processInstance);
-
+
processJobs(5000);
assertEquals(1, counter);
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
+
}
public void testTaskNodeTimerExecution() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <timer name='ceiling-timer' duedate='0 seconds'>" +
- " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
- " </timer>" +
- " <task name='clean ceiling' />" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <timer name='ceiling-timer' duedate='0 seconds'>"
+ + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " </timer>"
+ + " <task name='clean ceiling' />"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
jbpmContext.save(processInstance);
-
+
newTransaction();
processJobs(5000);
assertEquals(1, counter);
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
public void testTimerExecutionRepeat() throws Exception {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling'>" +
- " <timer name='ceiling-timer' duedate='0 seconds' repeat='60 second'>" +
- " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
- " </timer>" +
- " </task>" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling'>"
+ + " <timer name='ceiling-timer' duedate='0 seconds' repeat='60 second'>"
+ + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " </timer>"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
jbpmContext.save(processInstance);
@@ -218,7 +201,7 @@
newTransaction();
// fetch the original duedate
- Timer timer = (Timer) getJob();
+ Timer timer = getTimer();
assertNotNull(timer);
long originalDueDate = timer.getDueDate().getTime();
@@ -226,37 +209,33 @@
assertEquals(1, counter);
// check if the timer has be re-scheduled because of the repeat.
- timer = (Timer) getJob();
+ timer = getTimer();
assertNotNull(timer);
// check that the timer was rescheduled with a duedate 60 seconds after the original duedate.
- assertEquals(originalDueDate+60000, timer.getDueDate().getTime());
+ assertEquals(originalDueDate + 60000, timer.getDueDate().getTime());
}
- finally
- {
+ finally {
newTransaction();
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
-
+
public void testTimerELCreation() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling'>" +
- " <timer name='ceiling-timer' duedate='#{baseDate} + 2 days'>" +
- " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />" +
- " </timer>" +
- " </task>" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling'>"
+ + " <timer name='ceiling-timer' duedate='#{baseDate} + 2 days'>"
+ + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " </timer>"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
Calendar baseDate = Calendar.getInstance();
Date dateTestDate = new Date();
baseDate.setTime(dateTestDate);
@@ -273,15 +252,18 @@
baseDateTest.clear(Calendar.MILLISECOND);
baseDateTest.add(Calendar.DAY_OF_YEAR, 2);
- Timer timer = (Timer) getJob();
+ Timer timer = getTimer();
assertEquals("ceiling-timer", timer.getName());
-
+
assertNotNull(timer.getDueDate());
- assertEquals(baseDateTest.getTime(), timer.getDueDate());
+ assertEquals(baseDateTest.getTime(), timer.getDueDate());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
- }
+ }
+
+ private Timer getTimer() {
+ return (Timer) session.createCriteria(Timer.class).setMaxResults(1).uniqueResult();
+ }
}
Modified: jbpm3/trunk/modules/core/src/test/resources/log4j.xml
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/log4j.xml 2009-01-22 20:25:15 UTC (rev 3704)
+++ jbpm3/trunk/modules/core/src/test/resources/log4j.xml 2009-01-23 07:10:21 UTC (rev 3705)
@@ -35,17 +35,28 @@
<category name="org.hibernate">
<priority value="INFO" />
</category>
+
+ <!-- hide optimistic locking failures
+ <category name="org.hibernate.event.def.AbstractFlushingEventListener">
+ <priority value="FATAL" />
+ </category>
+ -->
+
+ <!-- hide proxy narrowing warns -->
+ <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
+ <priority value="ERROR" />
+ </category>
+
+ <!-- show SQL DML statements as they are executed -->
<category name="org.hibernate.SQL">
<priority value="DEBUG" />
</category>
- <!--
+
+ <!-- show JDBC parameters
<category name="org.hibernate.type">
<priority value="TRACE" />
</category>
-->
- <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
- <priority value="ERROR" />
- </category>
<!-- ======================= -->
<!-- Setup the Root category -->
15 years, 3 months
JBoss JBPM SVN: r3704 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/cmd and 6 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-01-22 15:25:15 -0500 (Thu, 22 Jan 2009)
New Revision: 3704
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryCmd.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.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/hibernate/HibernateTaskDbSession.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/task/src/main/java/org/jbpm/task/session/TaskDbSession.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
Log:
added task queries
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-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -31,6 +31,7 @@
*/
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";
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryCmd.java 2009-01-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryCmd.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -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 HqlQueryCmd implements Command<List<Object>> {
-
- private static final long serialVersionUID = 1L;
-
- private static Log log = Log.getLog(HqlQueryCmd.class.getName());
-
- String hql;
- Integer firstResult;
- Integer maxResults;
-
- public HqlQueryCmd(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/cmd/HqlQueryOldCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/HqlQueryOldCmd.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -0,0 +1,74 @@
+/*
+ * 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();
+ }
+}
Modified: 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-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionQueryImpl.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -26,7 +26,7 @@
import org.jbpm.Execution;
import org.jbpm.ExecutionQuery;
import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.HqlQueryCmd;
+import org.jbpm.pvm.internal.cmd.HqlQueryOldCmd;
import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -97,7 +97,7 @@
protected List<Execution> execute() {
String hql = buildHql();
- return (List) commandService.execute(new HqlQueryCmd(hql, firstResult, maxResults));
+ return (List) commandService.execute(new HqlQueryOldCmd(hql, firstResult, maxResults));
}
public ExecutionQuery onlyProcessInstances() {
Modified: 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-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessDefinitionQueryImpl.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -26,7 +26,7 @@
import org.jbpm.ProcessDefinition;
import org.jbpm.ProcessDefinitionQuery;
import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.HqlQueryCmd;
+import org.jbpm.pvm.internal.cmd.HqlQueryOldCmd;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
@@ -81,7 +81,7 @@
protected List<ProcessDefinition> execute() {
String hql = buildHql();
- return (List) commandService.execute(new HqlQueryCmd(hql, firstResult, maxResults));
+ return (List) commandService.execute(new HqlQueryOldCmd(hql, firstResult, maxResults));
}
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java 2009-01-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -1,53 +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;
-import org.jbpm.task.session.TaskDbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class GetPersonalTaskListCmd implements Command<List<Task>> {
-
- private static final long serialVersionUID = 1L;
-
- protected String userId;
- protected int firstResult;
- protected int maxResults;
-
- public GetPersonalTaskListCmd(String userId, int firstResult, int maxResults) {
- this.userId = userId;
- this.firstResult = firstResult;
- this.maxResults = maxResults;
- }
-
- public List<Task> execute(Environment environment) {
- TaskDbSession taskDbession = environment.get(TaskDbSession.class);
- return taskDbession.findPersonalTasks(userId, firstResult, maxResults);
- }
-}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java 2009-01-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -22,11 +22,9 @@
package org.jbpm.task.internal.hibernate;
import java.io.Serializable;
-import java.util.List;
import org.hibernate.criterion.Restrictions;
import org.jbpm.pvm.internal.hibernate.HibernateDbSession;
-import org.jbpm.task.Task;
import org.jbpm.task.internal.model.TaskImpl;
import org.jbpm.task.session.TaskDbSession;
@@ -43,16 +41,6 @@
.uniqueResult();
}
- public List<Task> findPersonalTasks(String userId, int firstResult, int maxResults) {
- // TODO maybe we should move these criteria queries to hql queries in the
- // hbm file so that users can easily customize.
- return session.createCriteria(TaskImpl.class)
- .add(Restrictions.eq("assignee", userId))
- .setFirstResult(firstResult)
- .setMaxResults(maxResults)
- .list();
- }
-
public void saveTask(TaskImpl task) {
if (! task.isPersisted()) {
Serializable dbid = session.save(task);
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-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -23,20 +23,30 @@
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.task.Task;
-import org.jbpm.task.internal.cmd.HqlQueryCmd;
/**
* @author Tom Baeyens
*/
-public class TaskQueryImpl implements TaskQuery {
+public class TaskQueryImpl implements TaskQuery, Command<List<Task>> {
+ 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;
@@ -44,23 +54,79 @@
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) {
- return null;
+ addOrderByClause(property, "asc");
+ return this;
}
public TaskQuery orderDesc(String property) {
- return null;
+ addOrderByClause(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) {
- return null;
+ page = new int[]{firstResult, maxResults};
+ return this;
}
public List<Task> execute() {
- // TODO
- return commandService.execute(null);
+ return commandService.execute(this);
}
+
+ public List<Task> execute(Environment environment){
+ 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 ");
+ } else if (assignee!=null) {
+ hql.append("task.assignee = :assignee ");
+ }
+
+ if (orderByClause!=null) {
+ hql.append("order by ");
+ hql.append(orderByClause);
+ }
+
+ 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();
+ }
}
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-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -28,10 +28,9 @@
import org.jbpm.cmd.CommandService;
import org.jbpm.task.Role;
import org.jbpm.task.Task;
-import org.jbpm.task.internal.cmd.NewTaskCmd;
import org.jbpm.task.internal.cmd.DeleteTaskCmd;
-import org.jbpm.task.internal.cmd.GetPersonalTaskListCmd;
import org.jbpm.task.internal.cmd.GetTaskCmd;
+import org.jbpm.task.internal.cmd.NewTaskCmd;
import org.jbpm.task.internal.cmd.SaveTaskCmd;
import org.jbpm.task.internal.cmd.SubmitTaskCmd;
@@ -89,8 +88,12 @@
return null;
}
- public List<Task> getPersonalTaskList(String userId, int firstResult, int maxResults) {
- return commandService.execute(new GetPersonalTaskListCmd(userId, firstResult, maxResults));
+ public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
+ return createTaskQuery()
+ .assignee(assignee)
+ .orderDesc(TaskQuery.PRIORITY)
+ .page(firstResult, maxResults)
+ .execute();
}
public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java 2009-01-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -21,10 +21,7 @@
*/
package org.jbpm.task.session;
-import java.util.List;
-
import org.jbpm.session.DbSession;
-import org.jbpm.task.Task;
import org.jbpm.task.internal.model.TaskImpl;
/**
@@ -35,7 +32,5 @@
TaskImpl findTaskById(String taskId);
- List<Task> findPersonalTasks(String userId, int firstResult, int maxResults);
-
void saveTask(TaskImpl 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-22 17:59:15 UTC (rev 3703)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java 2009-01-22 20:25:15 UTC (rev 3704)
@@ -23,6 +23,7 @@
import java.util.List;
+import org.jbpm.TaskQuery;
import org.jbpm.task.Task;
import org.jbpm.test.DbTestCase;
@@ -32,46 +33,167 @@
*/
public class TaskListTest extends DbTestCase {
- public void testDefaultScenario() {
+ public void testPersonalTaskList() {
Task task = taskService.newTask();
task.setName("do laundry");
task.setAssignee("johndoe");
saveTask(task);
task = taskService.newTask();
+ task.setName("get good idea");
+ task.setAssignee("joesmoe");
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setAssignee("joesmoe");
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ saveTask(task);
+
+ List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+ assertNotNull(taskList);
+
+ assertEquals("do laundry", taskList.get(0).getName());
+ assertEquals(1, taskList.size());
+
+ taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
+ assertNotNull(taskList);
+
+ assertContainsTask(taskList, "get good idea");
+ assertContainsTask(taskList, "start new business");
+ assertContainsTask(taskList, "find venture capital");
+
+ assertEquals(3, taskList.size());
+ }
+
+ public void testPersonalTaskListDefaultSortOrder() {
+ Task task = taskService.newTask();
+ task.setName("get good idea");
+ task.setAssignee("joesmoe");
+ task.setPriority(3);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setAssignee("joesmoe");
+ task.setPriority(2);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(1);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("take a day off");
+ task.setAssignee("joesmoe");
+ task.setPriority(-5);
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("make profit");
+ task.setAssignee("joesmoe");
+ task.setPriority(10);
+ saveTask(task);
+
+ List<Task> taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
+ assertNotNull(taskList);
+
+ assertEquals("make profit", taskList.get(0).getName());
+ assertEquals("get good idea", taskList.get(1).getName());
+ assertEquals("find venture capital", taskList.get(2).getName());
+ assertEquals("start new business", taskList.get(3).getName());
+ assertEquals("take a day off", taskList.get(4).getName());
+
+ 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.setAssignee("joesmoe");
+ task.setPriority(4);
saveTask(task);
- /*
- List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .execute();
assertNotNull(taskList);
- task = taskList.get(0);
- assertEquals("johndoe", task.getAssignee());
- assertEquals("do laundry", task.getName());
+ assertContainsTask(taskList, "do laundry");
+ assertContainsTask(taskList, "change dyper");
+ assertContainsTask(taskList, "start new business");
+ assertContainsTask(taskList, "find venture capital");
- task = taskList.get(1);
- assertEquals("johndoe", task.getAssignee());
- assertEquals("do laundry", task.getName());
+ assertEquals(4, taskList.size());
+ }
- assertEquals(2, 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);
-
- taskService.submitTask(task.getId());
-
- assertEquals(0, taskService.getPersonalTaskList("johndoe", 0, 10).size());
-
- */
+ 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);
+ }
}
15 years, 3 months
JBoss JBPM SVN: r3703 - jbpm4/trunk/modules/db/src/main/ant.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-01-22 12:59:15 -0500 (Thu, 22 Jan 2009)
New Revision: 3703
Modified:
jbpm4/trunk/modules/db/src/main/ant/build.schema.xml
Log:
added ; delimiter for mysql
Modified: jbpm4/trunk/modules/db/src/main/ant/build.schema.xml
===================================================================
--- jbpm4/trunk/modules/db/src/main/ant/build.schema.xml 2009-01-22 17:30:37 UTC (rev 3702)
+++ jbpm4/trunk/modules/db/src/main/ant/build.schema.xml 2009-01-22 17:59:15 UTC (rev 3703)
@@ -35,10 +35,12 @@
create="no" drop="yes" config="${cfg}" text="yes" />
<schemaexport properties="src/main/resources/db.properties/mysql.properties"
- output="target/classes/create/jbpm.mysql.create.sql"
+ output="target/classes/create/jbpm.mysql.create.sql"
+ delimiter=";"
create="yes" drop="no" config="${cfg}" text="yes" />
<schemaexport properties="src/main/resources/db.properties/mysql.properties"
output="target/classes/drop/jbpm.mysql.drop.sql"
+ delimiter=";"
create="no" drop="yes" config="${cfg}" text="yes" />
<schemaexport properties="src/main/resources/db.properties/oracle.properties"
15 years, 3 months
JBoss JBPM SVN: r3702 - jbpm3/trunk/modules/core/src/main/java/org/jbpm.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-22 12:30:37 -0500 (Thu, 22 Jan 2009)
New Revision: 3702
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java
Log:
increase event timeout
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java 2009-01-22 15:17:25 UTC (rev 3701)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/EventCallback.java 2009-01-22 17:30:37 UTC (rev 3702)
@@ -37,7 +37,7 @@
public class EventCallback implements Serializable {
- public static final int DEFAULT_TIMEOUT = 30 * 1000;
+ public static final int DEFAULT_TIMEOUT = 60 * 1000;
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(EventCallback.class);
15 years, 3 months
JBoss JBPM SVN: r3701 - in jbpm4/trunk/modules: task/src/main/java/org/jbpm/task/internal/cmd and 5 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-01-22 10:17:25 -0500 (Thu, 22 Jan 2009)
New Revision: 3701
Added:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
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/model/TaskQueryImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/
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/TaskServiceTest.java
Removed:
jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
Log:
started thinking about task queries
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface TaskQuery {
+
+ 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";
+
+ TaskQuery assignee(String assignee);
+
+ TaskQuery page(int firstResult, int maxResults);
+ TaskQuery orderAsc(String property);
+ TaskQuery orderDesc(String property);
+
+ List<Task> execute();
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -54,6 +54,8 @@
List<String> getCandidates(String taskId);
List<Role> getRoles(String taskId);
+
+ TaskQuery createTaskQuery();
/** retrieves the personal task of the given user, which might be different
* then the current authenticated user. E.g. when a manager wants to
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,40 @@
+/*
+ * 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;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,66 @@
+/*
+ * 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.model;
+
+import java.util.List;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.cmd.HqlQueryCmd;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryImpl implements TaskQuery {
+
+ protected CommandService commandService;
+
+ protected String assignee = null;
+
+ public TaskQueryImpl(CommandService commandService) {
+ this.commandService = commandService;
+ }
+
+ public TaskQuery assignee(String assignee) {
+ this.assignee = assignee;
+ return this;
+ }
+
+ public TaskQuery orderAsc(String property) {
+ return null;
+ }
+
+ public TaskQuery orderDesc(String property) {
+ return null;
+ }
+
+ public TaskQuery page(int firstResult, int maxResults) {
+ return null;
+ }
+
+ public List<Task> execute() {
+ // TODO
+ return commandService.execute(null);
+ }
+}
Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -23,6 +23,7 @@
import java.util.List;
+import org.jbpm.TaskQuery;
import org.jbpm.TaskService;
import org.jbpm.cmd.CommandService;
import org.jbpm.task.Role;
@@ -95,4 +96,8 @@
public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
return null;
}
+
+ public TaskQuery createTaskQuery() {
+ return new TaskQueryImpl(commandService);
+ }
}
Deleted: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java 2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -1,54 +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.model;
-
-import java.util.List;
-
-import org.jbpm.task.Task;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TaskActivityScenarioTest extends DbTestCase {
-
- public void testDefaultScenario() {
- // execution arrives in task activity
- // the task id is generated from the executionId and the task name
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- taskService.saveTask(task);
-
- List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
- assertEquals("expected 1 task for john doe: "+taskList, 1, taskList.size());
-
- task = taskList.get(0);
- assertEquals("johndoe", task.getAssignee());
- assertEquals("do laundry", task.getName());
-
- taskService.submitTask(task.getId());
-
- assertEquals(0, taskService.getPersonalTaskList("johndoe", 0, 10).size());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java 2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -1,77 +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.svc;
-
-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() {
- Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
- assertNull("expected null, but was " + task, 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("expected non-null task id", 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);
- }
-}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java (from rev 3682, jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,77 @@
+/*
+ * 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.task.Task;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskListTest extends DbTestCase {
+
+ public void testDefaultScenario() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setAssignee("joesmoe");
+ saveTask(task);
+
+ /*
+ List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+ assertNotNull(taskList);
+
+ task = taskList.get(0);
+ assertEquals("johndoe", task.getAssignee());
+ assertEquals("do laundry", task.getName());
+
+ task = taskList.get(1);
+ assertEquals("johndoe", task.getAssignee());
+ assertEquals("do laundry", task.getName());
+
+ assertEquals(2, taskList.size());
+
+
+ taskService.submitTask(task.getId());
+
+ assertEquals(0, taskService.getPersonalTaskList("johndoe", 0, 10).size());
+
+ */
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java (from rev 3641, jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java 2009-01-22 15:17:25 UTC (rev 3701)
@@ -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 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);
+ }
+}
15 years, 3 months
JBoss JBPM SVN: r3700 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/modules and 6 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-01-22 05:56:09 -0500 (Thu, 22 Jan 2009)
New Revision: 3700
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Event.java
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java
Log:
JBPM-1753 review event names
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Event.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Event.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Event.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -24,26 +24,14 @@
/** event constants.
*
- * <b>WARNING: these event names will be subject to change in the next release.
- * See <a href="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</a></b>
- *
* @author Tom Baeyens
*/
public interface Event {
- /** <b>WARNING: this event name will be subject to change in the next release. See <a href="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</a></b>
- * @deprecated */
- String TRANSITION_TAKE = "transition-take";
- /** <b>WARNING: this event name will be subject to change in the next release. See <a href="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</a></b>
- * @deprecated */
- String PROCESS_BEGIN = "process-begin";
- /** <b>WARNING: this event name will be subject to change in the next release. See <a href="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</a></b>
- * @deprecated */
- String PROCESS_END = "process-end";
- /** <b>WARNING: this event name will be subject to change in the next release. See <a href="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</a></b>
- * @deprecated */
- String NODE_BEGIN = "activity-begin";
- /** <b>WARNING: this event name will be subject to change in the next release. See <a href="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</a></b>
- * @deprecated */
- String NODE_END = "activity-end";
+ /** fired when a transition is being taken */
+ String TAKE = "take";
+ /** fired when a process or an activity starts */
+ String START = "start";
+ /** fired when a process or an activity ends */
+ String END = "end";
}
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml 2009-01-22 10:56:09 UTC (rev 3700)
@@ -310,32 +310,7 @@
</para>
<para>Most common events are fired by the execution automatically:
</para>
- <para><emphasis role="bold">WARNING: the following event names will be
- subject to change in the next release: see
- <ulink url="https://jira.jboss.org/jira/browse/JBPM-1753">JBPM-1753</ulink></emphasis>
- </para>
- <itemizedlist>
- <listitem><literal><emphasis role="bold">Event.TRANSITION_TAKE</emphasis> = "transition-take"</literal> :
- fired on transitions when transitions are taken.
- </listitem>
- <listitem><literal><emphasis role="bold">Event.NODE_BEGIN</emphasis> = "activity-begin"</literal> : fired on the activity
- when execution enters that activity. This happens when execution takes a transition
- to that activity, when a child activity is being executed with <literal>execution.execute(Activity)</literal>
- or when a transition is taken from a activity outside that activity to a contained activity.
- The latter refers to super states in state machines.
- </listitem>
- <listitem><literal><emphasis role="bold">Event.NODE_END</emphasis> = "activity-end"</literal> : fired on the activity
- when a transition is taken out of that activity or when a child activity execution is
- finished and the execution is propagated to the parent activity.
- </listitem>
- <listitem><literal><emphasis role="bold">Event.PROCESS_BEGIN</emphasis> = "process-begin"</literal> : fired on a process
- when a new process is started.
- </listitem>
- <listitem><literal><emphasis role="bold">Event.PROCESS_END</emphasis> = "process-end"</literal> : fired on a process
- when a new process is ended. This might include a executions that are ended
- with a cancelled or error state.
- </listitem>
- </itemizedlist>
+ <para>TODO: explain events in userguide</para>
<para>Events are identified by the combination of a process element
and an event name. Users and process languages can also fire events
programmatically with the fire method on the Execution:
@@ -375,13 +350,13 @@
</figure>
<programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build()
.activity("a").initial().behaviour(new AutomaticActivity())
- <emphasis role="bold">.event("activity-end")
+ <emphasis role="bold">.event("end")
.listener(new PrintLn("leaving a"))
.listener(new PrintLn("second message while leaving a"))</emphasis>
.transition().to("b")
<emphasis role="bold">.listener(new PrintLn("taking transition"))</emphasis>
.activity("b").behaviour(new WaitState())
- .event("activity-begin")
+ .event("start")
<emphasis role="bold">.listener(new PrintLn("entering b"))</emphasis>
.done();</programlisting>
<para>The first event shows how to register multiple listeners to the same
@@ -405,7 +380,7 @@
is to allow for listeners on process definitions or composite activities that get executed
for all events that occur within that process element. For example this feature
allows to register an event listener on a process definition or a composite activity on
- <literal>activity-end</literal> events. Such action will be executed if that activity is
+ <literal>end</literal> events. Such action will be executed if that activity is
left. And if that event listener is registered on a composite activity, it will also be executed
for all activities that are left within that composite activity.
</para>
@@ -421,12 +396,12 @@
}</programlisting>
<para>Note that the purpose of event listeners is not to be visible, that's why the event listener
itself should not be displayed in the diagram. A <literal>DisplaySource</literal> event listener
- will be added as a listener to the event <literal>activity-end</literal> on the composite activity.
+ will be added as a listener to the event <literal>end</literal> on the composite activity.
</para>
<para>The next process shows how the <literal>DisplaySource</literal> event listener is registered
- as a listener to to the 'activity-end' event on the <literal>composite</literal> activity:</para>
+ as a listener to to the 'end' event on the <literal>composite</literal> activity:</para>
<figure id="process.propagate">
- <title>A process with an invisible event listener on a activity-end event on a composite activity.</title>
+ <title>A process with an invisible event listener on a end event on a composite activity.</title>
<mediaobject><imageobject><imagedata align="center" fileref="images/process.propagate.png"/></imageobject></mediaobject>
</figure>
<programlisting>TODO update code snippet</programlisting>
@@ -439,7 +414,7 @@
</para>
<programlisting>execution.signal();</programlisting>
<para>When the signal method returns, the execution will have taken the transition and
- the <literal>activity-end</literal> event will be fired on activity <literal>a</literal>. That
+ the <literal>end</literal> event will be fired on activity <literal>a</literal>. That
event will be propagated to the
composite activity and to the process definition. Since our <literal>DisplaySource</literal>
event listener is placed
@@ -476,13 +451,13 @@
remains the same.
</para>
<figure id="process.propagate.propagation.disabled">
- <title>A process with an event listener to 'activity-end' events with propagation disabled.</title>
+ <title>A process with an event listener to 'end' events with propagation disabled.</title>
<mediaobject><imageobject><imagedata align="center" fileref="images/process.propagate.png"/></imageobject></mediaobject>
</figure>
<para>Building the process with the process factory:
</para>
<programlisting>TODO update code snippet</programlisting>
- <para>So when the first signal is given for this process, again the <literal>activity-end</literal>
+ <para>So when the first signal is given for this process, again the <literal>end</literal>
event will be fired on activity <literal>a</literal>, but now the event listener on the composite
activity will not be executed cause
propagated events have been disabled. Disabling propagation is a property on the individual
@@ -497,13 +472,13 @@
<para>Next, the second signal will take the transition from b to c.
</para>
<programlisting>execution.signal()</programlisting>
- <para>Again two <literal>activity-end</literal>
+ <para>Again two <literal>end</literal>
events are fired just like above on activities <literal>b</literal> and <literal>composite</literal>
respectively. The first event
- is the <literal>activity-end</literal> event on activity <literal>b</literal>. That will be propagated
+ is the <literal>end</literal> event on activity <literal>b</literal>. That will be propagated
to the <literal>composite</literal> activity. So the event
listener will not be executed for this event cause it has propagation disabled. But the
- event listener will be executed for the <literal>activity-end</literal> event on the
+ event listener will be executed for the <literal>end</literal> event on the
<literal>composite</literal> activity. That is not
propagated, but fired directly on the <literal>composite</literal> activity. So the event
listener will now be executed
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -37,7 +37,7 @@
protected TransitionImpl transition;
public FlowBuilder(ActivityBuilder activityBuilder, TransitionImpl transition) {
- super(transition, Event.TRANSITION_TAKE);
+ super(transition, Event.TAKE);
this.activityBuilder = activityBuilder;
this.transition = transition;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -31,14 +31,14 @@
private static final long serialVersionUID = 1L;
/** does this action accept propagated events ? */
- boolean isPropagationEnabled = true;
+ boolean isPropagationEnabled = false;
- /** does this action accept propagated events ? Default is true. */
+ /** does this action accept propagated events ? Default is false. */
public boolean isPropagationEnabled() {
return isPropagationEnabled;
}
- /** does this action accept propagated events ? Default is true. */
+ /** does this action accept propagated events ? Default is false. */
public void setPropagationEnabled(boolean isPropagationEnabled) {
this.isPropagationEnabled = isPropagationEnabled;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -203,7 +203,7 @@
}
this.state = STATE_ACTIVE;
ExecutionImpl scopedExecution = initializeScopes();
- fire(Event.PROCESS_BEGIN, processDefinition);
+ fire(Event.START, processDefinition);
if (activity!=null) {
scopedExecution.performAtomicOperation(EXECUTE_ACTIVITY);
}
@@ -327,7 +327,7 @@
parent.removeExecution(this);
} else { // this is a process instance
- fire(Event.PROCESS_END, processDefinition);
+ fire(Event.END, processDefinition);
if (superProcessExecution!=null) {
log.trace(toString()+" signals super process execution");
superProcessExecution.signal();
@@ -549,13 +549,13 @@
if (activity.isLocalScope()) {
propagatingExecution = createScope(activity);
}
- fire(Event.NODE_BEGIN, activity);
+ fire(Event.START, activity);
return propagatingExecution;
}
public ExecutionImpl endActivity(ActivityImpl activity) {
ExecutionImpl propagatingExecution = this;
- fire(Event.NODE_END, activity);
+ fire(Event.END, activity);
if (activity.isLocalScope()) {
propagatingExecution = destroyScope(activity);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -163,7 +163,7 @@
// basic methods ////////////////////////////////////////////////////////////
public String toString() {
- return (name!=null ? "processDefinition("+name+")" : "processDefinition");
+ return (name!=null ? "process("+name+")" : "process");
}
// getters and setters //////////////////////////////////////////////////////
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -62,13 +62,13 @@
public EventImpl createEvent() {
EventImpl event = new EventImpl();
- event.setName(Event.TRANSITION_TAKE);
+ event.setName(Event.TAKE);
addEvent(event);
return event;
}
public EventImpl getEvent() {
- return getEvent(Event.TRANSITION_TAKE);
+ return getEvent(Event.TAKE);
}
// get parent ///////////////////////////////////////////////////////////////
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -58,7 +58,7 @@
}
propagatingExecution.setActivity(null);
- propagatingExecution.fire(Event.TRANSITION_TAKE, transition);
+ propagatingExecution.fire(Event.TAKE, transition);
boolean wait = false;
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -37,7 +37,7 @@
.startProcess()
.startActivity("a", new AutomaticActivity())
.initial()
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(new PrintLn("leaving a"))
.listener(new PrintLn("second message while leaving a"))
.endEvent()
@@ -46,7 +46,7 @@
.endFlow()
.endActivity()
.startActivity("b", new WaitState())
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(new PrintLn("entering b"))
.endEvent()
.endActivity()
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -47,12 +47,12 @@
testConsole = null;
}
- public void testEventPropagation() {
+ public void testEventPropagationEnabled() {
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
.startActivity("composite")
- .startEvent(Event.NODE_END)
- .listener(new DisplaySource())
+ .startEvent(Event.END)
+ .listener(new DisplaySource(), true)
.endEvent()
.startActivity("a", new WaitState())
.initial()
@@ -83,12 +83,12 @@
assertEquals(expectedLines, testConsole.lines);
}
- public void testEventPropagationDisabled() {
+ public void testEventPropagationDefaultDisabled() {
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
.startActivity("composite")
- .startEvent(Event.NODE_END)
- .listener(new DisplaySource(), false)
+ .startEvent(Event.END)
+ .listener(new DisplaySource())
.endEvent()
.startActivity("a", new WaitState())
.initial()
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -248,11 +248,11 @@
public void testEventsOnProcessDefinition() {
ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
.startProcess()
- .startEvent(Event.PROCESS_BEGIN)
+ .startEvent(Event.START)
.listener("one")
.listener("two")
.endEvent()
- .startEvent(Event.PROCESS_END)
+ .startEvent(Event.END)
.listener("three")
.listener("four")
.endEvent()
@@ -263,12 +263,12 @@
processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
- EventImpl event = processDefinition.getEvent(Event.PROCESS_BEGIN);
+ EventImpl event = processDefinition.getEvent(Event.START);
List<EventListenerReference> listenerReferences = event.getListenerReferences();
assertEquals("one", listenerReferences.get(0).getExpression());
assertEquals("two", listenerReferences.get(1).getExpression());
- event = processDefinition.getEvent(Event.PROCESS_END);
+ event = processDefinition.getEvent(Event.END);
listenerReferences = event.getListenerReferences();
assertEquals("three", listenerReferences.get(0).getExpression());
assertEquals("four", listenerReferences.get(1).getExpression());
@@ -279,11 +279,11 @@
.startProcess()
.startActivity("a")
.initial()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener("one")
.listener("two")
.endEvent()
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener("three")
.listener("four")
.endEvent()
@@ -292,12 +292,12 @@
processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
- EventImpl event = processDefinition.getActivity("a").getEvent(Event.NODE_BEGIN);
+ EventImpl event = processDefinition.getActivity("a").getEvent(Event.START);
List<EventListenerReference> listenerReferences = event.getListenerReferences();
assertEquals("one", listenerReferences.get(0).getExpression());
assertEquals("two", listenerReferences.get(1).getExpression());
- event = processDefinition.getActivity("a").getEvent(Event.NODE_END);
+ event = processDefinition.getActivity("a").getEvent(Event.END);
listenerReferences = event.getListenerReferences();
assertEquals("three", listenerReferences.get(0).getExpression());
assertEquals("four", listenerReferences.get(1).getExpression());
@@ -442,7 +442,7 @@
public void testEventDynamicProperties() {
ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
.startProcess()
- .startEvent(Event.PROCESS_BEGIN)
+ .startEvent(Event.START)
.property("key1", "val1")
.property("key2", "val2")
.endEvent()
@@ -453,7 +453,7 @@
processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
- EventImpl event = processDefinition.getEvent(Event.PROCESS_BEGIN);
+ EventImpl event = processDefinition.getEvent(Event.START);
assertEquals("val1", event.getProperty("key1"));
assertEquals("val2", event.getProperty("key2"));
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -25,15 +25,14 @@
import java.util.List;
import java.util.Map;
-import org.jbpm.activity.ActivityBehaviour;
import org.jbpm.activity.ActivityExecution;
import org.jbpm.activity.ExternalActivityBehaviour;
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.listener.EventListener;
import org.jbpm.listener.EventListenerExecution;
-import org.jbpm.model.Event;
import org.jbpm.model.Activity;
+import org.jbpm.model.Event;
import org.jbpm.model.ObservableElement;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.test.JbpmTestCase;
@@ -47,9 +46,8 @@
private static final long serialVersionUID = 1L;
public List<Object> events = new ArrayList<Object>();
public void notify(EventListenerExecution execution) {
- ObservableElement element = execution.getEventSource();
- String elementName = element.getName();
- events.add(execution.getEvent()+" on "+(elementName!=null ? elementName : element));
+ ObservableElement eventSource = execution.getEventSource();
+ events.add(execution.getEvent()+" on "+eventSource);
}
}
@@ -63,28 +61,13 @@
}
}
- public static class AutomaticActivity implements ActivityBehaviour {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
- }
- }
-
- public static class WaitState implements ExternalActivityBehaviour {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
- execution.waitForSignal();
- }
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
- }
- }
-
public void testListenToActivityLeaveOnProcessForProcessActivities(){
Recorder recorder = new Recorder();
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.NODE_END)
- .listener(recorder)
+ .startEvent(Event.END)
+ .listener(recorder, true)
.endEvent()
.startActivity("initial", new WaitState())
.initial()
@@ -97,7 +80,7 @@
ClientExecution execution = processDefinition.startProcessInstance();
execution.signal();
- assertEquals("event(activity-end) on initial", recorder.events.get(0));
+ assertEquals("event(end) on activity(initial)", recorder.events.get(0));
assertEquals(1, recorder.events.size());
}
@@ -106,8 +89,8 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.NODE_BEGIN)
- .listener(recorder)
+ .startEvent(Event.START)
+ .listener(recorder, true)
.endEvent()
.startActivity("initial", new WaitState())
.initial()
@@ -120,8 +103,9 @@
ClientExecution execution = processDefinition.startProcessInstance();
execution.signal();
- assertEquals("event(activity-begin) on end", recorder.events.get(0));
- assertEquals(1, recorder.events.size());
+ assertEquals("event(start) on process(propagate)", recorder.events.get(0));
+ assertEquals("event(start) on activity(end)", recorder.events.get(1));
+ assertEquals(2, recorder.events.size());
}
public void testListenToTransitionOnProcessForTransitionBetweenProcessActivities(){
@@ -129,8 +113,8 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.TRANSITION_TAKE)
- .listener(recorder)
+ .startEvent(Event.TAKE)
+ .listener(recorder, true)
.endEvent()
.startActivity("initial", new WaitState())
.initial()
@@ -143,7 +127,7 @@
ClientExecution execution = processDefinition.startProcessInstance();
execution.signal();
- assertEquals("event(transition-take) on go", recorder.events.get(0));
+ assertEquals("event(take) on (initial)--go-->(end)", recorder.events.get(0));
assertEquals(1, recorder.events.size());
}
@@ -177,8 +161,8 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.NODE_END)
- .listener(recorder)
+ .startEvent(Event.END)
+ .listener(recorder, true)
.endEvent()
.startActivity("sequence", new Sequence())
.initial()
@@ -197,14 +181,15 @@
ClientExecution execution = processDefinition.startProcessInstance();
assertEquals(0, recorder.events.size());
execution.signal();
- assertEquals("event(activity-end) on one", recorder.events.get(0));
+ assertEquals("event(end) on activity(one)", recorder.events.get(0));
assertEquals(1, recorder.events.size());
execution.signal();
- assertEquals("event(activity-end) on two", recorder.events.get(1));
+ assertEquals("event(end) on activity(two)", recorder.events.get(1));
assertEquals(2, recorder.events.size());
execution.signal();
- assertEquals("event(activity-end) on three", recorder.events.get(2));
- assertEquals(3, recorder.events.size());
+ assertEquals("event(end) on activity(three)", recorder.events.get(2));
+ assertEquals("event(end) on process(propagate)", recorder.events.get(3));
+ assertEquals(recorder.events.toString(), 4, recorder.events.size());
}
public void testListenToActivityLeaveOnProcessForTransitionBetweenSequenceChildActivities(){
@@ -212,8 +197,8 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.NODE_END)
- .listener(recorder)
+ .startEvent(Event.END)
+ .listener(recorder, true)
.endEvent()
.startActivity("sequence", new Sequence())
.initial()
@@ -231,10 +216,10 @@
assertEquals(0, recorder.events.size());
execution.signal();
- assertEquals("event(activity-end) on one", recorder.events.get(0));
+ assertEquals("event(end) on activity(one)", recorder.events.get(0));
assertEquals(1, recorder.events.size());
execution.signal();
- assertEquals("event(activity-end) on two", recorder.events.get(1));
+ assertEquals("event(end) on activity(two)", recorder.events.get(1));
assertEquals(2, recorder.events.size());
}
@@ -244,8 +229,8 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.NODE_BEGIN)
- .listener(recorder)
+ .startEvent(Event.START)
+ .listener(recorder, true)
.endEvent()
.startActivity("sequence", new Sequence())
.initial()
@@ -262,14 +247,21 @@
.endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
- assertEquals("event(activity-begin) on one", recorder.events.get(0));
- assertEquals(1, recorder.events.size());
+
+ List<Object> expectedEvents = new ArrayList<Object>();
+ expectedEvents.add("event(start) on process(propagate)");
+ expectedEvents.add("event(start) on activity(one)");
+ assertEquals(expectedEvents, recorder.events);
+
execution.signal();
- assertEquals("event(activity-begin) on two", recorder.events.get(1));
- assertEquals(2, recorder.events.size());
+
+ expectedEvents.add("event(start) on activity(two)");
+ assertEquals(expectedEvents, recorder.events);
+
execution.signal();
- assertEquals("event(activity-begin) on three", recorder.events.get(2));
- assertEquals(3, recorder.events.size());
+
+ expectedEvents.add("event(start) on activity(three)");
+ assertEquals(expectedEvents, recorder.events);
}
public void testListenToTransitionTakeOnProcessForTransitionBetweenSequenceChildActivities(){
@@ -277,8 +269,8 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
- .startEvent(Event.TRANSITION_TAKE)
- .listener(recorder)
+ .startEvent(Event.TAKE)
+ .listener(recorder, true)
.endEvent()
.startActivity("sequence", new Sequence())
.initial()
@@ -296,7 +288,7 @@
assertEquals(0, recorder.events.size());
execution.signal();
- assertEquals("event(transition-take) on increment", recorder.events.get(0));
+ assertEquals("event(take) on (one)--increment-->(two)", recorder.events.get(0));
assertEquals(1, recorder.events.size());
}
@@ -310,24 +302,24 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
.startEvent("hello")
- .listener(processRecorder)
+ .listener(processRecorder, true)
.endEvent()
.startActivity("outer", new Sequence())
.initial()
.startEvent("hello")
- .listener(outerRecorder)
+ .listener(outerRecorder, true)
.endEvent()
.startActivity("middel", new Sequence())
.startEvent("hello")
- .listener(middelRecorder)
+ .listener(middelRecorder, true)
.endEvent()
.startActivity("inner", new Sequence())
.startEvent("hello")
- .listener(innerRecorder)
+ .listener(innerRecorder, true)
.endEvent()
.startActivity("nested state", new FireableState())
.startEvent("hello")
- .listener(nestedStateRecorder)
+ .listener(nestedStateRecorder, true)
.endEvent()
.endActivity()
.endActivity()
@@ -340,19 +332,19 @@
assertEquals(0, processRecorder.events.size());
execution.signal("hello");
- assertEquals("event(hello) on nested state", processRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", processRecorder.events.get(0));
assertEquals(1, processRecorder.events.size());
- assertEquals("event(hello) on nested state", outerRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", outerRecorder.events.get(0));
assertEquals(1, outerRecorder.events.size());
- assertEquals("event(hello) on nested state", middelRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", middelRecorder.events.get(0));
assertEquals(1, middelRecorder.events.size());
- assertEquals("event(hello) on nested state", innerRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", innerRecorder.events.get(0));
assertEquals(1, innerRecorder.events.size());
- assertEquals("event(hello) on nested state", nestedStateRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", nestedStateRecorder.events.get(0));
assertEquals(1, nestedStateRecorder.events.size());
}
@@ -366,20 +358,20 @@
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("propagate")
.startEvent("hello")
- .listener(processRecorder)
+ .listener(processRecorder, true)
.endEvent()
.startActivity("outer", new Sequence())
.initial()
.startEvent("hello")
- .listener(outerRecorder)
+ .listener(outerRecorder, true)
.endEvent()
.startActivity("middle", new Sequence())
.startEvent("hello")
- .listener(middleRecorder, false)
+ .listener(middleRecorder)
.endEvent()
.startActivity("inner", new Sequence())
.startEvent("hello")
- .listener(innerRecorder)
+ .listener(innerRecorder, true)
.endEvent()
.startActivity("nested state", new FireableState())
.startEvent("hello")
@@ -396,18 +388,18 @@
// the middle action should not be executed for an event that was propagated from the nested state
execution.signal("hello");
- assertEquals("event(hello) on nested state", processRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", processRecorder.events.get(0));
assertEquals(1, processRecorder.events.size());
- assertEquals("event(hello) on nested state", outerRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", outerRecorder.events.get(0));
assertEquals(1, outerRecorder.events.size());
assertEquals(0, middleRecorder.events.size());
- assertEquals("event(hello) on nested state", innerRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", innerRecorder.events.get(0));
assertEquals(1, innerRecorder.events.size());
- assertEquals("event(hello) on nested state", nestedStateRecorder.events.get(0));
+ assertEquals("event(hello) on activity(nested state)", nestedStateRecorder.events.get(0));
assertEquals(1, nestedStateRecorder.events.size());
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -52,23 +52,6 @@
*/
public class EventTest extends JbpmTestCase {
- public static class AutomaticActivity implements ActivityBehaviour {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
- }
- }
-
- public static class WaitState implements ExternalActivityBehaviour {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
- execution.waitForSignal();
- }
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
- execution.take(signalName);
- }
- }
-
-
// activity leave action ////////////////////////////////////////////////////////
public static class ActivityEndAction implements EventListener {
@@ -91,7 +74,7 @@
.startActivity("initial", new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(activityEndAction)
.endEvent()
.endActivity()
@@ -167,7 +150,7 @@
.flow("end")
.endActivity()
.startActivity("end", new WaitState())
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(activityBeginAction)
.endEvent()
.endActivity()
@@ -278,14 +261,14 @@
RecordingExecution execution = (RecordingExecution) processDefinition.startProcessInstance();
int index = 0;
- assertEquals("process-begin on processDefinition(basic)", execution.events.get(index));
+ assertEquals("start on process(basic)", execution.events.get(index));
index++;
- assertEquals("activity-end on activity(initial)", execution.events.get(index));
+ assertEquals("end on activity(initial)", execution.events.get(index));
index++;
- assertEquals("transition-take on (initial)-->(end)", execution.events.get(index));
+ assertEquals("take on (initial)-->(end)", execution.events.get(index));
index++;
- assertEquals("activity-begin on activity(end)", execution.events.get(index));
+ assertEquals("start on activity(end)", execution.events.get(index));
index++;
- assertEquals("process-end on processDefinition(basic)", execution.events.get(index));
+ assertEquals("end on process(basic)", execution.events.get(index));
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -73,7 +73,7 @@
.startActivity("initial", new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(new Batter())
.endEvent()
.endActivity()
@@ -97,7 +97,7 @@
.startActivity("initial", new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.startExceptionHandler(RuntimeException.class)
.listener(catcher)
.endExceptionHandler()
@@ -124,7 +124,7 @@
.startActivity("initial", new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(new Batter())
.startExceptionHandler(RuntimeException.class)
.listener(catcher)
@@ -151,7 +151,7 @@
.startActivity("initial",new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(new Batter())
.endEvent()
.endActivity()
@@ -185,7 +185,7 @@
.listener(catcher)
.endExceptionHandler()
.endEvent()
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(new Batter())
.endEvent()
.endActivity()
@@ -217,7 +217,7 @@
.startActivity("initial", new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.startExceptionHandler(NullPointerException.class)
.listener(catcher)
.endExceptionHandler()
@@ -255,7 +255,7 @@
.startActivity("initial", new WaitState())
.initial()
.flow("end")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.startExceptionHandler(RuntimeException.class)
.listener(rethrowingCatcher)
.endExceptionHandler()
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java 2009-01-21 19:21:34 UTC (rev 3699)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java 2009-01-22 10:56:09 UTC (rev 3700)
@@ -23,10 +23,7 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivityBehaviour;
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.listener.EventListener;
@@ -38,18 +35,8 @@
/**
* @author Tom Baeyens
*/
-public class TransitionEventsTest extends JbpmTestCase
-{
+public class TransitionEventsTest extends JbpmTestCase {
- public static class WaitState implements ExternalActivityBehaviour {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
- execution.waitForSignal();
- }
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
- }
- }
-
public class Recorder implements EventListener {
private static final long serialVersionUID = 1L;
public List<Object> events = new ArrayList<Object>();
@@ -75,48 +62,48 @@
*/
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess("leave a super state")
- .startEvent(Event.NODE_END)
+ .startProcess("p")
+ .startEvent(Event.END)
.listener(processListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(processListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(processListener)
.endEvent()
.startActivity("composite")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(compositeListener)
.endEvent()
.startActivity("inside", new WaitState())
.initial()
.flow("outside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(insideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(insideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(insideListener)
.endEvent()
.endActivity()
.endActivity()
.startActivity("outside", new WaitState())
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(outsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(outsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(outsideListener)
.endEvent()
.endActivity()
@@ -124,7 +111,9 @@
ClientExecution execution = processDefinition.startProcessInstance();
- assertEquals(0, processListener.events.size());
+ assertEquals("[event(start) on process(p)]",
+ processListener.events.toString());
+
assertEquals(0, outsideListener.events.size());
assertEquals(0, compositeListener.events.size());
assertEquals(0, insideListener.events.size());
@@ -133,20 +122,16 @@
execution.signal();
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(activity-end) on activity(composite), " +
- "event(transition-take) on (inside)-->(outside), " +
- "event(activity-begin) on activity(outside)]",
+ assertEquals("[event(start) on process(p)]",
processListener.events.toString());
-
- assertEquals("[event(activity-begin) on activity(outside)]",
+
+ assertEquals("[event(start) on activity(outside)]",
outsideListener.events.toString());
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(activity-end) on activity(composite)]",
+ assertEquals("[event(end) on activity(composite)]",
compositeListener.events.toString());
- assertEquals("[event(activity-end) on activity(inside)]",
+ assertEquals("[event(end) on activity(inside)]",
insideListener.events.toString());
}
@@ -166,47 +151,47 @@
*/
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess("enter a super state")
- .startEvent(Event.NODE_END)
+ .startProcess("p")
+ .startEvent(Event.END)
.listener(processListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(processListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(processListener)
.endEvent()
.startActivity("outside", new WaitState())
.initial()
.flow("inside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(outsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(outsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(outsideListener)
.endEvent()
.endActivity()
.startActivity("composite")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(compositeListener)
.endEvent()
.startActivity("inside", new WaitState())
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(insideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(insideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(insideListener)
.endEvent()
.endActivity()
@@ -215,27 +200,25 @@
ClientExecution execution = processDefinition.startProcessInstance();
- assertEquals(0, processListener.events.size());
+ assertEquals("[event(start) on process(p)]",
+ processListener.events.toString());
+
assertEquals(0, outsideListener.events.size());
assertEquals(0, compositeListener.events.size());
assertEquals(0, insideListener.events.size());
execution.signal();
- assertEquals("[event(activity-end) on activity(outside), " +
- "event(transition-take) on (outside)-->(inside), " +
- "event(activity-begin) on activity(composite), " +
- "event(activity-begin) on activity(inside)]",
+ assertEquals("[event(start) on process(p)]",
processListener.events.toString());
-
- assertEquals("[event(activity-end) on activity(outside)]",
+
+ assertEquals("[event(end) on activity(outside)]",
outsideListener.events.toString());
- assertEquals("[event(activity-begin) on activity(composite), " +
- "event(activity-begin) on activity(inside)]",
- compositeListener.events.toString());
+ assertEquals("[event(start) on activity(composite)]",
+ compositeListener.events.toString());
- assertEquals("[event(activity-begin) on activity(inside)]",
+ assertEquals("[event(start) on activity(inside)]",
insideListener.events.toString());
}
@@ -256,36 +239,36 @@
*/
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess("leave a super state")
- .startEvent(Event.NODE_END)
+ .startProcess("p")
+ .startEvent(Event.END)
.listener(processListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(processListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(processListener)
.endEvent()
.startActivity("composite")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(compositeListener)
.endEvent()
.startActivity("inside", new WaitState())
.initial()
.flow("inside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(insideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(insideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(insideListener)
.endEvent()
.endActivity()
@@ -294,7 +277,9 @@
ClientExecution execution = processDefinition.startProcessInstance();
- assertEquals(0, processListener.events.size());
+ assertEquals("[event(start) on process(p)]",
+ processListener.events.toString());
+
assertEquals(0, compositeListener.events.size());
assertEquals(0, insideListener.events.size());
@@ -302,22 +287,83 @@
execution.signal();
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(transition-take) on (inside)-->(inside), " +
- "event(activity-begin) on activity(inside)]",
+ assertEquals("[event(start) on process(p)]",
processListener.events.toString());
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(transition-take) on (inside)-->(inside), " +
- "event(activity-begin) on activity(inside)]",
- compositeListener.events.toString());
+ assertEquals(0, compositeListener.events.size());
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(activity-begin) on activity(inside)]",
+ assertEquals("[event(end) on activity(inside), " +
+ "event(start) on activity(inside)]",
insideListener.events.toString());
}
+ public void testPropagateSelfTransition(){
+ Recorder processListener = new Recorder();
+ Recorder compositeListener = new Recorder();
+ /*
+ +-----------------+
+ | composite |
+ | +--------+ |
+ | | inside |---+ |
+ | | | | |
+ | | |<--+ |
+ | +--------+ |
+ +-----------------+
+ */
+
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess("p")
+ .startEvent(Event.END)
+ .listener(processListener, true)
+ .endEvent()
+ .startEvent(Event.START)
+ .listener(processListener, true)
+ .endEvent()
+ .startEvent(Event.TAKE)
+ .listener(processListener, true)
+ .endEvent()
+ .startActivity("composite")
+ .startEvent(Event.END)
+ .listener(compositeListener, true)
+ .endEvent()
+ .startEvent(Event.START)
+ .listener(compositeListener, true)
+ .endEvent()
+ .startEvent(Event.TAKE)
+ .listener(compositeListener, true)
+ .endEvent()
+ .startActivity("inside", new WaitState())
+ .initial()
+ .flow("inside")
+ .endActivity()
+ .endActivity()
+ .endProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ assertEquals("[event(start) on process(p)]",
+ processListener.events.toString());
+
+ assertEquals(0, compositeListener.events.size());
+
+ assertEquals("inside", execution.getActivity().getName());
+
+ execution.signal();
+
+ assertEquals("[event(end) on activity(inside), " +
+ "event(take) on (inside)-->(inside), " +
+ "event(start) on activity(inside)]",
+ compositeListener.events.toString());
+
+ assertEquals("[event(start) on process(p), " +
+ "event(end) on activity(inside), " +
+ "event(take) on (inside)-->(inside), " +
+ "event(start) on activity(inside)]",
+ processListener.events.toString());
+ }
+
+
public void testCompositeLeaveInheritedTransition(){
Recorder processListener = new Recorder();
Recorder outsideListener = new Recorder();
@@ -334,48 +380,48 @@
*/
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess("leave a super state")
- .startEvent(Event.NODE_END)
+ .startProcess("p")
+ .startEvent(Event.END)
.listener(processListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(processListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(processListener)
.endEvent()
.startActivity("composite")
.flow("outside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(compositeListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(compositeListener)
.endEvent()
.startActivity("inside", new WaitState())
.initial()
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(insideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(insideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(insideListener)
.endEvent()
.endActivity()
.endActivity()
.startActivity("outside", new WaitState())
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(outsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(outsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(outsideListener)
.endEvent()
.endActivity()
@@ -383,7 +429,9 @@
ClientExecution execution = processDefinition.startProcessInstance();
- assertEquals(0, processListener.events.size());
+ assertEquals("[event(start) on process(p)]",
+ processListener.events.toString());
+
assertEquals(0, outsideListener.events.size());
assertEquals(0, compositeListener.events.size());
assertEquals(0, insideListener.events.size());
@@ -392,20 +440,16 @@
execution.signal();
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(activity-end) on activity(composite), " +
- "event(transition-take) on (composite)-->(outside), " +
- "event(activity-begin) on activity(outside)]",
+ assertEquals("[event(start) on process(p)]",
processListener.events.toString());
-
- assertEquals("[event(activity-begin) on activity(outside)]",
+
+ assertEquals("[event(start) on activity(outside)]",
outsideListener.events.toString());
- assertEquals("[event(activity-end) on activity(inside), " +
- "event(activity-end) on activity(composite)]",
+ assertEquals("[event(end) on activity(composite)]",
compositeListener.events.toString());
- assertEquals("[event(activity-end) on activity(inside)]",
+ assertEquals("[event(end) on activity(inside)]",
insideListener.events.toString());
}
@@ -430,69 +474,69 @@
*/
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess("leave a super state")
- .startEvent(Event.NODE_END)
+ .startProcess("p")
+ .startEvent(Event.END)
.listener(processListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(processListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(processListener)
.endEvent()
.startActivity("source outside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(sourceOutsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(sourceOutsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(sourceOutsideListener)
.endEvent()
.startActivity("source middle")
.flow("destination inside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(sourceMiddleListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(sourceMiddleListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(sourceMiddleListener)
.endEvent()
.startActivity("source inside", new WaitState())
.initial()
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(sourceInsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(sourceInsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(sourceInsideListener)
.endEvent()
.endActivity()
.endActivity()
.endActivity()
.startActivity("destination outside")
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(destinationOutsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(destinationOutsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(destinationOutsideListener)
.endEvent()
.startActivity("destination inside", new WaitState())
- .startEvent(Event.NODE_END)
+ .startEvent(Event.END)
.listener(destinationInsideListener)
.endEvent()
- .startEvent(Event.NODE_BEGIN)
+ .startEvent(Event.START)
.listener(destinationInsideListener)
.endEvent()
- .startEvent(Event.TRANSITION_TAKE)
+ .startEvent(Event.TAKE)
.listener(destinationInsideListener)
.endEvent()
.endActivity()
@@ -506,31 +550,22 @@
execution.signal();
- assertEquals("[event(activity-end) on activity(source inside), " +
- "event(activity-end) on activity(source middle), " +
- "event(activity-end) on activity(source outside), " +
- "event(transition-take) on (source middle)-->(destination inside), " +
- "event(activity-begin) on activity(destination outside), " +
- "event(activity-begin) on activity(destination inside)]",
+ assertEquals("[event(start) on process(p)]",
processListener.events.toString());
- assertEquals("[event(activity-end) on activity(source inside), " +
- "event(activity-end) on activity(source middle), " +
- "event(activity-end) on activity(source outside)]",
+ assertEquals("[event(end) on activity(source outside)]",
sourceOutsideListener.events.toString());
- assertEquals("[event(activity-end) on activity(source inside), " +
- "event(activity-end) on activity(source middle)]",
+ assertEquals("[event(end) on activity(source middle)]",
sourceMiddleListener.events.toString());
- assertEquals("[event(activity-end) on activity(source inside)]",
+ assertEquals("[event(end) on activity(source inside)]",
sourceInsideListener.events.toString());
- assertEquals("[event(activity-begin) on activity(destination outside), " +
- "event(activity-begin) on activity(destination inside)]",
+ assertEquals("[event(start) on activity(destination outside)]",
destinationOutsideListener.events.toString());
- assertEquals("[event(activity-begin) on activity(destination inside)]",
+ assertEquals("[event(start) on activity(destination inside)]",
destinationInsideListener.events.toString());
}
}
15 years, 3 months
JBoss JBPM SVN: r3699 - jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-21 14:21:34 -0500 (Wed, 21 Jan 2009)
New Revision: 3699
Modified:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
Log:
clean up custom objects saved in variables
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java 2009-01-21 19:18:15 UTC (rev 3698)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java 2009-01-21 19:21:34 UTC (rev 3699)
@@ -58,28 +58,26 @@
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
graphSession.saveProcessDefinition(processDefinition);
+ CustomLongClass customLongObject = null;
try {
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- // set the jbpmSession in the context because its used to determine the
- // jbpm-type for the custom object.
ContextInstance contextInstance = processInstance.getContextInstance();
-
// create the custom object
- CustomLongClass customLongObject = new CustomLongClass("customname");
+ customLongObject = new CustomLongClass("customname");
contextInstance.setVariable("custom hibernate object", customLongObject);
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
- // get the custom hibernatable object from the variableInstances
+ // get the custom hibernatable object from the variables
customLongObject = (CustomLongClass) contextInstance.getVariable("custom hibernate object");
assertNotNull(customLongObject);
assertEquals("customname", customLongObject.getName());
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
+ if (customLongObject != null) session.delete(customLongObject);
}
-
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java 2009-01-21 19:18:15 UTC (rev 3698)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java 2009-01-21 19:21:34 UTC (rev 3699)
@@ -58,27 +58,26 @@
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
graphSession.saveProcessDefinition(processDefinition);
+ CustomStringClass customStringObject = null;
try {
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- // set the jbpmSession in the context because its used to determine the
- // jbpm-type for the custom object.
ContextInstance contextInstance = processInstance.getContextInstance();
-
// create the custom object
- CustomStringClass customStringObject = new CustomStringClass("customname");
+ customStringObject = new CustomStringClass("customname");
contextInstance.setVariable("custom hibernate object", customStringObject);
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
- // get the custom hibernatable object from the variableInstances
+ // get the custom hibernatable object from the variables
customStringObject = (CustomStringClass) contextInstance.getVariable("custom hibernate object");
assertNotNull(customStringObject);
assertEquals("customname", customStringObject.getName());
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
+ if (customStringObject != null) session.delete(customStringObject);
}
}
}
15 years, 3 months
JBoss JBPM SVN: r3698 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/db.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-01-21 14:18:15 -0500 (Wed, 21 Jan 2009)
New Revision: 3698
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
Log:
prevent unnecessary invocation of JbpmSession
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -48,17 +48,17 @@
*/
public class GraphSession {
- JbpmSession jbpmSession = null;
- Session session = null;
+ final Session session;
+ final JbpmSession jbpmSession;
public GraphSession(JbpmSession jbpmSession) {
- this.jbpmSession = jbpmSession;
this.session = jbpmSession.getSession();
+ this.jbpmSession = jbpmSession;
}
public GraphSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
// process definitions //////////////////////////////////////////////////////
@@ -95,8 +95,7 @@
session.save(processDefinition);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't save process definition '" + processDefinition + "'", e);
}
}
@@ -111,8 +110,7 @@
return (ProcessDefinition) session.load(ProcessDefinition.class, new Long(processDefinitionId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process definition '" + processDefinitionId + "'", e);
}
}
@@ -127,8 +125,7 @@
return (ProcessDefinition) session.get(ProcessDefinition.class, new Long(processDefinitionId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process definition '" + processDefinitionId + "'", e);
}
}
@@ -145,8 +142,7 @@
processDefinition = (ProcessDefinition) query.uniqueResult();
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process definition with name '"
+ name
+ "' and version '"
@@ -168,8 +164,7 @@
processDefinition = (ProcessDefinition) query.uniqueResult();
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't find process definition '" + name + "'", e);
}
return processDefinition;
@@ -193,8 +188,7 @@
return result;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't find latest versions of process definitions", e);
}
}
@@ -215,8 +209,7 @@
return CollectionUtil.checkList(query.list(), ProcessDefinition.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't find all process definitions", e);
}
}
@@ -260,8 +253,7 @@
session.delete(processDefinition);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't delete process definition '"
+ processDefinition.getId()
+ "'", e);
@@ -305,8 +297,7 @@
return processInstance;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instance '" + processInstanceId + "'", e);
}
}
@@ -322,8 +313,7 @@
return processInstance;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process instance '" + processInstanceId + "'", e);
}
}
@@ -340,8 +330,7 @@
return token;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load token '" + tokenId + "'", e);
}
}
@@ -357,8 +346,7 @@
return token;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get token '" + tokenId + "'", e);
}
}
@@ -378,8 +366,7 @@
session.lock(processInstance, LockMode.UPGRADE);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't lock process instance '" + processInstance.getId() + "'", e);
}
}
@@ -395,8 +382,7 @@
return CollectionUtil.checkList(query.list(), ProcessInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instances for process definition '"
+ processDefinitionId
+ "'", e);
@@ -466,8 +452,7 @@
session.delete(processInstance);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't delete process instance '" + processInstance.getId() + "'",
e);
}
@@ -590,8 +575,7 @@
return results;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instances for process definition '"
+ processDefinitionId
+ "'", e);
@@ -605,8 +589,7 @@
return CollectionUtil.checkList(query.list(), Node.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't active nodes for process instance '"
+ processInstance
+ "'", e);
@@ -622,8 +605,7 @@
processInstance = (ProcessInstance) query.uniqueResult();
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process instance with key '" + key + "'", e);
}
return processInstance;
@@ -641,12 +623,17 @@
}
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instance with key '" + key + "'", e);
}
return processInstance;
}
+ private void handle(Exception e) {
+ log.error(e);
+ if (jbpmSession != null)
+ jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(GraphSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -41,7 +41,7 @@
public class JobSession {
- private Session session;
+ private final Session session;
public JobSession(Session session) {
this.session = session;
@@ -155,15 +155,6 @@
return CollectionUtil.checkList(criteria.list(), Job.class);
}
- private static Long[] toObjectArray(long[] array) {
- final int length = array.length;
- Long[] objects = new Long[length];
- for (int i = 0; i < length; i++) {
- objects[i] = array[i];
- }
- return objects;
- }
-
public Job getJob(long jobId) {
try {
return (Job) session.get(Job.class, new Long(jobId));
@@ -231,5 +222,14 @@
return CollectionUtil.checkList(query.list(), Job.class);
}
+ private static Long[] toObjectArray(long[] array) {
+ final int length = array.length;
+ Long[] objects = new Long[length];
+ for (int i = 0; i < length; i++) {
+ objects[i] = array[i];
+ }
+ return objects;
+ }
+
private static Log log = LogFactory.getLog(JobSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -37,17 +37,17 @@
public class LoggingSession {
- JbpmSession jbpmSession;
- Session session;
+ final Session session;
+ final JbpmSession jbpmSession;
public LoggingSession(JbpmSession jbpmSession) {
+ this.session = jbpmSession.getSession();
this.jbpmSession = jbpmSession;
- this.session = jbpmSession.getSession();
}
public LoggingSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
/**
@@ -68,8 +68,7 @@
collectTokenLogs(tokenLogs, processInstance.getRootToken());
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get logs for " + processInstance, e);
}
return tokenLogs;
@@ -102,8 +101,7 @@
return CollectionUtil.checkList(query.list(), ProcessLog.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get logs for " + token, e);
}
}
@@ -116,8 +114,7 @@
session.save(processLog);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't save process log '" + processLog + "'", e);
}
}
@@ -131,8 +128,7 @@
processLog = (ProcessLog) session.load(ProcessLog.class, new Long(processLogId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process log '" + processLogId + "'", e);
}
return processLog;
@@ -147,12 +143,17 @@
processLog = (ProcessLog) session.get(ProcessLog.class, new Long(processLogId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process log '" + processLogId + "'", e);
}
return processLog;
}
+ private void handle(Exception exception) {
+ log.error(exception);
+ if (jbpmSession != null)
+ jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(LoggingSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -39,17 +39,17 @@
private static final long serialVersionUID = 1L;
- JbpmSession jbpmSession = null;
- Session session = null;
+ final Session session;
+ final JbpmSession jbpmSession;
public TaskMgmtSession(JbpmSession jbpmSession) {
- this.jbpmSession = jbpmSession;
this.session = jbpmSession.getSession();
+ this.jbpmSession = jbpmSession;
}
public TaskMgmtSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
/**
@@ -62,8 +62,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances list for actor '" + actorId + "'", e);
}
}
@@ -81,8 +80,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances list for actors '" + actorIds + "'", e);
}
}
@@ -105,8 +103,7 @@
return findTaskInstancesByIds(taskInstanceIds);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException(
"couldn't get pooled task instances list for actor '" + actorId + "'", e);
}
@@ -123,8 +120,7 @@
return findTaskInstancesByIds(taskInstanceIds);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get pooled task instances list for actors '"
+ actorIds
+ "'", e);
@@ -141,8 +137,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances by token '" + tokenId + "'", e);
}
}
@@ -157,8 +152,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances by process instance '"
+ processInstance
+ "'", e);
@@ -174,8 +168,7 @@
taskInstance = (TaskInstance) session.load(TaskInstance.class, new Long(taskInstanceId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instance '" + taskInstanceId + "'", e);
}
return taskInstance;
@@ -190,8 +183,7 @@
taskInstance = (TaskInstance) session.get(TaskInstance.class, new Long(taskInstanceId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instance '" + taskInstanceId + "'", e);
}
return taskInstance;
@@ -209,13 +201,18 @@
result = CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances by ids '" + taskInstanceIds + "'", e);
}
}
return result;
}
+ private void handle(Exception exception) {
+ log.error(exception);
+ if (jbpmSession != null)
+ jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(TaskMgmtSession.class);
}
15 years, 3 months