JBoss JBPM SVN: r6869 - jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-16 01:45:19 -0500 (Thu, 16 Dec 2010)
New Revision: 6869
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
Log:
JBPM-2959 port forward job executor improvements devised while backporting dispatcher thread:
replace ExecutorService.submit() call with .execute(), the latter does not return a Future;
replace ArrayBlockingQueue with SynchronousQueue to avoid dispatching jobs which no executor is demanding
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java 2010-12-15 11:03:13 UTC (rev 6868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java 2010-12-16 06:45:19 UTC (rev 6869)
@@ -118,8 +118,8 @@
protected void submitAcquiredJobDbids(Collection<Long> jobDbids) {
log.debug("submitting jobs "+jobDbids);
- jobExecutor.getThreadPool().submit(
- new JobParcel(jobExecutor.getCommandExecutor(), jobDbids));
+ jobExecutor.getExecutorService().execute(new JobParcel(jobExecutor.getCommandExecutor(),
+ jobDbids));
log.trace("jobs "+jobDbids+" were submitted");
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java 2010-12-15 11:03:13 UTC (rev 6868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java 2010-12-16 06:45:19 UTC (rev 6869)
@@ -28,7 +28,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
@@ -67,7 +67,7 @@
private boolean isActive;
- private ExecutorService threadPool;
+ private ExecutorService executorService;
private DispatcherThread dispatcherThread;
private List<JobHistoryEntry> history = new ArrayList<JobHistoryEntry>();
@@ -83,11 +83,11 @@
isActive = true;
log.trace("starting thread pool for job executor '"+name+"'...");
- threadPool = new ThreadPoolExecutor(nbrOfThreads,
+ executorService = new ThreadPoolExecutor(nbrOfThreads,
nbrOfThreads,
0L,
TimeUnit.MILLISECONDS,
- new ArrayBlockingQueue<Runnable>(nbrOfThreads),
+ new SynchronousQueue<Runnable>(),
JobRejectionHandler.INSTANCE);
log.trace("starting dispatcher thread for job executor '"+name+"'...");
@@ -114,7 +114,7 @@
/** stops with join set to false.
* @see #stop(boolean) */
- public synchronized void stop() {
+ public void stop() {
stop(false);
}
@@ -126,14 +126,15 @@
* are in the middle of executing a job and they may finish after this method returned.
*/
public synchronized void stop(boolean join) {
- log.debug("stopping job executor");
if (isActive) {
isActive = false;
+
+ log.debug("stopping job executor");
dispatcherThread.deactivate(join);
- threadPool.shutdown();
+ executorService.shutdown();
if (join) {
try {
- threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+ executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
log.trace("joining "+getName()+" got interrupted");
}
@@ -151,7 +152,7 @@
}
}
- static String getHostName() {
+ private static String getHostName() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
@@ -159,8 +160,8 @@
}
}
- protected ExecutorService getThreadPool() {
- return threadPool;
+ protected ExecutorService getExecutorService() {
+ return executorService;
}
// getters //////////////////////////////////////////////////////////////////
13 years, 4 months
JBoss JBPM SVN: r6868 - jbpm3/branches/jbpm-3.2-soa/soa-distribution/post-patch.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2010-12-15 06:03:13 -0500 (Wed, 15 Dec 2010)
New Revision: 6868
Modified:
jbpm3/branches/jbpm-3.2-soa/soa-distribution/post-patch/overlay_hibernate_conf.xml
Log:
SOA-2656
We no longer need to add the hibernate.current_session_context_class in the
platform patch.
Modified: jbpm3/branches/jbpm-3.2-soa/soa-distribution/post-patch/overlay_hibernate_conf.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/soa-distribution/post-patch/overlay_hibernate_conf.xml 2010-12-14 06:07:50 UTC (rev 6867)
+++ jbpm3/branches/jbpm-3.2-soa/soa-distribution/post-patch/overlay_hibernate_conf.xml 2010-12-15 11:03:13 UTC (rev 6868)
@@ -27,8 +27,7 @@
<replace file="${module_base_dir}/target/work/jbpm-installed/config/hibernate.cfg.xml">
<replacetoken><![CDATA[JTA transaction properties (begin) ===]]></replacetoken>
<replacevalue><![CDATA[JTA transaction properties (begin) -->
- <property name="jta.UserTransaction">UserTransaction</property>
- <property name="hibernate.current_session_context_class">jta</property>]]></replacevalue>
+ <property name="jta.UserTransaction">UserTransaction</property>]]></replacevalue>
</replace>
</target>
13 years, 4 months
JBoss JBPM SVN: r6867 - in jbpm3/branches/jbpm-3.2-soa/core/src: test/java/org/jbpm and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-14 01:07:50 -0500 (Tue, 14 Dec 2010)
New Revision: 6867
Added:
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2984/
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2984/ConfigurationPropertyNameTest.java
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/PropertyInfo.java
Log:
JBPM-2984 restore PropertyInfo's binding property name isFoo to accessor method setFoo
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/PropertyInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/PropertyInfo.java 2010-12-14 04:58:10 UTC (rev 6866)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/PropertyInfo.java 2010-12-14 06:07:50 UTC (rev 6867)
@@ -41,8 +41,14 @@
// property name
if (propertyElement.hasAttribute("name")) {
String propertyName = propertyElement.getAttribute("name");
- setterMethodName = "set" + Character.toUpperCase(propertyName.charAt(0))
- + propertyName.substring(1);
+ if (propertyName.startsWith("is") && propertyName.length() >= 3
+ && Character.isUpperCase(propertyName.charAt(2))) {
+ setterMethodName = "set" + propertyName.substring(2);
+ }
+ else {
+ setterMethodName = "set" + Character.toUpperCase(propertyName.charAt(0))
+ + propertyName.substring(1);
+ }
}
// setter method
else if (propertyElement.hasAttribute("setter")) {
Added: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2984/ConfigurationPropertyNameTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2984/ConfigurationPropertyNameTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2984/ConfigurationPropertyNameTest.java 2010-12-14 06:07:50 UTC (rev 6867)
@@ -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.jbpm2984;
+
+import org.jbpm.AbstractJbpmTestCase;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory;
+
+/**
+ * JtaDbPersistenceServiceFactory backward incompatibility.
+ *
+ * @see <a href="https://issues.jboss.org/browse/JBPM-2984">JBPM-2984</a>
+ * @author Alejandro Guizar
+ */
+public class ConfigurationPropertyNameTest extends AbstractJbpmTestCase {
+
+ private JbpmConfiguration jbpmConfiguration;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context>"
+ + " <service name='persistence'>"
+ + " <factory>"
+ + " <bean class='"
+ + JtaDbPersistenceServiceFactory.class.getName()
+ + "'>"
+ + " <property name='isCurrentSessionEnabled'><false/></property>"
+ + " </bean>"
+ + " </factory>"
+ + " </service>"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
+ }
+
+ protected void tearDown() throws Exception {
+ jbpmConfiguration.close();
+ super.tearDown();
+ }
+
+ public void testConfigurationPropertyName() {
+ JtaDbPersistenceServiceFactory serviceFactory =
+ (JtaDbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory("persistence");
+ assertFalse("expected current session to be disabled",
+ serviceFactory.isCurrentSessionEnabled());
+ }
+}
13 years, 4 months
JBoss JBPM SVN: r6866 - jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-13 23:58:10 -0500 (Mon, 13 Dec 2010)
New Revision: 6866
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmConfiguration.java
Log:
JBPM-2919 release JbpmConfiguration thread-local stacks to avoid memory leak
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmConfiguration.java 2010-12-14 01:36:17 UTC (rev 6865)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmConfiguration.java 2010-12-14 04:58:10 UTC (rev 6866)
@@ -25,6 +25,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -240,20 +242,14 @@
private static ObjectFactory defaultObjectFactory;
private static final Map instances = new HashMap();
- private static final ThreadLocal threadLocalConfigurationStack = new ThreadLocalStack();
+ private static final ThreadLocal threadLocalConfigurationStack = new ThreadLocal();
private final ObjectFactory objectFactory;
private final String resourceName;
- private transient final ThreadLocal threadLocalContextStack = new ThreadLocalStack();
+ private transient final ThreadLocal threadLocalContextStack = new ThreadLocal();
private JobExecutor jobExecutor;
private volatile boolean isClosed;
- static class ThreadLocalStack extends ThreadLocal {
- protected Object initialValue() {
- return new ArrayList();
- }
- }
-
public JbpmConfiguration(ObjectFactory objectFactory) {
this(objectFactory, null);
}
@@ -425,13 +421,11 @@
}
private DbPersistenceServiceFactory getPersistenceServiceFactory(String jbpmContextName) {
- return (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE,
- jbpmContextName);
+ return (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
}
public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
- ProcessClassLoaderFactory factory =
- (ProcessClassLoaderFactory) Configs.getObject("process.class.loader.factory");
+ ProcessClassLoaderFactory factory = (ProcessClassLoaderFactory) Configs.getObject("process.class.loader.factory");
return factory.getProcessClassLoader(processDefinition);
}
@@ -538,9 +532,11 @@
}
// close remaining contexts
- List contextStack = getJbpmContextStack();
- if (!contextStack.isEmpty()) {
- log.warn("closing " + contextStack.size() + " open contexts;"
+ List contextStack = (List) threadLocalContextStack.get();
+ if (contextStack != null && !contextStack.isEmpty()) {
+ log.warn("closing "
+ + contextStack.size()
+ + " open contexts;"
+ " make sure to close JbpmContext after use");
// copy to array because JbpmContext.close() pops the context off the stack
@@ -581,14 +577,11 @@
}
static JbpmConfiguration getCurrentJbpmConfiguration() {
- List stack = getJbpmConfigurationStack();
- return stack.isEmpty() ? null : (JbpmConfiguration) stack.get(stack.size() - 1);
+ List stack = (List) threadLocalConfigurationStack.get();
+ return (stack == null || stack.isEmpty()) ? null
+ : (JbpmConfiguration) stack.get(stack.size() - 1);
}
- private static List getJbpmConfigurationStack() {
- return (List) threadLocalConfigurationStack.get();
- }
-
static void clearInstances() {
synchronized (instances) {
instances.clear();
@@ -598,29 +591,63 @@
public JbpmContext getCurrentJbpmContext() {
ensureOpen();
- List stack = getJbpmContextStack();
- return stack.isEmpty() ? null : (JbpmContext) stack.get(stack.size() - 1);
+ List stack = (List) threadLocalContextStack.get();
+ return (stack == null || stack.isEmpty()) ? null
+ : (JbpmContext) stack.get(stack.size() - 1);
}
- private List getJbpmContextStack() {
- return (List) threadLocalContextStack.get();
- }
-
void pushJbpmContext(JbpmContext jbpmContext) {
// first push the configuration
- getJbpmConfigurationStack().add(this);
+ List configStack = (List) threadLocalConfigurationStack.get();
+ if (configStack == null) {
+ configStack = new ArrayList();
+ threadLocalConfigurationStack.set(configStack);
+ }
+ configStack.add(this);
// then push the context
- getJbpmContextStack().add(jbpmContext);
+ List contextStack = (List) threadLocalContextStack.get();
+ if (contextStack == null) {
+ contextStack = new ArrayList();
+ threadLocalContextStack.set(contextStack);
+ }
+ contextStack.add(jbpmContext);
}
+ private static void remove(ThreadLocal threadLocal) {
+ try {
+ // ThreadLocal.remove does not exist in JDK 1.4.2
+ // invoke via reflection if available
+ Method removeMethod = ThreadLocal.class.getMethod("remove", null);
+ try {
+ removeMethod.invoke(threadLocal, null);
+ }
+ catch (IllegalAccessException e) {
+ // method should be public, otherwise Class.getMethod would not return it
+ throw new JbpmException(JbpmConfiguration.class + " has no access to " + removeMethod);
+ }
+ catch (InvocationTargetException e) {
+ // if remove method threw an exception, rethrow to client
+ Throwable cause = e.getCause();
+ if (cause instanceof RuntimeException) throw (RuntimeException) cause;
+ if (cause instanceof Error) throw (Error) cause;
+ throw new JbpmException(removeMethod + " threw exception", cause);
+ }
+ }
+ catch (NoSuchMethodException e) {
+ // method unavailable; just set thread local to null
+ // this will still leak the ThreadLocal itself but not the value
+ threadLocal.set(null);
+ }
+ }
+
void popJbpmContext(JbpmContext jbpmContext) {
boolean threadSafetyFlag = false;
boolean creationOrderFlag = false;
// first pop the context
- List contextStack = getJbpmContextStack();
- int contextIndex = contextStack.lastIndexOf(jbpmContext);
- if (contextIndex == -1) {
+ List contextStack = (List) threadLocalContextStack.get();
+ int contextIndex;
+ if (contextStack == null || (contextIndex = contextStack.lastIndexOf(jbpmContext)) == -1) {
threadSafetyFlag = true;
}
else {
@@ -629,12 +656,14 @@
}
// prevent context from remaining in the stack, no matter what
contextStack.remove(contextIndex);
+ // if context stack gets empty, remove thread-local variable
+ if (contextStack.isEmpty()) remove(threadLocalContextStack);
}
// then pop the configuration
- List configStack = getJbpmConfigurationStack();
- int configIndex = configStack.lastIndexOf(this);
- if (configIndex == -1) {
+ List configStack = (List) threadLocalConfigurationStack.get();
+ int configIndex;
+ if (configStack == null || (configIndex = configStack.lastIndexOf(this)) == -1) {
threadSafetyFlag = true;
}
else {
@@ -643,14 +672,18 @@
}
// prevent configuration from remaining in the stack, no matter what
configStack.remove(configIndex);
+ // if configuration stack gets empty, remove thread-local variable
+ if (configStack.isEmpty()) remove(threadLocalConfigurationStack);
}
if (threadSafetyFlag) {
- log.warn(jbpmContext + " was not closed in the thread that created it;"
+ log.warn(jbpmContext
+ + " was not closed in the thread that created it;"
+ " JbpmContext is not safe for access from multiple threads!");
}
else if (creationOrderFlag) {
- log.warn(jbpmContext + " was not closed in a block-structured manner;"
+ log.warn(jbpmContext
+ + " was not closed in a block-structured manner;"
+ " check try-finally clauses around JbpmContext blocks");
}
}
13 years, 4 months
JBoss JBPM SVN: r6865 - jbpm3/branches/jbpm-3.2-soa/ci.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-13 20:36:17 -0500 (Mon, 13 Dec 2010)
New Revision: 6865
Modified:
jbpm3/branches/jbpm-3.2-soa/ci/container.sh
Log:
pass connect-timeout option to curl in container script to avoid hang when server http port is already bound
Modified: jbpm3/branches/jbpm-3.2-soa/ci/container.sh
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/ci/container.sh 2010-12-14 01:31:35 UTC (rev 6864)
+++ jbpm3/branches/jbpm-3.2-soa/ci/container.sh 2010-12-14 01:36:17 UTC (rev 6865)
@@ -188,7 +188,7 @@
# Was it successfully started?
for (( TRY=1 ; ; TRY++ )); do
- curl --head --fail http://$MYTESTIP_1:8080/jbpm-console
+ curl --head --connect-timeout 5 --fail http://$MYTESTIP_1:8080/jbpm-console
if [ $? -eq 0 ]; then
break
elif [ $TRY -lt 5 ]; then
@@ -206,4 +206,3 @@
# Stop JBoss AS
$JBOSS_HOME/bin/shutdown.sh -s jnp://$MYTESTIP_1:1099 -S
-
13 years, 4 months
JBoss JBPM SVN: r6864 - in jbpm3/branches/jbpm-3.2-soa/core/src/main: java/org/jbpm/module/def and 5 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-13 20:31:35 -0500 (Mon, 13 Dec 2010)
New Revision: 6864
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Action.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Node.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/ProcessDefinition.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Transition.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/Comment.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/RuntimeAction.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/node/TaskNode.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/logging/log/ProcessLog.hbm.xml
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml
Log:
JBPM-2031 review bidirectional associations; define one end as inverse or disable inserts and updates, where needed
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java 2010-12-14 01:31:35 UTC (rev 6864)
@@ -510,7 +510,7 @@
}
if (definitions == null) definitions = new HashMap();
- definitions.put(moduleDefinition.getClass().getName(), moduleDefinition);
+ definitions.put(moduleDefinition.getName(), moduleDefinition);
moduleDefinition.setProcessDefinition(this);
return moduleDefinition;
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java 2010-12-14 01:31:35 UTC (rev 6864)
@@ -29,7 +29,7 @@
public abstract class ModuleDefinition implements Serializable {
long id;
- protected String name; // name equals fully qualified class name
+ protected String name = getClass().getName();
protected ProcessDefinition processDefinition;
private static final long serialVersionUID = 1L;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Action.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Action.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Action.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -30,14 +30,15 @@
cascade="all"
foreign-key="FK_ACTION_ACTNDEL"
index="IDX_ACTION_ACTNDL" />
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="event"
column="EVENT_"
foreign-key="FK_ACTION_EVENT"
- index="IDX_ACTION_EVENT" />
+ index="IDX_ACTION_EVENT"
+ insert="false" update="false" />
<many-to-one name="processDefinition"
column="PROCESSDEFINITION_"
foreign-key="FK_ACTION_PROCDEF"
index="IDX_ACTION_PROCDF" />
-
</class>
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Node.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Node.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Node.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -9,7 +9,7 @@
discriminator-value="N">
<id name="id" column="ID_"><generator class="native" /></id>
<discriminator type="char" column="CLASS_"/>
- <!-- KEEP THIS IN SYNC WITH Event.hbm.xml, ExceptionHandler.hbm.xml and RuntimeAction.bhm.xml !!! -->
+ <!-- KEEP THIS IN SYNC WITH Event.hbm.xml, ExceptionHandler.hbm.xml and RuntimeAction.hbm.xml !!! -->
<!-- NOTE that the characters may not overlap with other GraphElement identifiers -->
<!-- C : org.jbpm.graph.node.ProcessState -->
<!-- D : org.jbpm.graph.node.Decision -->
@@ -41,7 +41,7 @@
<one-to-many class="org.jbpm.graph.def.ExceptionHandler" />
</list>
<!-- ============ -->
-
+
<property name="isAsync" column="ISASYNC_"/>
<property name="isAsyncExclusive" column="ISASYNCEXCL_"/>
@@ -50,20 +50,21 @@
cascade="all"
foreign-key="FK_NODE_ACTION"
index="IDX_NODE_ACTION" />
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="superState"
column="SUPERSTATE_"
foreign-key="FK_NODE_SUPERSTATE"
- index="IDX_NODE_SUPRSTATE"/>
-
+ index="IDX_NODE_SUPRSTATE"
+ insert="false" update="false"/>
+
<list name="leavingTransitions" cascade="all">
<key column="FROM_" />
<list-index column="FROMINDEX_" />
<one-to-many class="org.jbpm.graph.def.Transition" />
</list>
- <set name="arrivingTransitions">
+ <set name="arrivingTransitions" inverse="true">
<key column="TO_" />
<one-to-many class="org.jbpm.graph.def.Transition" />
</set>
-
</class>
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/ProcessDefinition.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/ProcessDefinition.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/ProcessDefinition.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -52,11 +52,10 @@
<map-key column="NAME_" type="string"/>
<one-to-many class="org.jbpm.graph.def.Action" />
</map>
- <map name="definitions" cascade="all">
+ <map name="definitions" cascade="all" inverse="true">
<key column="PROCESSDEFINITION_" />
<map-key column="NAME_" type="string"/>
<one-to-many class="org.jbpm.module.def.ModuleDefinition" />
</map>
-
</class>
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Transition.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Transition.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/def/Transition.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -26,16 +26,17 @@
<one-to-many class="org.jbpm.graph.def.ExceptionHandler" />
</list>
<!-- ============ -->
-
+
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="from"
column="FROM_"
foreign-key="FK_TRANSITION_FROM"
- index="IDX_TRANSIT_FROM"/>
+ index="IDX_TRANSIT_FROM"
+ insert="false" update="false"/>
<many-to-one name="to"
column="TO_"
foreign-key="FK_TRANSITION_TO"
index="IDX_TRANSIT_TO"/>
<property name="condition" column="CONDITION_"/>
-
</class>
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/Comment.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/Comment.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/Comment.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -12,14 +12,17 @@
<property name="actorId" column="ACTORID_"/>
<property name="time" column="TIME_"/>
<property name="message" column="MESSAGE_" type="longstring" length="4000"/>
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="token"
column="TOKEN_"
foreign-key="FK_COMMENT_TOKEN"
- index="IDX_COMMENT_TOKEN"/>
+ index="IDX_COMMENT_TOKEN"
+ insert="false" update="false"/>
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="taskInstance"
column="TASKINSTANCE_"
foreign-key="FK_COMMENT_TSK"
- index="IDX_COMMENT_TSK"/>
-
+ index="IDX_COMMENT_TSK"
+ insert="false" update="false"/>
</class>
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/RuntimeAction.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/RuntimeAction.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/exe/RuntimeAction.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -10,7 +10,7 @@
<version name="version" column="VERSION_" />
<property name="eventType" column="EVENTTYPE_"/>
-
+
<any name="graphElement" id-type="long" meta-type="char">
<meta-value value="A" class="org.jbpm.taskmgmt.def.Task"/>
<meta-value value="C" class="org.jbpm.graph.node.ProcessState" />
@@ -29,14 +29,15 @@
<column name="GRAPHELEMENT_"/>
</any>
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="processInstance"
column="PROCESSINSTANCE_"
foreign-key="FK_RTACTN_PROCINST"
- index="IDX_RTACTN_PRCINST"/>
+ index="IDX_RTACTN_PRCINST"
+ insert="false" update="false"/>
<many-to-one name="action"
column="ACTION_"
foreign-key="FK_RTACTN_ACTION"
index="IDX_RTACTN_ACTION" />
-
</class>
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/node/TaskNode.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/node/TaskNode.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/graph/node/TaskNode.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -10,7 +10,7 @@
<property name="signal" column="SIGNAL_" />
<property name="createTasks" column="CREATETASKS_" />
<property name="endTasks" column="ENDTASKS_" />
- <set name="tasks" cascade="all">
+ <set name="tasks" cascade="all" inverse="true">
<key column="TASKNODE_" foreign-key="FK_TASK_TASKNODE" />
<one-to-many class="org.jbpm.taskmgmt.def.Task" />
</set>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/logging/log/ProcessLog.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/logging/log/ProcessLog.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/logging/log/ProcessLog.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -1,12 +1,10 @@
<?xml version="1.0"?>
-
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false" default-access="field">
-
- <class name="org.jbpm.logging.log.ProcessLog"
+ <class name="org.jbpm.logging.log.ProcessLog"
table="JBPM_LOG"
discriminator-value="P"
lazy="false">
@@ -41,19 +39,19 @@
<!-- 4 : org.jbpm.taskmgmt.log.SwimlaneLog -->
<!-- 5 : org.jbpm.taskmgmt.log.SwimlaneCreateLog -->
<!-- 6 : org.jbpm.taskmgmt.log.SwimlaneAssignLog -->
-
<discriminator type="char" column="CLASS_"/>
-
+
<property name="index" column="INDEX_" />
<property name="date" column="DATE_" />
- <many-to-one name="token"
- column="TOKEN_"
+ <many-to-one name="token"
+ column="TOKEN_"
foreign-key="FK_LOG_TOKEN"
index="IDX_LOG_TOKEN" />
- <many-to-one name="parent"
- column="PARENT_"
+ <!-- bidirectional, other side is indexed; make this side inverse -->
+ <many-to-one name="parent"
+ column="PARENT_"
foreign-key="FK_LOG_PARENT"
- index="IDX_LOG_PARENT" />
+ index="IDX_LOG_PARENT"
+ insert="false" update="false" />
</class>
-
</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml 2010-12-10 20:07:24 UTC (rev 6863)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/module/exe/ModuleInstance.hbm.xml 2010-12-14 01:31:35 UTC (rev 6864)
@@ -1,11 +1,9 @@
<?xml version="1.0"?>
-
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false" default-access="field">
-
<class name="org.jbpm.module.exe.ModuleInstance"
table="JBPM_MODULEINSTANCE"
abstract="true"
@@ -18,12 +16,12 @@
<!-- T : org.jbpm.taskmgmt.def.TaskMgmtDefinition -->
<discriminator type="char" column="CLASS_"/>
<version name="version" column="VERSION_" />
-
+
+ <!-- bidirectional, other side is indexed; make this side inverse -->
<many-to-one name="processInstance"
column="PROCESSINSTANCE_"
foreign-key="FK_MODINST_PRCINST"
- index="IDX_MODINST_PRINST"/>
-
+ index="IDX_MODINST_PRINST"
+ insert="false" update="false"/>
</class>
-
</hibernate-mapping>
13 years, 4 months
JBoss JBPM SVN: r6863 - jbpm3/branches/jbpm-3.2-soa/ci.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-10 15:07:24 -0500 (Fri, 10 Dec 2010)
New Revision: 6863
Modified:
jbpm3/branches/jbpm-3.2-soa/ci/container.sh
Log:
read jboss run configuration from container shell script to avoid OOMEs during integration test
Modified: jbpm3/branches/jbpm-3.2-soa/ci/container.sh
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/ci/container.sh 2010-12-07 03:15:04 UTC (rev 6862)
+++ jbpm3/branches/jbpm-3.2-soa/ci/container.sh 2010-12-10 20:07:24 UTC (rev 6863)
@@ -146,6 +146,14 @@
# BEGIN section taken from run.sh
+# Read an optional running configuration file
+if [ -z "$RUN_CONF" ]; then
+ RUN_CONF="$JBOSS_HOME/bin/run.conf"
+fi
+if [ -r "$RUN_CONF" ]; then
+ . "$RUN_CONF"
+fi
+
# Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
@@ -194,7 +202,8 @@
# Run enterprise test suite
mvn -f enterprise/pom.xml -s $MAVEN_SETTINGS -Djboss.bind.address=$MYTESTIP_1 \
- -Dsurefire.jvm.args=-Xmx256m integration-test | tee $WORKSPACE/tests.log
+ integration-test | tee $WORKSPACE/tests.log
# Stop JBoss AS
$JBOSS_HOME/bin/shutdown.sh -s jnp://$MYTESTIP_1:1099 -S
+
13 years, 4 months
JBoss JBPM SVN: r6862 - in jbpm3/branches/jbpm-3.2-soa: core/src/main/java/org/jbpm and 16 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-06 22:15:04 -0500 (Mon, 06 Dec 2010)
New Revision: 6862
Added:
jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm2983/
jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm2983/SaveOperationsDbTest.java
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/ContextInstance.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableContainer.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/PersistenceService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/save/HibernateSaveOperation.java
jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/pom.xml
jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java
jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java
jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java
jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
jbpm3/branches/jbpm-3.2-soa/pom.xml
Log:
JBPM-2983 check if transaction is active before performing save operations
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -590,7 +590,7 @@
/**
* gets the jdbc connection from the default configured persistence service.
*
- * @return the jdbc connectoin, or <code>null</code> if a nonstandard persistence service is
+ * @return the jdbc connection, or <code>null</code> if a nonstandard persistence service is
* configured.
*/
public Connection getConnection() {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/ContextInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/ContextInstance.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/ContextInstance.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -135,10 +135,9 @@
* the same as the {@link #addVariables(Map, Token)}, but it was added for more consistency.
*/
public void setVariables(Map variables, Token token) {
- // [JBPM-1778] Empty map variables on process creation is set as null
+ // [JBPM-1778] empty variable map is set as null on process creation
TokenVariableMap tokenVariableMap = getOrCreateTokenVariableMap(token);
- Iterator iter = variables.entrySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = variables.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
String name = (String) entry.getKey();
Object value = entry.getValue();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableContainer.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableContainer.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableContainer.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -50,7 +50,7 @@
setVariableLocally(name, value);
}
else {
- // so let's action to the parent token's TokenVariableMap
+ // propagate to parent variable container
parent.setVariable(name, value);
}
}
@@ -143,12 +143,11 @@
public void setVariableLocally(String name, Object value) {
if (name == null) {
- throw new JbpmException("name is null");
+ throw new IllegalArgumentException("variable name is null");
}
VariableInstance variableInstance = getVariableInstance(name);
- // if there is already a variable instance
- // and it does not support the new value
+ // if variable instance already exists and it does not support the new value
if (variableInstance != null && !variableInstance.supports(value)) {
// delete the old variable instance
if (log.isDebugEnabled()) {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -43,9 +43,9 @@
import org.jbpm.instantiation.UserCodeInterceptorConfig;
import org.jbpm.job.ExecuteActionJob;
import org.jbpm.msg.MessageService;
+import org.jbpm.persistence.PersistenceService;
import org.jbpm.persistence.db.DbPersistenceService;
import org.jbpm.signal.EventService;
-import org.jbpm.svc.Service;
import org.jbpm.util.ClassUtil;
public abstract class GraphElement implements Identifiable, Serializable {
@@ -387,11 +387,10 @@
// see https://jira.jboss.org/browse/JBPM-1775
JbpmContext jbpmContext = executionContext.getJbpmContext();
if (jbpmContext != null) {
- Service service = jbpmContext.getServices().getPersistenceService();
- if (service instanceof DbPersistenceService) {
- DbPersistenceService persistenceService = (DbPersistenceService) service;
- return persistenceService.isTransactionActive()
- || !persistenceService.isTransactionPresent();
+ PersistenceService persistenceService = jbpmContext.getServices().getPersistenceService();
+ if (persistenceService instanceof DbPersistenceService) {
+ DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
+ return dbPersistenceService.isTransactionActive();
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -131,12 +131,12 @@
this.rootToken = new Token(this);
this.key = key;
- // if this is created in the context of a persistent operation
- Services.assignId(this);
-
// create the optional definitions
addInitialModuleDefinitions(processDefinition);
+ // if this is created in the context of a persistent operation
+ Services.assignId(this);
+
// add the creation log
rootToken.addLog(new ProcessInstanceCreateLog());
@@ -148,9 +148,9 @@
}
public void addInitialContextVariables(Map variables) {
- ContextInstance contextInstance = getContextInstance();
- if ((contextInstance != null) && (variables != null)) {
- contextInstance.addVariables(variables);
+ if (variables != null) {
+ ContextInstance contextInstance = getContextInstance();
+ if (contextInstance != null) contextInstance.addVariables(variables);
}
}
@@ -158,21 +158,18 @@
Map definitions = processDefinition.getDefinitions();
// if the state-definition has optional definitions
if (definitions != null) {
- instances = new HashMap();
// loop over each optional definition
for (Iterator i = definitions.values().iterator(); i.hasNext();) {
ModuleDefinition definition = (ModuleDefinition) i.next();
// and create the corresponding optional instance
ModuleInstance instance = definition.createInstance();
- if (instance != null) {
- addInstance(instance);
- }
+ if (instance != null) addInstance(instance);
}
}
}
public void fireStartEvent(Node initialNode) {
- this.start = Clock.getCurrentTime();
+ start = Clock.getCurrentTime();
// fire the process start event
if (initialNode != null) {
@@ -187,69 +184,60 @@
// optional module instances ////////////////////////////////////////////////
/**
- * adds the given optional moduleinstance (bidirectional).
+ * adds the given optional module instance (bidirectional).
*/
public ModuleInstance addInstance(ModuleInstance moduleInstance) {
if (moduleInstance == null) {
throw new IllegalArgumentException("module instance is null");
}
- if (instances == null)
- instances = new HashMap();
+ if (instances == null) instances = new HashMap();
instances.put(moduleInstance.getClass().getName(), moduleInstance);
moduleInstance.setProcessInstance(this);
return moduleInstance;
}
/**
- * removes the given optional moduleinstance (bidirectional).
+ * removes the given optional module instance (bidirectional).
*/
public ModuleInstance removeInstance(ModuleInstance moduleInstance) {
if (moduleInstance == null) {
throw new IllegalArgumentException("module instance is null");
}
- ModuleInstance removedModuleInstance = null;
- if (instances != null) {
- removedModuleInstance = (ModuleInstance) instances.remove(moduleInstance.getClass()
- .getName());
- if (removedModuleInstance != null) {
- moduleInstance.setProcessInstance(null);
- }
+ if (instances != null && instances.remove(moduleInstance.getClass().getName()) != null) {
+ moduleInstance.setProcessInstance(null);
+ return moduleInstance;
}
- return removedModuleInstance;
+ return null;
}
/**
* looks up an optional module instance by its class.
*/
public ModuleInstance getInstance(Class moduleClass) {
- ModuleInstance moduleInstance = null;
String className = moduleClass.getName();
if (instances != null) {
- moduleInstance = (ModuleInstance) instances.get(className);
+ ModuleInstance moduleInstance = (ModuleInstance) instances.get(className);
+ if (moduleInstance != null) return moduleInstance;
}
+ // client requested a module instance that is not in the persistent map;
+ // assume the client wants a transient instance
+ if (transientInstances == null) transientInstances = new HashMap();
+ ModuleInstance moduleInstance = (ModuleInstance) transientInstances.get(className);
if (moduleInstance == null) {
- if (transientInstances == null)
- transientInstances = new HashMap();
-
- // client requested an instance that is not in the map of instances.
- // so we can safely assume that the client wants a transient instance
- moduleInstance = (ModuleInstance) transientInstances.get(className);
- if (moduleInstance == null) {
- try {
- moduleInstance = (ModuleInstance) moduleClass.newInstance();
- moduleInstance.setProcessInstance(this);
- }
- catch (InstantiationException e) {
- throw new JbpmException("failed to instantiate " + moduleClass, e);
- }
- catch (IllegalAccessException e) {
- throw new JbpmException(getClass() + " has no access to " + moduleClass, e);
- }
- transientInstances.put(className, moduleInstance);
+ try {
+ moduleInstance = (ModuleInstance) moduleClass.newInstance();
+ moduleInstance.setProcessInstance(this);
}
+ catch (InstantiationException e) {
+ throw new JbpmException("failed to instantiate " + moduleClass, e);
+ }
+ catch (IllegalAccessException e) {
+ throw new JbpmException(getClass() + " has no access to " + moduleClass, e);
+ }
+ transientInstances.put(className, moduleInstance);
}
return moduleInstance;
@@ -287,9 +275,7 @@
* @throws IllegalStateException if the token is not active.
*/
public void signal() {
- if (hasEnded()) {
- throw new IllegalStateException("token has ended");
- }
+ if (hasEnded()) throw new IllegalStateException("process instance has ended");
rootToken.signal();
}
@@ -300,9 +286,7 @@
* @throws IllegalStateException if the token is not active.
*/
public void signal(String transitionName) {
- if (hasEnded()) {
- throw new IllegalStateException("token has ended");
- }
+ if (hasEnded()) throw new IllegalStateException("process instance has ended");
rootToken.signal(transitionName);
}
@@ -313,9 +297,7 @@
* @throws IllegalStateException if the token is not active.
*/
public void signal(Transition transition) {
- if (hasEnded()) {
- throw new IllegalStateException("token has ended");
- }
+ if (hasEnded()) throw new IllegalStateException("process instance has ended");
rootToken.signal(transition);
}
@@ -324,8 +306,7 @@
*/
public void end() {
// if already ended, do nothing
- if (end != null)
- return;
+ if (end != null) return;
// record the end time
// the end time also indicates that this process instance has ended
@@ -340,10 +321,9 @@
// add the process instance end log
rootToken.addLog(new ProcessInstanceEndLog());
-
- //Fetch this higher, rather than doing the work twice.
+ // Fetch this higher, rather than doing the work twice.
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
-
+
// is this a sub-process?
if (superProcessToken != null && !superProcessToken.hasEnded()) {
// is message service available?
@@ -368,7 +348,7 @@
}
// cancel jobs associated to this process instance
-
+
// is there an active context?
if (jbpmContext != null) {
Services services = jbpmContext.getServices();
@@ -444,17 +424,14 @@
* removes a runtime action.
*/
public RuntimeAction removeRuntimeAction(RuntimeAction runtimeAction) {
- RuntimeAction removedRuntimeAction = null;
if (runtimeAction == null) {
throw new IllegalArgumentException("runtime action is null");
}
- if (runtimeActions != null) {
- if (runtimeActions.remove(runtimeAction)) {
- removedRuntimeAction = runtimeAction;
- runtimeAction.processInstance = null;
- }
+ if (runtimeActions != null && runtimeActions.remove(runtimeAction)) {
+ runtimeAction.processInstance = null;
+ return runtimeAction;
}
- return removedRuntimeAction;
+ return null;
}
/**
@@ -470,18 +447,14 @@
* tells if this process instance is still active or not.
*/
public boolean hasEnded() {
- return (end != null);
+ return end != null;
}
/**
* calculates if this process instance has still options to continue.
*/
public boolean isTerminatedImplicitly() {
- boolean isTerminatedImplicitly = true;
- if (end == null) {
- isTerminatedImplicitly = rootToken.isTerminatedImplicitly();
- }
- return isTerminatedImplicitly;
+ return !hasEnded() ? rootToken.isTerminatedImplicitly() : true;
}
/**
@@ -491,7 +464,7 @@
* @return the specified token or null if the token is not found.
*/
public Token findToken(String tokenPath) {
- return (rootToken != null ? rootToken.findToken(tokenPath) : null);
+ return rootToken != null ? rootToken.findToken(tokenPath) : null;
}
/**
@@ -505,9 +478,7 @@
}
void addCascadeProcessInstance(ProcessInstance cascadeProcessInstance) {
- if (cascadeProcessInstances == null) {
- cascadeProcessInstances = new ArrayList();
- }
+ if (cascadeProcessInstances == null) cascadeProcessInstances = new ArrayList();
cascadeProcessInstances.add(cascadeProcessInstance);
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -35,8 +35,8 @@
import org.jbpm.JbpmException;
import org.jbpm.file.def.FileDefinition;
import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.persistence.PersistenceService;
import org.jbpm.persistence.db.DbPersistenceService;
-import org.jbpm.svc.Service;
public class ProcessClassLoader extends ClassLoader {
@@ -119,12 +119,13 @@
// is there an active context?
JbpmContext jbpmContext = jbpmConfiguration.getCurrentJbpmContext();
if (jbpmContext != null) {
- // is a database persistence service present?
- Service service = jbpmContext.getServices().getPersistenceService();
- if (service instanceof DbPersistenceService) {
- // confirm transaction is still active before loading process definition
- DbPersistenceService persistenceService = (DbPersistenceService) service;
- if (persistenceService.isTransactionActive()) {
+ // check if transaction is still active before loading process definition
+ // https://jira.jboss.org/browse/JBPM-2918
+ PersistenceService persistenceService = jbpmContext.getServices()
+ .getPersistenceService();
+ if (persistenceService instanceof DbPersistenceService) {
+ DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
+ if (dbPersistenceService.isTransactionActive()) {
return persistenceService.getGraphSession()
.loadProcessDefinition(processDefinitionId);
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/logging/db/DbLoggingService.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -21,33 +21,37 @@
*/
package org.jbpm.logging.db;
-import org.hibernate.Session;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.logging.LoggingService;
import org.jbpm.logging.log.ProcessLog;
+import org.jbpm.persistence.PersistenceService;
+import org.jbpm.persistence.db.DbPersistenceService;
public class DbLoggingService implements LoggingService {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
- private final Session session;
+ private final PersistenceService persistenceService;
public DbLoggingService() {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext == null) {
- throw new JbpmException("no active jbpm context");
- }
- session = jbpmContext.getSession();
+ if (jbpmContext == null) throw new JbpmException("no active jbpm context");
+ persistenceService = jbpmContext.getServices().getPersistenceService();
}
public void log(ProcessLog processLog) {
- if (session != null) {
- // Improvement suggestions by Max :
- // db-level: use hilo based id strategy to avoid repetitive insert (dependent on db-lock)
- // session: use stateless session or at least different session
- // can we borrow connection safely. (open on top of another session)
- session.save(processLog);
+ // check if transaction is active before saving log
+ // https://jira.jboss.org/browse/JBPM-2983
+ if (persistenceService instanceof DbPersistenceService) {
+ DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
+ if (dbPersistenceService.isTransactionActive()) {
+ // Improvement suggestions:
+ // db-level: use hi-lo id strategy to avoid repetitive insert (dependent on db-lock)
+ // session: use stateless session or at least different session
+ // can we borrow connection safely? (open on top of another session)
+ dbPersistenceService.getSession().save(processLog);
+ }
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/PersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/PersistenceService.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/PersistenceService.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -42,10 +42,8 @@
/** @deprecated call {@link TxService#isRollbackOnly()} instead */
boolean isRollbackOnly();
-
/** @deprecated call {@link TxService#setRollbackOnly()} instead */
void setRollbackOnly();
-
/** @deprecated call {@link TxService#setRollbackOnly()} instead */
void setRollbackOnly(boolean isRollbackOnly);
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -185,10 +185,6 @@
return transaction != null && transaction.isActive();
}
- public boolean isTransactionPresent() {
- return transaction != null;
- }
-
protected boolean isTransactionManagedExternally() {
return !isTransactionEnabled;
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -32,8 +32,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Session;
import org.hibernate.engine.SessionFactoryImplementor;
+
import org.jbpm.JbpmException;
import org.jbpm.persistence.db.DbPersistenceService;
@@ -46,17 +46,14 @@
public JtaDbPersistenceService(JtaDbPersistenceServiceFactory persistenceServiceFactory) {
super(persistenceServiceFactory);
+ // if no transaction is underway, begin one
+ if (getTransactionStatus() == Status.STATUS_NO_TRANSACTION) beginTransaction();
}
public boolean isTransactionActive() {
return getTransactionStatus() == Status.STATUS_ACTIVE;
}
- public boolean isTransactionPresent() {
- int status = getTransactionStatus();
- return status != Status.STATUS_NO_TRANSACTION && status != Status.STATUS_UNKNOWN;
- }
-
protected boolean isTransactionManagedExternally() {
return userTransaction == null;
}
@@ -68,6 +65,7 @@
public void beginTransaction() {
try {
+ if (log.isDebugEnabled()) log.debug("beginning user transaction");
JtaDbPersistenceServiceFactory jtaFactory =
(JtaDbPersistenceServiceFactory) persistenceServiceFactory;
userTransaction = jtaFactory.getUserTransaction();
@@ -81,11 +79,6 @@
}
}
- public Session getSession() {
- if (!isTransactionPresent()) beginTransaction();
- return super.getSession();
- }
-
private int getTransactionStatus() {
try {
if (userTransaction != null) {
@@ -110,6 +103,7 @@
protected Exception commit() {
if (userTransaction != null) {
+ if (log.isDebugEnabled()) log.debug("committing user transaction");
try {
userTransaction.commit();
}
@@ -131,6 +125,7 @@
protected Exception rollback() {
if (userTransaction != null) {
+ if (log.isDebugEnabled()) log.debug("rolling back user transaction");
try {
userTransaction.rollback();
}
@@ -143,6 +138,7 @@
if (transactionManager == null) {
throw new JbpmException("cannot honor rollback request without transaction manager");
}
+ if (log.isDebugEnabled()) log.debug("marking external transaction for rollback");
try {
transactionManager.setRollbackOnly();
}
@@ -153,7 +149,6 @@
return null;
}
- /** @deprecated use !{@link #isTransactionManagedExternally()} instead */
public boolean isJtaTxCreated() {
return !isTransactionManagedExternally();
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -263,6 +263,7 @@
if (firstException != null) throw firstException;
}
+ /** @deprecated call {@link DbPersistenceService#isLockingException(Exception)} instead */
public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException) {
return DbPersistenceService.isLockingException(persistenceException);
}
@@ -270,7 +271,7 @@
/** assigns an identifier to the given object */
public static void assignId(Object object) {
PersistenceService service =
- (PersistenceService) Services.getCurrentService(SERVICENAME_PERSISTENCE, false);
+ (PersistenceService) getCurrentService(SERVICENAME_PERSISTENCE, false);
if (service != null) service.assignId(object);
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/save/HibernateSaveOperation.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/save/HibernateSaveOperation.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/save/HibernateSaveOperation.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -21,23 +21,24 @@
*/
package org.jbpm.svc.save;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Session;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.persistence.PersistenceService;
+import org.jbpm.persistence.db.DbPersistenceService;
public class HibernateSaveOperation implements SaveOperation {
private static final long serialVersionUID = 1L;
public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
- Session session = jbpmContext.getSession();
- if (session != null) {
- if (log.isDebugEnabled()) log.debug("saving " + processInstance);
- session.save(processInstance);
+ // check if transaction is active before saving process instance
+ // https://jira.jboss.org/browse/JBPM-2983
+ PersistenceService persistenceService = jbpmContext.getServices().getPersistenceService();
+ if (persistenceService instanceof DbPersistenceService) {
+ DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
+ if (dbPersistenceService.isTransactionActive()) {
+ dbPersistenceService.getSession().save(processInstance);
+ }
}
}
-
- private static final Log log = LogFactory.getLog(HibernateSaveOperation.class);
}
Modified: jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -31,7 +31,6 @@
import org.jbpm.ejb.impl.JobListenerBean;
import org.jbpm.svc.Service;
import org.jbpm.svc.ServiceFactory;
-import org.jbpm.svc.Services;
import org.jbpm.util.JndiUtil;
/**
Modified: jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -26,9 +26,7 @@
import java.util.Iterator;
import java.util.List;
-import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.naming.NamingException;
import org.apache.cactus.ServletTestCase;
import org.apache.commons.logging.Log;
@@ -57,11 +55,8 @@
protected CommandService commandService;
private List processDefinitions = new ArrayList();
-
private final Log log = LogFactory.getLog(getClass());
- private static Context environment;
-
protected AbstractEnterpriseTestCase() {
}
@@ -81,15 +76,15 @@
}
protected CommandService createCommandService() throws Exception {
- Object object = getEnvironment().lookup("ejb/CommandServiceBean");
- CommandService commandService;
+ Object bean = new InitialContext().lookup("java:comp/env/ejb/CommandServiceBean");
- if (object instanceof CommandService) {
+ CommandService commandService;
+ if (bean instanceof CommandService) {
// compatibility with EJB3 homeless beans
- commandService = (CommandService) object;
+ commandService = (CommandService) bean;
}
else {
- LocalCommandServiceHome home = (LocalCommandServiceHome) object;
+ LocalCommandServiceHome home = (LocalCommandServiceHome) bean;
commandService = home.create();
}
@@ -150,19 +145,6 @@
commandService.execute(new DeleteProcessDefinitionCommand(processDefinitionId));
}
- private static Context getEnvironment() throws NamingException {
- if (environment == null) {
- Context initial = new InitialContext();
- try {
- environment = (Context) initial.lookup("java:comp/env");
- }
- finally {
- initial.close();
- }
- }
- return environment;
- }
-
private static final class RetryCommandService implements CommandService {
private final CommandService delegate;
Modified: jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -8,8 +8,8 @@
import org.jbpm.graph.def.EventCallback;
/**
- * Use JMS instead of DBMS for storing jobs, so that each job is not taken by multiple job executor
- * threads.
+ * Use JMS instead of DBMS for storing jobs, so that each job is not taken by multiple job
+ * executor threads.
*
* @see <a href="https://jira.jboss.org/jira/browse/JBPM-1952">JBPM-1952</a>
* @author Alejandro Guizar
@@ -24,40 +24,40 @@
public void testStaleStateInAsyncFork() {
deployProcessDefinition("<process-definition name='jbpm1952'>"
- + " <event type='process-end'>"
- + " <action expression='#{eventCallback.processEnd}' />"
- + " </event>"
- + " <start-state>"
- + " <transition to='a' />"
- + " </start-state>"
- + " <node name='a' async='true'>"
- + " <transition to='b' />"
- + " </node>"
- + " <node name='b' async='true'>"
- + " <transition to='fork' />"
- + " </node>"
- + " <fork name='fork'>"
- + " <transition to='c1' name='to_c1'/>"
- + " <transition to='c2' name='to_c2'/>"
- + " <transition to='c3' name='to_c3'/>"
- + " </fork>"
- + " <node name='c1' async='true'>"
- + " <transition to='join' />"
- + " </node>"
- + " <node name='c2' async='true'>"
- + " <transition to='join' />"
- + " </node>"
- + " <node name='c3' async='true'>"
- + " <transition to='join' />"
- + " </node>"
- + " <join name='join' async='exclusive'>"
- + " <transition to='d' />"
- + " </join>"
- + " <node name='d' async='true'>"
- + " <transition to='end' />"
- + " </node>"
- + " <end-state name='end'/>"
- + "</process-definition>");
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}' />"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <node name='a' async='true'>"
+ + " <transition to='b' />"
+ + " </node>"
+ + " <node name='b' async='true'>"
+ + " <transition to='fork' />"
+ + " </node>"
+ + " <fork name='fork'>"
+ + " <transition to='c1' name='to_c1'/>"
+ + " <transition to='c2' name='to_c2'/>"
+ + " <transition to='c3' name='to_c3'/>"
+ + " </fork>"
+ + " <node name='c1' async='true'>"
+ + " <transition to='join' />"
+ + " </node>"
+ + " <node name='c2' async='true'>"
+ + " <transition to='join' />"
+ + " </node>"
+ + " <node name='c3' async='true'>"
+ + " <transition to='join' />"
+ + " </node>"
+ + " <join name='join' async='exclusive'>"
+ + " <transition to='d' />"
+ + " </join>"
+ + " <node name='d' async='true'>"
+ + " <transition to='end' />"
+ + " </node>"
+ + " <end-state name='end'/>"
+ + "</process-definition>");
long[] processInstanceIds = new long[PROCESS_EXECUTION_COUNT];
for (int i = 0; i < PROCESS_EXECUTION_COUNT; i++) {
Added: jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm2983/SaveOperationsDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm2983/SaveOperationsDbTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jbpm2983/SaveOperationsDbTest.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.jbpm2983;
+
+import javax.transaction.UserTransaction;
+
+import junit.framework.Test;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
+import org.jbpm.command.Command;
+import org.jbpm.command.CommandService;
+import org.jbpm.enterprise.AbstractEnterpriseTestCase;
+import org.jbpm.enterprise.IntegrationTestSetup;
+import org.jbpm.graph.def.DelegationException;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory;
+import org.jbpm.svc.Services;
+
+/**
+ * Check if transaction is active before performing save operations.
+ *
+ * @see <a href="https://jira.jboss.org/browse/JBPM-2983">JBPM-2983</a>
+ * @author Alejandro Guizar
+ */
+public class SaveOperationsDbTest extends AbstractEnterpriseTestCase {
+
+ public static Test suite() {
+ return new IntegrationTestSetup(SaveOperationsDbTest.class, "enterprise-test.war");
+ }
+
+ protected CommandService createCommandService() throws Exception {
+ return new CommandService() {
+ public Object execute(Command command) {
+ JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
+ UserTransaction tx = null;
+ try {
+ JtaDbPersistenceServiceFactory persistenceServiceFactory =
+ (JtaDbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ tx = persistenceServiceFactory.getUserTransaction();
+ tx.begin();
+
+ Object result = command.execute(jbpmContext);
+ tx.commit();
+ return result;
+ }
+ catch (Exception e) {
+ if (tx != null) {
+ try {
+ tx.rollback();
+ }
+ catch (Exception re) {
+ // ignore
+ }
+ }
+ throw e instanceof RuntimeException ? (RuntimeException) e : new JbpmException(e);
+ }
+ finally {
+ jbpmContext.close();
+ }
+ }
+ };
+ }
+
+ public void testSaveOperations() {
+ deployProcessDefinition("<?xml version='1.0'?>"
+ + "<process-definition name='jbpm2983'>"
+ + " <start-state name='start'>"
+ + " <transition to='midway' />"
+ + " </start-state>"
+ + " <state name='midway'>"
+ + " <transition to='end'>"
+ + " <script>"
+ + " throw new UnsupportedOperationException(\"you did not see me coming\");"
+ + " </script>"
+ + " </transition>"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+
+ ProcessInstance processInstance = startProcessInstance("jbpm2983");
+ try {
+ signalToken(processInstance.getRootToken().getId());
+ fail("expected exception");
+ }
+ catch (DelegationException e) {
+ assert e.getCause() instanceof UnsupportedOperationException : e.getCause();
+ }
+
+ long processInstanceId = processInstance.getId();
+ assertTrue("expected process instance " + processInstanceId + " to have ended",
+ !hasProcessInstanceEnded(processInstanceId));
+ }
+}
Modified: jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2010-12-07 03:15:04 UTC (rev 6862)
@@ -115,7 +115,7 @@
+ " <start-state name='start'>"
+ " <transition to='end'>"
+ " <script>"
- + " executionContext.getJbpmContext().getSessionFactory().getTransactionManager().setRollbackOnly();"
+ + " executionContext.jbpmContext.sessionFactory.transactionManager.setRollbackOnly();"
+ " throw new org.hibernate.TransactionException(\"transaction marked for rollback\");"
+ " </script>"
+ " </transition>"
Modified: jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/pom.xml 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/pom.xml 2010-12-07 03:15:04 UTC (rev 6862)
@@ -21,24 +21,14 @@
<version>3.2.10-SNAPSHOT</version>
</parent>
+ <properties>
+ <maven.compiler.source>1.5</maven.compiler.source>
+ <maven.compiler.target>1.5</maven.compiler.target>
+ </properties>
+
<build>
<plugins>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- </configuration>
- </plugin>
-
- <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
@@ -57,7 +47,7 @@
</plugin>
</plugins>
</build>
-
+
<dependencies>
<dependency>
<groupId>org.jbpm.jbpm3</groupId>
Modified: jbpm3/branches/jbpm-3.2-soa/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/pom.xml 2010-12-03 21:11:52 UTC (rev 6861)
+++ jbpm3/branches/jbpm-3.2-soa/pom.xml 2010-12-07 03:15:04 UTC (rev 6862)
@@ -33,16 +33,17 @@
<!-- Modules -->
<modules>
<module>core</module>
- <module>identity</module>
<module>enterprise</module>
<module>examples</module>
+ <module>identity</module>
<module>simulation</module>
+ <module>tomcat</module>
</modules>
<!-- Properties -->
<properties>
+ <maven.compiler.source>1.4</maven.compiler.source>
<maven.compiler.target>1.4</maven.compiler.target>
- <maven.compiler.source>1.4</maven.compiler.source>
<!-- Dependency versions -->
<cargo.version>1.0.3</cargo.version>
@@ -597,7 +598,6 @@
<jdk>[1.5,1.7)</jdk>
</activation>
<modules>
- <module>tomcat</module>
<module>enterprise-jee5</module>
</modules>
</profile>
13 years, 5 months
JBoss JBPM SVN: r6861 - in jbpm3/branches/jbpm-3.2-soa: core/src/main/java/org/jbpm/file/def and 15 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-03 16:11:52 -0500 (Fri, 03 Dec 2010)
New Revision: 6861
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/file/def/FileDefinition.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Action.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/Delegation.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/exe/ModuleInstance.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/msg/MessageService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/SecurityHelper.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/authentication/DefaultAuthenticationService.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/util/JndiUtil.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/persistence/db/MockSession.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/taskmgmt/exe/TaskAssignmentTest.java
jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java
Log:
JBPM-2981 factor out common code from mail delegation parse methods;
avoid writing xml directly, rely on dom4j instead
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/JbpmContext.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -42,6 +42,7 @@
import org.jbpm.graph.exe.Token;
import org.jbpm.persistence.PersistenceService;
import org.jbpm.persistence.db.DbPersistenceService;
+import org.jbpm.security.AuthenticationService;
import org.jbpm.svc.ServiceFactory;
import org.jbpm.svc.Services;
import org.jbpm.taskmgmt.exe.TaskInstance;
@@ -669,7 +670,8 @@
*/
public void setActorId(String actorId) {
ensureOpen();
- services.getAuthenticationService().setActorId(actorId);
+ AuthenticationService authService = services.getAuthenticationService();
+ if (authService != null) authService.setActorId(actorId);
}
public void addAutoSaveProcessInstance(ProcessInstance processInstance) {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/file/def/FileDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/file/def/FileDefinition.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/file/def/FileDefinition.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -36,10 +36,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jbpm.JbpmContext;
+import org.jbpm.JbpmConfiguration.Configs;
import org.jbpm.JbpmException;
import org.jbpm.bytes.ByteArray;
-import org.jbpm.configuration.ObjectFactory;
import org.jbpm.module.def.ModuleDefinition;
import org.jbpm.module.exe.ModuleInstance;
import org.jbpm.util.IoUtil;
@@ -49,13 +48,7 @@
private static final long serialVersionUID = 1L;
private static String getRootDir() {
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
- ObjectFactory objectFactory = jbpmContext.getObjectFactory();
- if (objectFactory.hasObject("jbpm.files.dir"))
- return (String) objectFactory.createObject("jbpm.files.dir");
- }
- return null;
+ return Configs.hasObject("jbpm.files.dir") ? Configs.getString("jbpm.files.dir") : null;
}
private String dir;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Action.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Action.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Action.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -21,7 +21,6 @@
*/
package org.jbpm.graph.def;
-import java.io.Serializable;
import java.util.Map;
import org.dom4j.Element;
@@ -33,7 +32,7 @@
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
-public class Action implements ActionHandler, Parsable, Serializable {
+public class Action implements ActionHandler, Parsable {
private static final long serialVersionUID = 1L;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/Delegation.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/Delegation.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/Delegation.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -21,10 +21,7 @@
*/
package org.jbpm.instantiation;
-import java.io.IOException;
import java.io.Serializable;
-import java.io.StringWriter;
-import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
@@ -33,15 +30,12 @@
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
-import org.dom4j.io.OutputFormat;
-import org.dom4j.io.XMLWriter;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.DelegationException;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
-import org.jbpm.jpdl.xml.Problem;
public class Delegation implements Parsable, Serializable {
@@ -87,32 +81,10 @@
configType = delegateElement.attributeValue("config-type");
if (delegateElement.hasContent()) {
- try {
- StringWriter stringWriter = new StringWriter();
- // configuration is saved to database, write in a compact format
- CompactXmlWriter xmlWriter = new CompactXmlWriter(stringWriter);
- xmlWriter.writeElementContent(delegateElement);
- xmlWriter.flush();
- configuration = stringWriter.toString();
- }
- catch (IOException e) {
- jpdlReader.addProblem(new Problem(Problem.LEVEL_WARNING,
- "failed to write configuration xml", e));
- }
+ configuration = jpdlReader.writeElementContent(delegateElement);
}
}
- private static class CompactXmlWriter extends XMLWriter {
-
- CompactXmlWriter(Writer writer) {
- super(writer, OutputFormat.createCompactFormat());
- }
-
- public void writeElementContent(Element element) throws IOException {
- super.writeElementContent(element);
- }
- }
-
public void write(Element element) {
element.addAttribute("class", className);
element.addAttribute("config-type", configType);
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -101,15 +101,13 @@
}
protected Element parseConfiguration(String configuration) {
- Element element = null;
try {
- element = DocumentHelper.parseText("<action>" + configuration + "</action>")
+ return DocumentHelper.parseText("<action>" + configuration + "</action>")
.getRootElement();
}
catch (DocumentException e) {
throw new JbpmException("failed to parse configuration", e);
}
- return element;
}
protected Object newInstance(Class clazz) {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -32,10 +34,13 @@
import org.dom4j.Document;
import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
import org.xml.sax.InputSource;
-import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmConfiguration.Configs;
import org.jbpm.JbpmException;
import org.jbpm.context.def.VariableAccess;
import org.jbpm.graph.action.ActionTypes;
@@ -72,14 +77,14 @@
protected Collection unresolvedTransitionDestinations = new ArrayList();
protected Collection unresolvedActionReferences = new ArrayList();
- /**
- * process definition as DOM tree, available after readProcessDefinition
- */
+ /** process document, available after {@link #readProcessDefinition()} */
protected Document document;
- /** for autonumbering anonymous timers. */
+ /** for auto-numbering anonymous timers. */
private int timerNumber;
+ private XMLWriter xmlWriter;
+
public JpdlXmlReader(InputSource inputSource) {
this.inputSource = inputSource;
}
@@ -129,7 +134,7 @@
// create a new definition
processDefinition = ProcessDefinition.createNewProcessDefinition();
- // initialize lists
+ // clear lists
problems.clear();
unresolvedTransitionDestinations.clear();
unresolvedActionReferences.clear();
@@ -137,35 +142,35 @@
try {
// parse the document into a dom tree
document = JpdlParser.parse(inputSource, this);
- Element root = document.getRootElement();
+ }
+ catch (DocumentException e) {
+ throw new JpdlException("failed to parse process document", e);
+ }
- // read the process name
- parseProcessDefinitionAttributes(root);
+ // read the process name
+ Element root = document.getRootElement();
+ parseProcessDefinitionAttributes(root);
- // get the process description
- String description = root.elementTextTrim("description");
- if (description != null) processDefinition.setDescription(description);
+ // get the process description
+ String description = root.elementTextTrim("description");
+ if (description != null) processDefinition.setDescription(description);
- // first pass: read most content
- readSwimlanes(root);
- readActions(root, null, null);
- readNodes(root, processDefinition);
- readEvents(root, processDefinition);
- readExceptionHandlers(root, processDefinition);
- readTasks(root, null);
+ // first pass: read most content
+ readSwimlanes(root);
+ readActions(root, null, null);
+ readNodes(root, processDefinition);
+ readEvents(root, processDefinition);
+ readExceptionHandlers(root, processDefinition);
+ readTasks(root, null);
- // second pass processing
- resolveTransitionDestinations();
- resolveActionReferences();
- verifySwimlaneAssignments();
+ // second pass processing
+ resolveTransitionDestinations();
+ resolveActionReferences();
+ verifySwimlaneAssignments();
- if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
- throw new JpdlException(problems);
- }
+ if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
+ throw new JpdlException(problems);
}
- catch (DocumentException e) {
- throw new JpdlException("failed to parse process document", e);
- }
return processDefinition;
}
@@ -180,7 +185,7 @@
Element swimlaneElement = (Element) iter.next();
String swimlaneName = swimlaneElement.attributeValue("name");
if (swimlaneName == null) {
- addWarning("there's a swimlane without a name");
+ addWarning("unnamed swimlane detected");
}
else {
Swimlane swimlane = new Swimlane(swimlaneName);
@@ -222,13 +227,12 @@
// check for duplicate start-states
if (node instanceof StartState && processDefinition.getStartState() != null) {
- addError("max one start-state allowed in a process");
+ addError("only one start-state is allowed");
}
else {
// read the common node parts of the element
readNode(nodeElement, node, nodeCollection);
-
- // let node parse its special configuration
+ // let node parse its specific configuration
node.read(nodeElement, this);
}
}
@@ -244,13 +248,8 @@
public void readTasks(Element element, TaskNode taskNode) {
List elements = element.elements("task");
- TaskMgmtDefinition tmd = (TaskMgmtDefinition) processDefinition.getDefinition(TaskMgmtDefinition.class);
if (elements.size() > 0) {
- if (tmd == null) {
- tmd = new TaskMgmtDefinition();
- }
- processDefinition.addDefinition(tmd);
-
+ TaskMgmtDefinition tmd = processDefinition.getTaskMgmtDefinition();
for (Iterator iter = elements.iterator(); iter.hasNext();) {
Element taskElement = (Element) iter.next();
readTask(taskElement, tmd, taskNode);
@@ -276,38 +275,27 @@
// get the task description
String description = taskElement.elementTextTrim("description");
- if (description != null) {
- task.setDescription(description);
- }
- else {
- task.setDescription(taskElement.attributeValue("description"));
- }
+ if (description == null) description = taskElement.attributeValue("description");
+ task.setDescription(description);
// get the condition
String condition = taskElement.elementTextTrim("condition");
- if (condition != null) {
- task.setCondition(condition);
- }
- else {
- task.setCondition(taskElement.attributeValue("condition"));
- }
+ if (condition == null) condition = taskElement.attributeValue("condition");
+ task.setCondition(condition);
// parse common subelements
readTaskTimers(taskElement, task);
readEvents(taskElement, task);
readExceptionHandlers(taskElement, task);
- // duedate
+ // due date
String duedateText = taskElement.attributeValue("duedate");
- if (duedateText == null) {
- duedateText = taskElement.attributeValue("dueDate");
- }
+ if (duedateText == null) duedateText = taskElement.attributeValue("dueDate");
task.setDueDate(duedateText);
+
// priority
String priorityText = taskElement.attributeValue("priority");
- if (priorityText != null) {
- task.setPriority(Task.parsePriority(priorityText));
- }
+ if (priorityText != null) task.setPriority(Task.parsePriority(priorityText));
// if this task is in the context of a taskNode, associate them
if (taskNode != null) taskNode.addTask(task);
@@ -356,17 +344,14 @@
// notify
String notificationsText = taskElement.attributeValue("notify");
if (readBoolean(notificationsText, false)) {
- String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN;
- Event event = task.getEvent(notificationEvent);
- if (event == null) {
- event = new Event(notificationEvent);
- task.addEvent(event);
- }
- Delegation delegation = createMailDelegation(notificationEvent, null, null, null, null);
+ // create mail action
+ Delegation delegation = createMailDelegation(Event.EVENTTYPE_TASK_ASSIGN);
Action action = new Action(delegation);
action.setProcessDefinition(processDefinition);
action.setName(task.getName());
- event.addAction(action);
+
+ // attach action to task assign event
+ addAction(task, Event.EVENTTYPE_TASK_ASSIGN, action);
}
// task controller
@@ -389,31 +374,34 @@
protected Delegation readAssignmentDelegation(Element assignmentElement) {
Delegation assignmentDelegation = new Delegation();
+ assignmentDelegation.setProcessDefinition(processDefinition);
+
String expression = assignmentElement.attributeValue("expression");
- String actorId = assignmentElement.attributeValue("actor-id");
- String pooledActors = assignmentElement.attributeValue("pooled-actors");
+ if (expression != null) {
+ // read assigment expression
+ Element config = DocumentHelper.createElement("expression");
+ config.setText(expression);
- if (expression != null) {
- assignmentDelegation.setProcessDefinition(processDefinition);
assignmentDelegation.setClassName("org.jbpm.identity.assignment.ExpressionAssignmentHandler");
- assignmentDelegation.setConfiguration("<expression>" + expression + "</expression>");
+ assignmentDelegation.setConfiguration(writeElement(config));
}
- else if (actorId != null || pooledActors != null) {
- assignmentDelegation.setProcessDefinition(processDefinition);
- assignmentDelegation.setClassName("org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
- String configuration = "";
- if (actorId != null) {
- configuration += "<actorId>" + actorId + "</actorId>";
+ else {
+ String actorId = assignmentElement.attributeValue("actor-id");
+ String pooledActors = assignmentElement.attributeValue("pooled-actors");
+ if (actorId != null || pooledActors != null) {
+ // read assignment actors
+ Element config = DocumentHelper.createElement("configuration");
+ if (actorId != null) config.addElement("actorId").setText(actorId);
+ if (pooledActors != null) config.addElement("pooledActors").setText(pooledActors);
+
+ assignmentDelegation.setClassName("org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
+ assignmentDelegation.setConfiguration(writeElementContent(config));
}
- if (pooledActors != null) {
- configuration += "<pooledActors>" + pooledActors + "</pooledActors>";
+ else {
+ // parse custom assignment handler
+ assignmentDelegation.read(assignmentElement, this);
}
- assignmentDelegation.setConfiguration(configuration);
}
- else {
- assignmentDelegation = new Delegation();
- assignmentDelegation.read(assignmentElement, this);
- }
return assignmentDelegation;
}
@@ -437,14 +425,16 @@
List variableAccesses = new ArrayList();
for (Iterator iter = element.elementIterator("variable"); iter.hasNext();) {
Element variableElement = (Element) iter.next();
-
+ // name
String variableName = variableElement.attributeValue("name");
if (variableName == null) {
addWarning("variable name not specified: " + variableElement.getPath());
}
+ // access
String access = variableElement.attributeValue("access", "read,write");
+ // mapped name
String mappedName = variableElement.attributeValue("mapped-name");
-
+ // variable access
variableAccesses.add(new VariableAccess(variableName, access, mappedName));
}
return variableAccesses;
@@ -477,9 +467,7 @@
// get the node description
String description = nodeElement.elementTextTrim("description");
- if (description != null) {
- node.setDescription(description);
- }
+ if (description != null) node.setDescription(description);
String asyncText = nodeElement.attributeValue("async");
if ("exclusive".equalsIgnoreCase(asyncText)) {
@@ -546,8 +534,8 @@
action = readSingleAction(timerElement);
}
else {
- Delegation delegation = createMailDelegation("task-reminder", null, null, null, null);
- action = new Action(delegation);
+ Delegation mailDelegation = createMailDelegation("task-reminder");
+ action = new Action(mailDelegation);
}
createTimerAction.setTimerAction(action);
addAction(task, Event.EVENTTYPE_TASK_CREATE, createTimerAction);
@@ -576,10 +564,10 @@
protected void readEvents(Element parentElement, GraphElement graphElement) {
for (Iterator iter = parentElement.elementIterator("event"); iter.hasNext();) {
Element eventElement = (Element) iter.next();
+ // register event of the defined type
String eventType = eventElement.attributeValue("type");
- if (!graphElement.hasEvent(eventType)) {
- graphElement.addEvent(new Event(eventType));
- }
+ if (!graphElement.hasEvent(eventType)) graphElement.addEvent(new Event(eventType));
+ // parse any actions associated to the event
readActions(eventElement, graphElement, eventType);
}
}
@@ -630,7 +618,7 @@
Action action = (Action) actionType.newInstance();
// read the common action parts of the element
readAction(actionElement, action);
- // let action parse its special configuration
+ // let action parse its specific configuration
action.read(actionElement, this);
return action;
}
@@ -717,12 +705,14 @@
* to override this method to read additional configuration properties)
*/
public Transition resolveTransitionDestination(Element transitionElement, Node node) {
+ String transitionName = transitionElement.attributeValue("name");
+
Transition transition = new Transition();
transition.setProcessDefinition(processDefinition);
-
- transition.setName(transitionElement.attributeValue("name"));
+ transition.setName(transitionName);
transition.setDescription(transitionElement.elementTextTrim("description"));
+ // read transition condition
String condition = transitionElement.attributeValue("condition");
if (condition == null) {
Element conditionElement = transitionElement.element("condition");
@@ -736,19 +726,21 @@
}
transition.setCondition(condition);
- // add the transition to the node
+ // register transition in origin
node.addLeavingTransition(transition);
- // set destinationNode of the transition
+ // register transition in destination
String toName = transitionElement.attributeValue("to");
if (toName == null) {
addWarning("node '" + node.getFullyQualifiedName()
+ "' has a transition without a 'to'-attribute");
}
else {
- Node to = ((NodeCollection) node.getParent()).findNode(toName);
+ NodeCollection parent = (NodeCollection) node.getParent();
+ Node to = parent.findNode(toName);
if (to == null) {
- addWarning("transition to '" + toName + "' from " + node + " cannot be resolved");
+ addWarning("failed to resolve destination '" + toName + "' of transition '"
+ + transitionName + "' leaving from " + node);
}
else {
to.addArrivingTransition(transition);
@@ -771,13 +763,14 @@
for (Iterator iter = unresolvedActionReferences.iterator(); iter.hasNext();) {
Object[] unresolvedActionReference = (Object[]) iter.next();
Element actionElement = (Element) unresolvedActionReference[0];
- Action action = (Action) unresolvedActionReference[1];
- String referencedActionName = actionElement.attributeValue("ref-name");
- Action referencedAction = processDefinition.getAction(referencedActionName);
- if (referencedAction == null) {
+ Action refAction = processDefinition.getAction(actionElement.attributeValue("ref-name"));
+ if (refAction == null) {
addWarning("referenced action not found: " + actionElement.getPath());
}
- action.setReferencedAction(referencedAction);
+ else {
+ Action action = (Action) unresolvedActionReference[1];
+ action.setReferencedAction(refAction);
+ }
}
}
@@ -786,12 +779,11 @@
TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
Map swimlanes;
if (taskMgmtDefinition != null && (swimlanes = taskMgmtDefinition.getSwimlanes()) != null) {
+ Task startTask = taskMgmtDefinition.getStartTask();
+ Swimlane startTaskSwimlane = startTask != null ? startTask.getSwimlane() : null;
+
for (Iterator iter = swimlanes.values().iterator(); iter.hasNext();) {
Swimlane swimlane = (Swimlane) iter.next();
-
- Task startTask = taskMgmtDefinition.getStartTask();
- Swimlane startTaskSwimlane = startTask != null ? startTask.getSwimlane() : null;
-
if (swimlane.getAssignmentDelegation() == null && swimlane != startTaskSwimlane) {
addWarning("swimlane '" + swimlane.getName() + "' does not have an assignment");
}
@@ -801,120 +793,129 @@
// mail delegations /////////////////////////////////////////////////////////
- /** @deprecated call {@link #readMailDelegation(Element)} instead */
- public Delegation createMailDelegation(String template, String actors, String to,
- String subject, String text) {
- StringBuffer config = new StringBuffer();
- if (template != null) {
- config.append("<template>");
- config.append(template);
- config.append("</template>");
+ private Delegation createMailDelegation(Element config) {
+ // read mail class name
+ String mailClassName;
+ if (Configs.hasObject("jbpm.mail.class.name")) {
+ mailClassName = Configs.getString("jbpm.mail.class.name");
}
- if (actors != null) {
- config.append("<actors>");
- config.append(actors);
- config.append("</actors>");
+ else {
+ mailClassName = Mail.class.getName();
}
- if (to != null) {
- config.append("<to>");
- config.append(to);
- config.append("</to>");
- }
- if (subject != null) {
- config.append("<subject>");
- config.append(subject);
- config.append("</subject>");
- }
- if (text != null) {
- config.append("<text>");
- config.append(text);
- config.append("</text>");
- }
- String mailClassName = Mail.class.getName();
- if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name")) {
- mailClassName = JbpmConfiguration.Configs.getString("jbpm.mail.class.name");
- }
- else if (JbpmConfiguration.Configs.hasObject("mail.class.name")) {
- mailClassName = JbpmConfiguration.Configs.getString("mail.class.name");
- }
-
Delegation delegation = new Delegation(mailClassName);
delegation.setProcessDefinition(processDefinition);
- delegation.setConfiguration(config.toString());
+ delegation.setConfiguration(writeElementContent(config));
return delegation;
}
+ private Delegation createMailDelegation(String template) {
+ Element config = DocumentHelper.createElement("config");
+ config.addElement("template").setText(template);
+ return createMailDelegation(config);
+ }
+
+ /** @deprecated call {@link #readMailDelegation(Element)} instead */
+ public Delegation createMailDelegation(String template, String actors, String to,
+ String subject, String text) {
+ Element config = DocumentHelper.createElement("config");
+ // template
+ if (template != null) config.addElement("template").setText(template);
+ // to - addresses
+ if (to != null) config.addElement("to").setText(to);
+ // to - actors
+ if (actors != null) config.addElement("actors").setText(actors);
+ // subject
+ if (subject != null) config.addElement("subject").setText(subject);
+ // text
+ if (text != null) config.addElement("text").setText(text);
+
+ return createMailDelegation(config);
+ }
+
public Delegation readMailDelegation(Element element) {
- StringBuffer config = new StringBuffer();
+ Element config = DocumentHelper.createElement("config");
// template
String template = element.attributeValue("template");
- if (template != null) {
- config.append("<template>").append(template).append("</template>");
- }
+ if (template != null) config.addElement("template").setText(template);
// to - addresses
String to = element.attributeValue("to");
- if (to != null) {
- config.append("<to>").append(to).append("</to>");
- }
+ if (to != null) config.addElement("to").setText(to);
// to - actors
String actors = element.attributeValue("actors");
- if (actors != null) {
- config.append("<actors>").append(actors).append("</actors>");
- }
+ if (actors != null) config.addElement("actors").setText(actors);
// cc - addresses
String cc = element.attributeValue("cc");
- if (cc != null) {
- config.append("<cc>").append(cc).append("</cc>");
- }
+ if (cc != null) config.addElement("cc").setText(cc);
// cc - actors
String ccActors = element.attributeValue("cc-actors");
- if (ccActors != null) {
- config.append("<ccActors>").append(ccActors).append("</ccActors>");
- }
+ if (ccActors != null) config.addElement("ccActors").setText(ccActors);
// bcc - addresses
- String bcc = element.attributeValue("cc");
- if (bcc != null) {
- config.append("<bcc>").append(bcc).append("</bcc>");
- }
+ String bcc = element.attributeValue("bcc");
+ if (bcc != null) config.addElement("bcc").setText(bcc);
// bcc - actors
String bccActors = element.attributeValue("bcc-actors");
- if (bccActors != null) {
- config.append("<bccActors>").append(bccActors).append("</bccActors>");
- }
+ if (bccActors != null) config.addElement("bccActors").setText("bcc-actors");
// subject
String subject = getProperty("subject", element);
- if (subject != null) {
- config.append("<subject>").append(subject).append("</subject>");
- }
+ if (subject != null) config.addElement("subject").setText(subject);
// text
String text = getProperty("text", element);
- if (text != null) {
- config.append("<text>").append(text).append("</text>");
+ if (text != null) config.addElement("text").setText(text);
+
+ return createMailDelegation(config);
+ }
+
+ public String getProperty(String property, Element element) {
+ String propertyAttribute = element.attributeValue(property);
+ if (propertyAttribute == null) {
+ Element propertyElement = element.element(property);
+ if (propertyElement != null) propertyAttribute = propertyElement.getText();
}
+ return propertyAttribute;
+ }
- String mailClassName;
- if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name")) {
- mailClassName = JbpmConfiguration.Configs.getString("jbpm.mail.class.name");
+ private XMLWriter getXmlWriter() {
+ if (xmlWriter == null) {
+ try {
+ // configuration is saved to database, write in a compact format
+ xmlWriter = new XMLWriter(OutputFormat.createCompactFormat());
+ }
+ catch (UnsupportedEncodingException e) {
+ // WTF?
+ throw new JbpmException("failed to create xml writer", e);
+ }
}
- else {
- mailClassName = Mail.class.getName();
+ return xmlWriter;
+ }
+
+ private String writeElement(Element element) {
+ StringWriter stringWriter = new StringWriter();
+ XMLWriter xmlWriter = getXmlWriter();
+ xmlWriter.setWriter(stringWriter);
+ try {
+ xmlWriter.write(element);
}
-
- Delegation delegation = new Delegation(mailClassName);
- delegation.setProcessDefinition(processDefinition);
- delegation.setConfiguration(config.toString());
- return delegation;
+ catch (IOException e) {
+ // cannot happen, writing to memory
+ addError("failed to write mail configuration", e);
+ }
+ return stringWriter.toString();
}
- public String getProperty(String property, Element element) {
- String value = element.attributeValue(property);
- if (value == null) {
- Element propertyElement = element.element(property);
- if (propertyElement != null) {
- value = propertyElement.getText();
+ public String writeElementContent(Element element) {
+ StringWriter stringWriter = new StringWriter();
+ XMLWriter xmlWriter = getXmlWriter();
+ xmlWriter.setWriter(stringWriter);
+ try {
+ for (Iterator i = element.content().iterator(); i.hasNext();) {
+ xmlWriter.write((org.dom4j.Node) i.next());
}
}
- return value;
+ catch (IOException e) {
+ // cannot happen, writing to memory
+ addError("failed to write mail configuration", e);
+ }
+ return stringWriter.toString().trim();
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -30,10 +30,10 @@
import java.util.List;
import java.util.Map;
+import org.dom4j.Branch;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
-import org.dom4j.Namespace;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
@@ -47,7 +47,6 @@
import org.jbpm.graph.node.ProcessFactory;
import org.jbpm.graph.node.StartState;
import org.jbpm.jpdl.JpdlException;
-import org.jbpm.util.IoUtil;
/**
* Class for writing process definitions to character streams.
@@ -58,12 +57,11 @@
*/
public class JpdlXmlWriter {
- static final String JPDL_NAMESPACE = "http://jbpm.org/3/jpdl";
- static final Namespace jbpmNamespace = new Namespace(null, JPDL_NAMESPACE);
+ private static final String JPDL_NAMESPACE = "urn:jbpm.org:jpdl-3.2";
- Writer writer = null;
- List problems = new ArrayList();
- boolean useNamespace = false;
+ private final Writer writer;
+ private final List problems = new ArrayList();
+ private boolean useNamespace;
public JpdlXmlWriter(Writer writer) {
if (writer == null) throw new JbpmException("writer is null");
@@ -71,7 +69,7 @@
}
public void addProblem(String msg) {
- problems.add(msg);
+ problems.add(new Problem(Problem.LEVEL_ERROR, msg));
}
public static String toString(ProcessDefinition processDefinition) {
@@ -85,77 +83,65 @@
this.useNamespace = useNamespace;
}
- //newElement.add( jbpmNamespace );
-
public void write(ProcessDefinition processDefinition) {
- problems = new ArrayList();
- if (processDefinition == null) throw new JbpmException("processDefinition is null");
+ if (processDefinition == null) throw new JbpmException("process definition is null");
+
+ problems.clear();
try {
// collect the actions of the process definition
- // we will remove each named event action and the remaining ones will be written
+ // we will remove each named event action and the remaining ones will be written
// on the process definition.
- // create a dom4j dom-tree for the process definition
Document document = createDomTree(processDefinition);
- // write the dom-tree to the given writer
- OutputFormat outputFormat = new OutputFormat(" ", true);
- // OutputFormat outputFormat = OutputFormat.createPrettyPrint();
- XMLWriter xmlWriter = new XMLWriter(writer, outputFormat);
+ // write the document using the given writer
+ XMLWriter xmlWriter = new XMLWriter(writer, OutputFormat.createPrettyPrint());
xmlWriter.write(document);
xmlWriter.flush();
- writer.flush();
}
catch (IOException e) {
- addProblem("couldn't write process definition xml: " + e.getMessage());
+ Problem problem = new Problem(Problem.LEVEL_ERROR, "could not write process definition", e);
+ problems.add(problem);
}
- if (problems.size() > 0) {
- throw new JpdlException(problems);
- }
+ if (problems.size() > 0) throw new JpdlException(problems);
}
private Document createDomTree(ProcessDefinition processDefinition) {
Document document = DocumentHelper.createDocument();
+ Element root = addElement(document, "process-definition");
- Element root;
- if (useNamespace)
- root = document.addElement("process-definition", jbpmNamespace.getURI());
- else
- root = document.addElement("process-definition");
- addAttribute(root, "name", processDefinition.getName());
+ String value = processDefinition.getName();
+ if (value != null) root.addAttribute("name", value);
// write the start-state
if (processDefinition.getStartState() != null) {
- writeComment(root, "START-STATE");
+ root.addComment("START-STATE");
writeStartNode(root, (StartState) processDefinition.getStartState());
}
// write the nodeMap
- if ((processDefinition.getNodes() != null) && (processDefinition.getNodes().size() > 0)) {
- writeComment(root, "NODES");
+ if (processDefinition.getNodes() != null && processDefinition.getNodes().size() > 0) {
+ root.addComment("NODES");
writeNodes(root, processDefinition.getNodes());
}
// write the process level actions
if (processDefinition.hasEvents()) {
- writeComment(root, "PROCESS-EVENTS");
+ root.addComment("PROCESS-EVENTS");
writeEvents(root, processDefinition);
}
if (processDefinition.hasActions()) {
- writeComment(root, "ACTIONS");
+ root.addComment("ACTIONS");
List namedProcessActions = getNamedProcessActions(processDefinition.getActions());
writeActions(root, namedProcessActions);
}
- root.addText(IoUtil.lineSeparator);
-
return document;
}
private List getNamedProcessActions(Map actions) {
List namedProcessActions = new ArrayList();
- Iterator iter = actions.values().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = actions.values().iterator(); iter.hasNext();) {
Action action = (Action) iter.next();
- if ((action.getEvent() == null) && (action.getName() != null)) {
+ if (action.getEvent() == null && action.getName() != null) {
namedProcessActions.add(action);
}
}
@@ -169,8 +155,7 @@
}
private void writeNodes(Element parentElement, Collection nodes) {
- Iterator iter = nodes.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = nodes.iterator(); iter.hasNext();) {
org.jbpm.graph.def.Node node = (org.jbpm.graph.def.Node) iter.next();
if (!(node instanceof StartState)) {
Element nodeElement = addElement(parentElement, ProcessFactory.getTypeName(node));
@@ -181,15 +166,15 @@
}
private void writeNode(Element element, org.jbpm.graph.def.Node node) {
- addAttribute(element, "name", node.getName());
+ String value = node.getName();
+ if (value != null) element.addAttribute("name", value);
writeTransitions(element, node);
writeEvents(element, node);
}
private void writeTransitions(Element element, org.jbpm.graph.def.Node node) {
if (node.getLeavingTransitionsMap() != null) {
- Iterator iter = node.getLeavingTransitionsList().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = node.getLeavingTransitionsList().iterator(); iter.hasNext();) {
Transition transition = (Transition) iter.next();
writeTransition(element.addElement("transition"), transition);
}
@@ -204,15 +189,14 @@
transitionElement.addAttribute("name", transition.getName());
}
Event transitionEvent = transition.getEvent(Event.EVENTTYPE_TRANSITION);
- if ((transitionEvent != null) && (transitionEvent.hasActions())) {
+ if (transitionEvent != null && transitionEvent.hasActions()) {
writeActions(transitionElement, transitionEvent.getActions());
}
}
private void writeEvents(Element element, GraphElement graphElement) {
if (graphElement.hasEvents()) {
- Iterator iter = graphElement.getEvents().values().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = graphElement.getEvents().values().iterator(); iter.hasNext();) {
Event event = (Event) iter.next();
writeEvent(element.addElement("event"), event);
}
@@ -222,8 +206,7 @@
private void writeEvent(Element eventElement, Event event) {
eventElement.addAttribute("type", event.getEventType());
if (event.hasActions()) {
- Iterator actionIter = event.getActions().iterator();
- while (actionIter.hasNext()) {
+ for (Iterator actionIter = event.getActions().iterator(); actionIter.hasNext();) {
Action action = (Action) actionIter.next();
writeAction(eventElement, action);
}
@@ -231,8 +214,7 @@
}
private void writeActions(Element parentElement, Collection actions) {
- Iterator actionIter = actions.iterator();
- while (actionIter.hasNext()) {
+ for (Iterator actionIter = actions.iterator(); actionIter.hasNext();) {
Action action = (Action) actionIter.next();
writeAction(parentElement, action);
}
@@ -253,25 +235,12 @@
action.write(actionElement);
}
- private void writeComment(Element element, String comment) {
- element.addText(IoUtil.lineSeparator);
- element.addComment(" " + comment + " ");
+ private Element addElement(Branch parent, String elementName) {
+ return useNamespace ? parent.addElement(elementName, JPDL_NAMESPACE)
+ : parent.addElement(elementName);
}
- private Element addElement(Element element, String elementName) {
- Element newElement = element.addElement(elementName);
- return newElement;
- }
-
- private void addAttribute(Element e, String attributeName, String value) {
- if (value != null) {
- e.addAttribute(attributeName, value);
- }
- }
-
private String getTypeName(Object o) {
return ProcessFactory.getTypeName((org.jbpm.graph.def.Node) o);
}
-
- // private static final Log log = LogFactory.getLog(JpdlXmlWriter.class);
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/exe/ModuleInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/exe/ModuleInstance.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/module/exe/ModuleInstance.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -23,9 +23,9 @@
import java.io.Serializable;
-import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.svc.Service;
+import org.jbpm.svc.Services;
public class ModuleInstance implements Serializable {
@@ -58,12 +58,7 @@
}
protected Service getService(String serviceName) {
- Service service = null;
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
- service = jbpmContext.getServices().getService(serviceName);
- }
- return service;
+ return Services.getCurrentService(serviceName, false);
}
// getters and setters //////////////////////////////////////////////////////
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/msg/MessageService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/msg/MessageService.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/msg/MessageService.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -21,12 +21,10 @@
*/
package org.jbpm.msg;
-import java.io.Serializable;
-
import org.jbpm.job.Job;
import org.jbpm.svc.Service;
-public interface MessageService extends Service, Serializable {
+public interface MessageService extends Service {
void send(Job job);
void close();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -50,11 +50,10 @@
import org.jbpm.db.TaskMgmtSession;
import org.jbpm.persistence.JbpmPersistenceException;
import org.jbpm.persistence.PersistenceService;
-import org.jbpm.svc.Service;
import org.jbpm.svc.Services;
import org.jbpm.tx.TxService;
-public class DbPersistenceService implements Service, PersistenceService {
+public class DbPersistenceService implements PersistenceService {
private static final long serialVersionUID = 1L;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/SecurityHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/SecurityHelper.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/SecurityHelper.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -23,40 +23,32 @@
import java.security.Permission;
-import org.jbpm.JbpmContext;
+import org.jbpm.svc.Services;
/**
- * provides helper methods to access the authentication and authorization
- * services.
+ * provides helper methods to access the authentication and authorization services.
*/
-public abstract class SecurityHelper {
-
+public class SecurityHelper {
+
+ private SecurityHelper() {
+ // hide default constructor to prevent instantiation
+ }
+
/**
- * helper method to look up the authenticated actorId in the current
- * jbpm context.
+ * helper method to look up the authenticated actorId in the current jbpm context.
*/
public static String getAuthenticatedActorId() {
- String actorId = null;
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext!=null) {
- AuthenticationService authenticationService = jbpmContext.getServices().getAuthenticationService();
- if (authenticationService!=null) {
- actorId = authenticationService.getActorId();
- }
- }
- return actorId;
+ AuthenticationService authService = (AuthenticationService)
+ Services.getCurrentService(Services.SERVICENAME_AUTHENTICATION, false);
+ return authService != null ? authService.getActorId() : null;
}
-
+
/**
* helper method to check the permissions of a jbpm secured operation.
*/
public static void checkPermission(Permission permission) {
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext!=null) {
- AuthorizationService authorizationService = jbpmContext.getServices().getAuthorizationService();
- if (authorizationService!=null) {
- authorizationService.checkPermission(permission);
- }
- }
+ AuthorizationService authService = (AuthorizationService)
+ Services.getCurrentService(Services.SERVICENAME_AUTHORIZATION, false);
+ if (authService != null) authService.checkPermission(permission);
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/authentication/DefaultAuthenticationService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/authentication/DefaultAuthenticationService.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/security/authentication/DefaultAuthenticationService.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -27,8 +27,8 @@
private static final long serialVersionUID = 1L;
- String actorId = null;
-
+ private String actorId;
+
public void setActorId(String actorId) {
this.actorId = actorId;
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/svc/Services.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -267,16 +267,11 @@
return DbPersistenceService.isLockingException(persistenceException);
}
+ /** assigns an identifier to the given object */
public static void assignId(Object object) {
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
- // assign id to the given object
- Services services = jbpmContext.getServices();
- if (services.hasService(Services.SERVICENAME_PERSISTENCE)) {
- PersistenceService persistenceService = services.getPersistenceService();
- persistenceService.assignId(object);
- }
- }
+ PersistenceService service =
+ (PersistenceService) Services.getCurrentService(SERVICENAME_PERSISTENCE, false);
+ if (service != null) service.assignId(object);
}
private static final Log log = LogFactory.getLog(Services.class);
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -21,7 +21,6 @@
*/
package org.jbpm.taskmgmt.exe;
-import java.io.Serializable;
import java.util.Set;
import org.jbpm.taskmgmt.def.Swimlane;
@@ -29,7 +28,7 @@
/**
* is a process role for a one process instance.
*/
-public class SwimlaneInstance implements Serializable, Assignable {
+public class SwimlaneInstance implements Assignable {
private static final long serialVersionUID = 1L;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/util/JndiUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/util/JndiUtil.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/util/JndiUtil.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -28,8 +28,7 @@
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
-import org.jbpm.JbpmContext;
-import org.jbpm.configuration.ObjectFactory;
+import org.jbpm.JbpmConfiguration.Configs;
public class JndiUtil {
@@ -47,17 +46,16 @@
}
private static Object lookup(String jndiName) throws NamingException {
- Properties jndiProperties = null;
- JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
- ObjectFactory objectFactory = jbpmContext.getObjectFactory();
- if (objectFactory.hasObject("resource.jndi.properties")) {
- String jndiResource = (String) objectFactory.createObject("resource.jndi.properties");
- jndiProperties = ClassLoaderUtil.getProperties(jndiResource);
- }
+ Context initialContext;
+ if (Configs.hasObject("resource.jndi.properties")) {
+ String resource = Configs.getString("resource.jndi.properties");
+ Properties properties = ClassLoaderUtil.getProperties(resource);
+ initialContext = new InitialContext(properties);
}
+ else {
+ initialContext = new InitialContext();
+ }
- Context initialContext = new InitialContext(jndiProperties);
try {
return initialContext.lookup(jndiName);
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -13,8 +13,8 @@
import org.jbpm.util.ClassLoaderUtil;
/**
- * Test case for ProcessClassLoader hierarchy and setting the ContextClassLoader
- * correctly. Relates to {@link ConfigurableClassLoadersTest}.
+ * Test case for ProcessClassLoader hierarchy and setting the ContextClassLoader correctly.
+ * Relates to {@link ConfigurableClassLoadersTest}.
*
* @author Tom Baeyens
* @author bernd.ruecker(a)camunda.com
@@ -52,9 +52,9 @@
}
/*
- * DOES NOT configure usage of the context classloader. So this tests the
- * default (backwards compatible) behaviour. so the classloading hierarchy of
- * DefaultLoadedAction should be ProcessClassloader -> jbpm-lib classloader
+ * DOES NOT configure usage of the context classloader. So this tests the default (backwards
+ * compatible) behaviour. so the classloading hierarchy of DefaultLoadedAction should be
+ * ProcessClassloader -> jbpm-lib classloader
*/
public void testDefaultClassLoader() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
@@ -93,13 +93,13 @@
}
}
- /*
- * configures usage of the context classloader so the classloading hierarchy
- * of ContextLoadedAction should be ProcessClassloader ->
- * TestContextClassLoader -> Thread.currentContextClassLoader
+ /**
+ * configures usage of the context class loader. the classloading hierarchy of
+ * ContextLoadedAction will be ProcessClassLoader -> TestClassLoader -> originalClassLoader
*/
public void testContextClassLoader() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context />"
+ " <string name='jbpm.class.loader' value='context' />"
+ "</jbpm-configuration>");
@@ -135,10 +135,9 @@
}
/*
- * a third test should set the testcontextClassLoader in the test and then let
- * the action throw an exception. Then it should be verified that the original
- * classloader is still restored correctly. Easiest is to start from a copy of
- * the testContextClassLoader
+ * a third test should set the testcontextClassLoader in the test and then let the action
+ * throw an exception. Then it should be verified that the original classloader is still
+ * restored correctly. Easiest is to start from a copy of the testContextClassLoader
*/
public static class ContextLoadedExceptionAction implements ActionHandler {
@@ -160,6 +159,7 @@
public void testContextClassLoaderException() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context />"
+ " <string name='jbpm.class.loader' value='context' />"
+ "</jbpm-configuration>");
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/persistence/db/MockSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/persistence/db/MockSession.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/persistence/db/MockSession.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -16,13 +16,12 @@
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.SQLQuery;
-import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.type.Type;
-public class MockSession implements Session, org.hibernate.classic.Session {
+public class MockSession implements org.hibernate.classic.Session {
private static final long serialVersionUID = 1L;
@@ -89,7 +88,7 @@
throw new UnsupportedOperationException();
}
- public Session getSession(EntityMode entityMode) {
+ public org.hibernate.Session getSession(EntityMode entityMode) {
throw new UnsupportedOperationException();
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/taskmgmt/exe/TaskAssignmentTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/taskmgmt/exe/TaskAssignmentTest.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/taskmgmt/exe/TaskAssignmentTest.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -35,12 +35,11 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.security.authentication.DefaultAuthenticationServiceFactory;
import org.jbpm.taskmgmt.def.AssignmentHandler;
public class TaskAssignmentTest extends AbstractJbpmTestCase {
- static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
-
public static class TestAssignmentHandler implements AssignmentHandler {
private static final long serialVersionUID = 1L;
public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
@@ -175,6 +174,15 @@
}
public void testStartTaskSwimlaneAssignmentTest() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context>" +
+ " <service name='authentication' factory='" +
+ DefaultAuthenticationServiceFactory.class.getName() +
+ "' />" +
+ " </jbpm-context>" +
+ "</jbpm-configuration>");
+
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition>" +
" <swimlane name='initiator' />" +
@@ -196,10 +204,10 @@
} finally {
jbpmContext.setActorId(null);
jbpmContext.close();
+ jbpmConfiguration.close();
}
SwimlaneInstance swimlaneInstance = taskMgmtInstance.getSwimlaneInstance("initiator");
- assertNotNull(swimlaneInstance);
assertEquals("user", swimlaneInstance.getActorId());
}
Modified: jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java 2010-12-03 17:32:13 UTC (rev 6860)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise/src/main/java/org/jbpm/msg/jms/JmsMessageServiceFactory.java 2010-12-03 21:11:52 UTC (rev 6861)
@@ -69,7 +69,6 @@
// set to current context
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
if (jbpmContext == null) throw new JbpmException("no active jbpm context");
- assert this == jbpmContext.getServiceFactory(Services.SERVICENAME_MESSAGE) : jbpmContext.getServiceFactory(Services.SERVICENAME_MESSAGE);
jbpmConfiguration = jbpmContext.getJbpmConfiguration();
}
return jbpmConfiguration;
13 years, 5 months
JBoss JBPM SVN: r6860 - in projects/jsf-console/branches/jsf-console-3.2-soa: gpd-deployer and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-03 12:32:13 -0500 (Fri, 03 Dec 2010)
New Revision: 6860
Modified:
projects/jsf-console/branches/jsf-console-3.2-soa/console/.project
projects/jsf-console/branches/jsf-console-3.2-soa/gpd-deployer/.project
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/.project
Log:
remove wst natures from web modules, they do not add value at this point
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/console/.project
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/console/.project 2010-12-03 01:42:02 UTC (rev 6859)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/console/.project 2010-12-03 17:32:13 UTC (rev 6860)
@@ -6,31 +6,18 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
- <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/gpd-deployer/.project
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/gpd-deployer/.project 2010-12-03 01:42:02 UTC (rev 6859)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/gpd-deployer/.project 2010-12-03 17:32:13 UTC (rev 6860)
@@ -6,31 +6,18 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
- <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/.project
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/.project 2010-12-03 01:42:02 UTC (rev 6859)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/.project 2010-12-03 17:32:13 UTC (rev 6860)
@@ -6,31 +6,18 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
- <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
13 years, 5 months