Author: alex.guizar(a)jboss.com
Date: 2010-04-13 04:02:00 -0400 (Tue, 13 Apr 2010)
New Revision: 6256
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmException.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/JbpmContextInfo.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/DelegationException.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Node.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/MailNode.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/ELException.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/svc/Services.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmContextTest.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceConfigurationDbTest.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceFactoryDbTest.java
Log:
flush and evict process instances while deleting process definition;
limit places where thrown exception is raised;
make package class members private
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -50,15 +50,14 @@
/**
* configuration of one jBPM instance.
* <p>
- * During process execution, jBPM might need to use some services. A
- * JbpmConfiguration contains the knowledge on how to create those services.
+ * During process execution, jBPM might need to use some services. A JbpmConfiguration
contains
+ * the knowledge on how to create those services.
* </p>
* <p>
* A JbpmConfiguration is a thread safe object and serves as a factory for
- * {@link org.jbpm.JbpmContext}s, which means one JbpmConfiguration can be used
- * to create {@link org.jbpm.JbpmContext}s for all threads. The single
- * JbpmConfiguration can be maintained in a static member or in the JNDI tree if
- * that is available.
+ * {@link org.jbpm.JbpmContext}s, which means one JbpmConfiguration can be used to
create
+ * {@link org.jbpm.JbpmContext}s for all threads. The single JbpmConfiguration can be
maintained
+ * in a static member or in the JNDI tree if that is available.
* </p>
* <p>
* A JbpmConfiguration can be obtained in following ways:
@@ -88,9 +87,9 @@
* </pre>
*
* </li>
- * <li>By specifying a custom implementation of an object factory. This can be
- * used to specify a JbpmConfiguration in other bean-style notations such as
- * used by JBoss Microcontainer or Spring.
+ * <li>By specifying a custom implementation of an object factory. This can be used
to specify a
+ * JbpmConfiguration in other bean-style notations such as used by JBoss Microcontainer
or
+ * Spring.
*
* <pre>
* ObjectFactory of = new <i>MyCustomObjectFactory</i>();
@@ -101,8 +100,8 @@
* </li>
* </ul>
* <p>
- * JbpmConfigurations can be configured using a spring-like XML notation (in
- * relax ng compact notation):
+ * JbpmConfigurations can be configured using a spring-like XML notation (in relax ng
compact
+ * notation):
* </p>
*
* <pre>
@@ -239,11 +238,11 @@
private static final long serialVersionUID = 1L;
- static ObjectFactory defaultObjectFactory;
- static final Map instances = new HashMap();
+ private static ObjectFactory defaultObjectFactory;
+ private static final Map instances = new HashMap();
private static final ThreadLocal jbpmConfigurationStacks = new StackThreadLocal();
- final ObjectFactory objectFactory;
+ private final ObjectFactory objectFactory;
private final String resourceName;
private JobExecutor jobExecutor;
private boolean isClosed;
@@ -256,15 +255,22 @@
}
public JbpmConfiguration(ObjectFactory objectFactory) {
- this.objectFactory = objectFactory;
- this.resourceName = null;
+ this(objectFactory, null);
}
- JbpmConfiguration(ObjectFactory objectFactory, String resourceName) {
+ private JbpmConfiguration(ObjectFactory objectFactory, String resourceName) {
this.objectFactory = objectFactory;
this.resourceName = resourceName;
}
+ ObjectFactory getObjectFactory() {
+ return objectFactory;
+ }
+
+ public static void setDefaultObjectFactory(ObjectFactory objectFactory) {
+ defaultObjectFactory = objectFactory;
+ }
+
public static JbpmConfiguration getInstance() {
return getInstance(null);
}
@@ -291,15 +297,15 @@
log.info("using configuration resource: " + resource);
InputStream jbpmCfgXmlStream = ClassLoaderUtil.getStream(resource, false);
/*
- * if a custom resource is specified, but not found in the classpath,
- * log a warning; otherwise, users who want to load custom stuff will
- * not receive any feedback when their resource cannot be found
+ * if a custom resource is specified, but not found in the classpath, log a
warning;
+ * otherwise, users who want to load custom stuff will not receive any feedback
when
+ * their resource cannot be found
*/
if (jbpmCfgXmlStream == null &&
!"jbpm.cfg.xml".equals(resource)) {
log.warn("configuration resource '" + resource + "'
was not found");
}
ObjectFactory objectFactory = parseObjectFactory(jbpmCfgXmlStream);
- instance = createJbpmConfiguration(objectFactory);
+ instance = createJbpmConfiguration(objectFactory, resource);
}
// put configuration in cache
instances.put(resource, instance);
@@ -337,7 +343,12 @@
}
protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory)
{
- JbpmConfiguration jbpmConfiguration = new JbpmConfiguration(objectFactory);
+ return createJbpmConfiguration(objectFactory, null);
+ }
+
+ private static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory,
+ String resourceName) {
+ JbpmConfiguration jbpmConfiguration = new JbpmConfiguration(objectFactory,
resourceName);
// make the bean jbpm.configuration always available
if (objectFactory instanceof ObjectFactoryImpl) {
ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl) objectFactory;
@@ -372,7 +383,7 @@
InputStream inputStream = resource != null ? ClassLoaderUtil.getStream(resource,
false)
: null;
ObjectFactory objectFactory = parseObjectFactory(inputStream);
- return createJbpmConfiguration(objectFactory);
+ return createJbpmConfiguration(objectFactory, resource);
}
public JbpmContext createJbpmContext() {
@@ -383,14 +394,14 @@
ensureOpen();
JbpmContext jbpmContext = (JbpmContext) objectFactory.createObject(name);
- jbpmContext.name = name;
- jbpmContext.jbpmConfiguration = this;
+ jbpmContext.setName(name);
+ jbpmContext.setJbpmConfiguration(this);
pushJbpmContext(jbpmContext);
return jbpmContext;
}
private void ensureOpen() {
- if (isClosed) throw new JbpmException("configuration closed");
+ if (isClosed) throw new JbpmException("jbpm configuration is closed");
}
public ServiceFactory getServiceFactory(String serviceName) {
@@ -419,8 +430,8 @@
}
/**
- * gives the jbpm domain model access to configuration information via the
- * current JbpmContext.
+ * gives the jbpm domain model access to configuration information via the current
+ * JbpmContext.
*/
public static class Configs {
@@ -429,19 +440,16 @@
}
public static ObjectFactory getObjectFactory() {
- ObjectFactory objectFactory = null;
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
- objectFactory = jbpmContext.objectFactory;
- }
- else {
- objectFactory = getInstance().objectFactory;
- }
- return objectFactory;
+ return jbpmContext != null ? jbpmContext.getObjectFactory()
+ : getInstance().getObjectFactory();
}
+ /**
+ * @deprecated call {@link JbpmConfiguration#setDefaultObjectFactory(ObjectFactory)}
instead
+ */
public static void setDefaultObjectFactory(ObjectFactory objectFactory) {
- defaultObjectFactory = objectFactory;
+ JbpmConfiguration.setDefaultObjectFactory(objectFactory);
}
public static boolean hasObject(String name) {
@@ -539,12 +547,9 @@
jbpmContextStacks.set(null);
// remove from configuration cache
- synchronized (instances) {
- for (Iterator i = instances.values().iterator(); i.hasNext();) {
- if (this == i.next()) {
- i.remove();
- break;
- }
+ if (resourceName != null) {
+ synchronized (instances) {
+ instances.remove(resourceName);
}
}
}
@@ -565,23 +570,25 @@
static void clearJbpmConfigurationStack() {
List configStack = getJbpmConfigurationStack();
if (configStack != null) {
- Object[] configs = configStack.toArray();
+ JbpmConfiguration[] configs = (JbpmConfiguration[]) configStack.toArray(new
JbpmConfiguration[configStack.size()]);
for (int f = 0; f < configs.length; f++) {
- JbpmConfiguration config = (JbpmConfiguration) configs[f];
- List contextStack = config.getJbpmContextStack();
+ List contextStack = configs[f].getJbpmContextStack();
if (contextStack != null) {
- Object[] contexts = contextStack.toArray();
+ JbpmContext[] contexts = (JbpmContext[]) contextStack.toArray(new
JbpmContext[contextStack.size()]);
for (int t = 0; t < contexts.length; t++) {
- JbpmContext context = (JbpmContext) contexts[t];
- context.close();
+ contexts[t].close();
}
}
- contextStack.clear();
+ assert contextStack.isEmpty() : contextStack;
}
- configStack.clear();
+ assert configStack.isEmpty() : configStack;
}
}
+ static void clearInstances() {
+ instances.clear();
+ }
+
private void pushJbpmConfiguration() {
getJbpmConfigurationStack().add(this);
}
@@ -590,14 +597,12 @@
List stack = getJbpmConfigurationStack();
int index = stack.lastIndexOf(this);
if (index == -1) {
- log.warn(this
- + " was not found in thread-local stack;"
+ log.warn(this + " was not found in thread-local stack;"
+ "do not access JbpmContext instances from multiple threads");
}
else {
if (index != stack.size() - 1) {
- log.warn(this
- + " was not closed in reverse creation order;"
+ log.warn(this + " was not closed in reverse creation order;"
+ " check your try-finally clauses around JbpmContext blocks");
}
// prevent configuration from remaining in the stack, no matter what
@@ -629,14 +634,12 @@
List stack = getJbpmContextStack();
int index = stack.lastIndexOf(jbpmContext);
if (index == -1) {
- log.warn(jbpmContext
- + " was not found in thread-local stack;"
+ log.warn(jbpmContext + " was not found in thread-local stack;"
+ " do not access JbpmContext instances from multiple threads");
}
else {
if (index != stack.size() - 1) {
- log.warn(jbpmContext
- + " was not closed in reverse creation order;"
+ log.warn(jbpmContext + " was not closed in reverse creation order;"
+ " check your try-finally clauses around JbpmContext blocks");
}
// prevent context from remaining in the stack, no matter what
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -27,8 +27,6 @@
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -52,9 +50,8 @@
/**
* is used to surround persistent operations to processes.
* <p>
- * Obtain JbpmContext's via
- * {@link org.jbpm.JbpmConfiguration#createJbpmContext()} and put it in a
- * try-finally block like this:
+ * Obtain a JbpmContext via {@link org.jbpm.JbpmConfiguration#createJbpmContext()} and
+ * manipulate it inside a try-finally block as follows.
* </p>
*
* <pre>
@@ -72,33 +69,30 @@
* }
* </pre>
* <p>
- * A JbpmContext separates jBPM from a sprecific environment. For each service
- * that jBPM uses, there is an interface specified in the jBPM codebase. jBPM
- * also includes implementations that implement these services by using services
- * in a specific environment. e.g. a hibernate session, a JMS asynchronous
- * messaging system, ...
+ * A JbpmContext separates jBPM from a sprecific environment. For each service that jBPM
uses,
+ * there is an interface specified in the jBPM codebase. jBPM also includes
implementations that
+ * implement these services by using services in a specific environment. e.g. a
hibernate
+ * session, a JMS asynchronous messaging system, ...
* </p>
* <p>
- * A JbpmContext can demarcate a transaction. When a PersistenceService is
- * fetched from the JbpmContext, the default implementation for the persistence
- * service will create a hibernate session and start a transaction. So that
- * transactions can be configured in the hibernate configuration.
+ * A JbpmContext can demarcate a transaction. When a PersistenceService is fetched from
the
+ * JbpmContext, the default implementation for the persistence service will create a
hibernate
+ * session and start a transaction. So that transactions can be configured in the
hibernate
+ * configuration.
* </p>
* <p>
- * A JbpmContext allows the user to overwrite (or make complete) the
- * configuration by injecting objects programmatically. like e.g. a hibernate
- * session factory or a hibernate session or any other resource that can be
- * fetched or created from the configuration.
+ * A JbpmContext allows the user to overwrite (or make complete) the configuration by
injecting
+ * objects programmatically. like e.g. a hibernate session factory or a hibernate session
or any
+ * other resource that can be fetched or created from the configuration.
* </p>
* <p>
- * Last but not least, JbpmContext provides convenient access to the most common
- * operations such as {@link #getTaskList(String)},
- * {@link #newProcessInstance(String)} {@link #loadTaskInstanceForUpdate(long)}
- * and {@link #save(ProcessInstance)}.
+ * Last but not least, JbpmContext provides convenient access to the most common
operations such
+ * as {@link #getTaskList(String)}, {@link #newProcessInstance(String)}
+ * {@link #loadTaskInstanceForUpdate(long)} and {@link #save(ProcessInstance)}.
* </p>
* <p>
- * All the <code>...ForUpdate(...)</code> methods will automatically save
the
- * loaded objects at <code>jbpmContext.close();</code>
+ * All the <code>...ForUpdate(...)</code> methods will automatically save the
loaded objects at
+ * <code>jbpmContext.close();</code>
* </p>
*/
public class JbpmContext implements Serializable {
@@ -107,17 +101,16 @@
public static final String DEFAULT_JBPM_CONTEXT_NAME =
"default.jbpm.context";
- String name;
- ObjectFactory objectFactory;
- Services services;
- JbpmConfiguration jbpmConfiguration;
- List autoSaveProcessInstances;
+ private String name;
+ private ObjectFactory objectFactory;
+ private Services services;
+ private JbpmConfiguration jbpmConfiguration;
+ private List autoSaveProcessInstances;
/**
* normally, JbpmContext object are created via a {@link JbpmConfiguration}.
*/
public JbpmContext(Services services, ObjectFactory objectFactory) {
- log.debug("creating " + this);
this.services = services;
this.objectFactory = objectFactory;
}
@@ -126,7 +119,6 @@
* make sure you close your JbpmContext in a finally block.
*/
public void close() {
- log.debug("closing " + this);
try {
if (services != null) {
try {
@@ -143,14 +135,12 @@
}
/**
- * obtains the current JbpmContext from a thread local. The current contexts
- * are maintained in a stack so that you can do nested context operations for
- * different jbpm configurations.
+ * obtains the current JbpmContext from a thread local. The current contexts are
maintained in
+ * a stack so that you can do nested context operations for different jbpm
configurations.
*
* <p>
* it is <strong>strongly recommended</strong> that client code invokes
- * {@link JbpmConfiguration#getCurrentJbpmContext()} in preference to this
- * method.
+ * {@link JbpmConfiguration#getCurrentJbpmContext()} in preference to this method.
* </p>
*/
public static JbpmContext getCurrentJbpmContext() {
@@ -165,18 +155,17 @@
// convenience methods //////////////////////////////////////////////////////
/**
- * deploys a process definition. For parsing process definitions from
- * archives, see the static parseXxx methods on {@link ProcessDefinition}.
+ * deploys a process definition. For parsing process definitions from archives, see the
static
+ * parseXxx methods on {@link ProcessDefinition}.
*/
public void deployProcessDefinition(ProcessDefinition processDefinition) {
getGraphSession().deployProcessDefinition(processDefinition);
}
/**
- * fetches the tasklist for the current authenticated actor. With the default
- * configured authentication service, you can set the authenticated user with
- * {@link #setActorId(String)}, then all the subsequent operations will be
- * performed on behalf of that actor.
+ * fetches the tasklist for the current authenticated actor. With the default
configured
+ * authentication service, you can set the authenticated user with {@link
#setActorId(String)}
+ * , then all the subsequent operations will be performed on behalf of that actor.
*/
public List getTaskList() {
String actorId = getActorId();
@@ -191,14 +180,12 @@
}
/**
- * fetches all the task instances for which at least one of the given actorIds
- * is a candidate (pooled actor). Typically, for an actor, his/her personal
- * actorId plus all the actorIds representing the groups that person belongs
- * to form the actorIds. Then the user interface should show only the option
- * to take these tasks to the actor's personal task list (with
- * {@link TaskInstance#setActorId(String)}). Only task instances that are
- * assigned to the actor directly should be offered the possibility for
- * performing the actual task.
+ * fetches all the task instances for which at least one of the given actorIds is a
candidate
+ * (pooled actor). Typically, for an actor, his/her personal actorId plus all the
actorIds
+ * representing the groups that person belongs to form the actorIds. Then the user
interface
+ * should show only the option to take these tasks to the actor's personal task
list (with
+ * {@link TaskInstance#setActorId(String)}). Only task instances that are assigned to
the
+ * actor directly should be offered the possibility for performing the actual task.
*/
public List getGroupTaskList(List actorIds) {
return getTaskMgmtSession().findPooledTaskInstances(actorIds);
@@ -229,10 +216,9 @@
}
/**
- * loads a task instance from the db and registers it for auto-save. The
- * loaded task instance will be save automatically at the {@link #close()}.
- * This is a convenience method in case you plan to do update operations on
- * this task instance.
+ * loads a task instance from the db and registers it for auto-save. The loaded task
instance
+ * will be save automatically at the {@link #close()}. This is a convenience method in
case
+ * you plan to do update operations on this task instance.
*
* @throws JbpmException in case no such task instance exists
* @see #loadTaskInstance(long)
@@ -246,10 +232,9 @@
}
/**
- * gets a task instance from the db and registers it for auto-save. The loaded
- * task instance will be save automatically at the {@link #close()}. This is a
- * convenience method in case you plan to do update operations on this task
- * instance.
+ * gets a task instance from the db and registers it for auto-save. The loaded task
instance
+ * will be save automatically at the {@link #close()}. This is a convenience method in
case
+ * you plan to do update operations on this task instance.
*
* @return the task instance or null in case no such task instance exists.
* @see #loadTaskInstance(long)
@@ -289,10 +274,9 @@
}
/**
- * loads a token from the db and registers it for auto-save. The loaded token
- * will be {@link #save(Token)}d automatically at the {@link #close()}. This
- * is a convenience method in case you plan to do update operations on this
- * token.
+ * loads a token from the db and registers it for auto-save. The loaded token will be
+ * {@link #save(Token)}d automatically at the {@link #close()}. This is a convenience
method
+ * in case you plan to do update operations on this token.
*
* @throws JbpmException in case no such token exists.
* @see #getToken(long)
@@ -306,10 +290,9 @@
}
/**
- * get a token from the db and registers it for auto-save. The loaded token
- * will be {@link #save(Token)}d automatically at the {@link #close()}. This
- * is a convenience method in case you plan to do update operations on this
- * token.
+ * gets a token from the db and registers it for auto-save. The loaded token will be
+ * {@link #save(Token)}d automatically at the {@link #close()}. This is a convenience
method
+ * in case you plan to do update operations on this token.
*
* @return the token or null in case no such token exists.
* @see #getToken(long)
@@ -326,8 +309,8 @@
/**
* loads a process instance from the db. Consider using
- * {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an
- * update operation on the process instance.
+ * {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an update
operation on
+ * the process instance.
*
* @throws JbpmException in case no such process instance exists.
* @see #getProcessInstance(long)
@@ -340,8 +323,8 @@
/**
* gets a process instance from the db. Consider using
- * {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an
- * update operation on the process instance.
+ * {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an update
operation on
+ * the process instance.
*
* @return the token or null in case no such token exists.
* @see #loadProcessInstance(long)
@@ -353,10 +336,10 @@
}
/**
- * loads a process instances from the db and registers it for auto-save. The
- * loaded process instance will be {@link #save(ProcessInstance)}d
- * automatically at the {@link #close()}. This is a convenience method in case
- * you plan to do update operations on this process instance.
+ * loads a process instances from the db and registers it for auto-save. The loaded
process
+ * instance will be {@link #save(ProcessInstance)}d automatically at the {@link
#close()}.
+ * This is a convenience method in case you plan to do update operations on this
process
+ * instance.
*
* @throws JbpmException in case no such process instance exists.
* @see #loadProcessInstance(long)
@@ -370,10 +353,10 @@
}
/**
- * gets a process instances from the db and registers it for auto-save. The
- * loaded process instance will be {@link #save(ProcessInstance)}d
- * automatically at the {@link #close()}. This is a convenience method in case
- * you plan to do update operations on this process instance.
+ * gets a process instances from the db and registers it for auto-save. The loaded
process
+ * instance will be {@link #save(ProcessInstance)}d automatically at the {@link
#close()}.
+ * This is a convenience method in case you plan to do update operations on this
process
+ * instance.
*
* @return the token or null in case no such token exists.
* @see #loadProcessInstance(long)
@@ -389,25 +372,23 @@
}
/**
- * returns the process instance with the given key or null if no such instance
- * exists.
+ * returns the process instance with the given key or null if no such instance exists.
*/
public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String
key) {
return getGraphSession().getProcessInstance(processDefinition, key);
}
/**
- * returns the process instance with the given key or throws an exception if
- * no such instance exists.
+ * returns the process instance with the given key or throws an exception if no such
instance
+ * exists.
*/
public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String
key) {
return getGraphSession().loadProcessInstance(processDefinition, key);
}
/**
- * returns the process instance with the given key or null if no such instance
- * exists. Upon close of this jbpmContext, the fetched process instance will
- * be automatically saved.
+ * returns the process instance with the given key or null if no such instance exists.
Upon
+ * close of this jbpmContext, the fetched process instance will be automatically
saved.
*/
public ProcessInstance getProcessInstanceForUpdate(ProcessDefinition
processDefinition,
String key) {
@@ -419,9 +400,9 @@
}
/**
- * returns the process instance with the given key or throws an exception if
- * no such instance exists. Upon close of this jbpmContext, the fetched
- * process instance will be automatically saved.
+ * returns the process instance with the given key or throws an exception if no such
instance
+ * exists. Upon close of this jbpmContext, the fetched process instance will be
automatically
+ * saved.
*/
public ProcessInstance loadProcessInstanceForUpdate(ProcessDefinition
processDefinition,
String key) {
@@ -433,11 +414,10 @@
}
/**
- * creates a new process instance for the latest version of the process
- * definition with the given name.
+ * creates a new process instance for the latest version of the process definition with
the
+ * given name.
*
- * @throws JbpmException when no processDefinition with the given name is
- * deployed.
+ * @throws JbpmException when no processDefinition with the given name is deployed.
*/
public ProcessInstance newProcessInstance(String processDefinitionName) {
ProcessDefinition processDefinition =
getGraphSession().findLatestProcessDefinition(processDefinitionName);
@@ -445,11 +425,10 @@
}
/**
- * creates a new process instance for the latest version of the process
- * definition with the given name and registers it for auto-save.
+ * creates a new process instance for the latest version of the process definition with
the
+ * given name and registers it for auto-save.
*
- * @throws JbpmException when no processDefinition with the given name is
- * deployed.
+ * @throws JbpmException when no processDefinition with the given name is deployed.
*/
public ProcessInstance newProcessInstanceForUpdate(String processDefinitionName) {
ProcessDefinition processDefinition =
getGraphSession().findLatestProcessDefinition(processDefinitionName);
@@ -468,22 +447,22 @@
}
/**
- * saves the complete process instance for this token.
+ * saves the process instance of the given token.
*/
public void save(Token token) {
save(token.getProcessInstance());
}
/**
- * saves the complete process instance for this task instance.
+ * saves the process instance of the given task instance.
*/
public void save(TaskInstance taskInstance) {
save(taskInstance.getTaskMgmtInstance().getProcessInstance());
}
/**
- * mark this transaction for rollback only in the persistence service. The
- * {@link #close()} operation will then perform a rollback.
+ * mark this transaction for rollback only in the persistence service. The {@link
#close()}
+ * operation will then perform a rollback.
*/
public void setRollbackOnly() {
TxService txService = (services != null ? services.getTxService() : null);
@@ -509,21 +488,33 @@
}
/**
- * gives access to the object factory containing the configuration for
- * creating the service factories.
+ * gives access to the object factory containing the configuration to create the
service
+ * factories.
*/
public ObjectFactory getObjectFactory() {
return objectFactory;
}
+ /** give access to the configuration that created this jbpm context */
+ public JbpmConfiguration getJbpmConfiguration() {
+ return jbpmConfiguration;
+ }
+
+ void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration) {
+ this.jbpmConfiguration = jbpmConfiguration;
+ }
+
+ void setName(String name) {
+ this.name = name;
+ }
+
// persistence methods //////////////////////////////////////////////////////
/**
- * gets the hibernate session factory from the default configured persistence
- * service.
+ * gets the hibernate session factory from the default configured persistence service.
*
- * @return the hibernate session factory, or <code>null</code> if a
- * nonstandard persistence service is configured
+ * @return the hibernate session factory, or <code>null</code> if a
nonstandard persistence
+ * service is configured
*/
public SessionFactory getSessionFactory() {
PersistenceService persistenceService = getPersistenceService();
@@ -532,10 +523,9 @@
}
/**
- * sets the hibernate session factory into the default configured persistence
- * service, overwriting the configured session factory (if there is one
- * configured). if a nonstandard persistence service is configured, then this
- * call has no effect.
+ * sets the hibernate session factory into the default configured persistence service,
+ * overwriting the configured session factory (if there is one configured). if a
nonstandard
+ * persistence service is configured, then this call has no effect.
*/
public void setSessionFactory(SessionFactory sessionFactory) {
PersistenceService persistenceService = getPersistenceService();
@@ -548,8 +538,8 @@
/**
* gets the hibernate session from the default configured persistence service.
*
- * @return the hibernate session, or <code>null</code> if a nonstandard
- * persistence service is configured.
+ * @return the hibernate session, or <code>null</code> if a nonstandard
persistence service is
+ * configured.
*/
public Session getSession() {
PersistenceService persistenceService = getPersistenceService();
@@ -558,10 +548,9 @@
}
/**
- * sets the hibernate session into the default configured persistence service,
- * preventing the creation of a session from the configured session factory
- * (if there is one configured). if a nonstandard persistence service is
- * configured, then this call has no effect.
+ * sets the hibernate session into the default configured persistence service,
preventing the
+ * creation of a session from the configured session factory (if there is one
configured). if
+ * a nonstandard persistence service is configured, then this call has no effect.
*/
public void setSession(Session session) {
PersistenceService persistenceService = getPersistenceService();
@@ -574,8 +563,8 @@
/**
* gets the jdbc connection from the default configured persistence service.
*
- * @return the jdbc connectoin, or <code>null</code> if a nonstandard
- * persistence service is configured.
+ * @return the jdbc connectoin, or <code>null</code> if a nonstandard
persistence service is
+ * configured.
*/
public Connection getConnection() {
PersistenceService persistenceService = getPersistenceService();
@@ -584,9 +573,8 @@
}
/**
- * allows users to provide a jdbc connection to be used when the hibernate
- * session is created. if a nonstandard persistence service is configured,
- * then this call has no effect.
+ * allows users to provide a jdbc connection to be used when the hibernate session is
created.
+ * if a nonstandard persistence service is configured, then this call has no effect.
*/
public void setConnection(Connection connection) {
PersistenceService persistenceService = getPersistenceService();
@@ -670,29 +658,23 @@
// private methods //////////////////////////////////////////////////////////
- void autoSave() {
+ private void autoSave() {
if (autoSaveProcessInstances != null) {
- Iterator iter = autoSaveProcessInstances.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = autoSaveProcessInstances.iterator(); iter.hasNext();) {
ProcessInstance processInstance = (ProcessInstance) iter.next();
save(processInstance);
- iter.remove();
}
+ autoSaveProcessInstances.clear();
}
}
- PersistenceService getPersistenceService() {
+ private PersistenceService getPersistenceService() {
return services != null ? services.getPersistenceService() : null;
}
- public JbpmConfiguration getJbpmConfiguration() {
- return jbpmConfiguration;
- }
-
- private static Log log = LogFactory.getLog(JbpmContext.class);
-
public String toString() {
return "JbpmContext"
+ (name != null ? '(' + name + ')' : '@' +
Integer.toHexString(hashCode()));
}
+
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmException.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmException.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmException.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -38,6 +38,6 @@
super(message);
}
public JbpmException(Throwable cause) {
- super(cause);
+ super(cause.getMessage(), cause);
}
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/JbpmContextInfo.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/JbpmContextInfo.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/configuration/JbpmContextInfo.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -27,8 +27,6 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmContext;
import org.jbpm.svc.Services;
import org.jbpm.util.XmlUtil;
@@ -37,73 +35,76 @@
public class JbpmContextInfo extends AbstractObjectInfo {
private static final long serialVersionUID = 1L;
-
- Map serviceFactoryObjectInfos = null;
- Map serviceFactories = null;
- List serviceNames = null;
-
- ObjectInfo[] saveOperationObjectInfos = null;
- List saveOperations = null;
-
+
+ private Map serviceFactoryObjectInfos;
+ private Map serviceFactories;
+ private List serviceNames;
+
+ private ObjectInfo[] saveOperationObjectInfos;
+ private List saveOperations;
+
public JbpmContextInfo(Element jbpmContextElement, ObjectFactoryParser
objectFactoryParser) {
super(verifyDefaultName(jbpmContextElement), objectFactoryParser);
if (jbpmContextElement.hasAttribute("singleton")) {
- throw new ConfigurationException("attribute 'singleton' is not allowed
in element 'jbpm-context'");
+ throw new ConfigurationException(
+ "attribute 'singleton' is not allowed in element
'jbpm-context'");
}
-
+
// parse the services
serviceFactoryObjectInfos = new HashMap();
List serviceElements = XmlUtil.elements(jbpmContextElement, "service");
serviceNames = new ArrayList();
- Iterator iter = serviceElements.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = serviceElements.iterator(); iter.hasNext();) {
Element serviceElement = (Element) iter.next();
- if (! serviceElement.hasAttribute("name")) {
- throw new ConfigurationException("name is required in service element
"+XmlUtil.toString(serviceElement));
+ if (!serviceElement.hasAttribute("name")) {
+ throw new ConfigurationException("name is required in service element
"
+ + XmlUtil.toString(serviceElement));
}
String serviceName = serviceElement.getAttribute("name");
serviceNames.add(serviceName);
- ObjectInfo serviceFactoryObjectInfo = null;
+ ObjectInfo serviceFactoryObjectInfo;
Element factoryElement = XmlUtil.element(serviceElement, "factory");
- if (factoryElement!=null) {
+ if (factoryElement != null) {
Element factoryBeanElement = XmlUtil.element(factoryElement);
- if (factoryBeanElement==null) {
- throw new ConfigurationException("element 'factory' requires
either a bean or ref element");
+ if (factoryBeanElement == null) {
+ throw new ConfigurationException(
+ "element 'factory' requires either a bean or ref
element");
}
serviceFactoryObjectInfo = objectFactoryParser.parse(factoryBeanElement);
-
- if (serviceElement.hasAttribute("factory")) {
- log.warn("duplicate factory specification for service
"+serviceName+", using the factory element");
- }
- } else if (serviceElement.hasAttribute("factory")) {
+ }
+ else if (serviceElement.hasAttribute("factory")) {
String factoryClassName = serviceElement.getAttribute("factory");
BeanInfo beanInfo = new BeanInfo();
beanInfo.setClassName(factoryClassName);
serviceFactoryObjectInfo = beanInfo;
- } else {
- throw new ConfigurationException("element 'service' requires either
a factory attribute or a factory element");
}
-
+ else {
+ throw new ConfigurationException(
+ "element 'service' requires either a factory attribute or a
factory element");
+ }
+
serviceFactoryObjectInfos.put(serviceName, serviceFactoryObjectInfo);
}
-
+
// parse the save operations
Element saveOperationsElement = XmlUtil.element(jbpmContextElement,
"save-operations");
- if (saveOperationsElement!=null) {
+ if (saveOperationsElement != null) {
List saveOperationElements = XmlUtil.elements(saveOperationsElement,
"save-operation");
saveOperationObjectInfos = new ObjectInfo[saveOperationElements.size()];
- for (int i=0; i<saveOperationElements.size(); i++){
+ for (int i = 0; i < saveOperationElements.size(); i++) {
Element saveOperationElement = (Element) saveOperationElements.get(i);
-
+
if (saveOperationElement.hasAttribute("class")) {
String saveOperationClassName =
saveOperationElement.getAttribute("class");
BeanInfo beanInfo = new BeanInfo();
beanInfo.setClassName(saveOperationClassName);
saveOperationObjectInfos[i] = beanInfo;
- } else {
+ }
+ else {
Element saveOperationBeanElement = XmlUtil.element(saveOperationElement);
- if (saveOperationBeanElement==null) {
- throw new ConfigurationException("element 'save-operation'
requires either a class attribute or an element of type 'bean' or
'ref'");
+ if (saveOperationBeanElement == null) {
+ throw new ConfigurationException(
+ "element 'save-operation' requires either a class attribute or
an element of type 'bean' or 'ref'");
}
saveOperationObjectInfos[i] =
objectFactoryParser.parse(saveOperationBeanElement);
}
@@ -119,10 +120,9 @@
}
public synchronized Object createObject(ObjectFactoryImpl objectFactory) {
- if (serviceFactories==null) {
+ if (serviceFactories == null) {
serviceFactories = new HashMap();
- Iterator iter = serviceFactoryObjectInfos.entrySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = serviceFactoryObjectInfos.entrySet().iterator();
iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
String serviceName = (String) entry.getKey();
ObjectInfo serviceFactoryObjectInfo = (ObjectInfo) entry.getValue();
@@ -130,21 +130,16 @@
}
}
- if ( (saveOperations==null)
- && (saveOperationObjectInfos!=null)
- ) {
+ if (saveOperations == null && saveOperationObjectInfos != null) {
saveOperations = new ArrayList();
- for (int i=0; i<saveOperationObjectInfos.length; i++) {
+ for (int i = 0; i < saveOperationObjectInfos.length; i++) {
Object saveOperation = saveOperationObjectInfos[i].createObject(objectFactory);
saveOperations.add(saveOperation);
}
}
Services services = new Services(serviceFactories, serviceNames, saveOperations);
-
- if (log.isDebugEnabled()) log.debug("creating jbpm context with service
factories '"+serviceFactories.keySet()+"'");
return new JbpmContext(services, objectFactory);
}
-
- private static Log log = LogFactory.getLog(JbpmContextInfo.class);
+
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.List;
+import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.ObjectNotFoundException;
@@ -46,9 +47,9 @@
*/
public class GraphSession {
- final Session session;
+ private final Session session;
/** @deprecated */
- final JbpmSession jbpmSession;
+ private final JbpmSession jbpmSession;
/** @deprecated use {@link #GraphSession(Session)} instead */
public GraphSession(JbpmSession jbpmSession) {
@@ -64,8 +65,7 @@
// process definitions //////////////////////////////////////////////////////
/**
- * assigns a version number to the given process definition and then makes it
- * persistent.
+ * assigns a version number to the given process definition and then makes it
persistent.
*/
public void deployProcessDefinition(ProcessDefinition processDefinition) {
// versioning applies to named process definitions only
@@ -88,8 +88,8 @@
}
/**
- * saves the process definition. this method does not assign a version
- * number.
+ * saves the process definition. this method does not assign a version number.
+ *
* @see {@link #deployProcessDefinition(ProcessDefinition)}
*/
public void saveProcessDefinition(ProcessDefinition processDefinition) {
@@ -103,10 +103,9 @@
}
/**
- * returns the persistent process definition with the given identifier,
- * assuming the definition exists. if the requested process definition does
- * not exist in the database, {@link ObjectNotFoundException} is thrown when
- * the definition state is first accessed.
+ * returns the persistent process definition with the given identifier, assuming the
+ * definition exists. if the requested process definition does not exist in the
database,
+ * {@link ObjectNotFoundException} is thrown when the definition state is first
accessed.
*/
public ProcessDefinition loadProcessDefinition(long processDefinitionId) {
try {
@@ -123,8 +122,8 @@
/**
* returns the persistent process definition with the given identifier.
*
- * @return the referenced process definition, or <code>null</code> if there
is
- * no such definition.
+ * @return the referenced process definition, or <code>null</code> if there
is no such
+ * definition.
*/
public ProcessDefinition getProcessDefinition(long processDefinitionId) {
try {
@@ -156,8 +155,7 @@
}
/**
- * queries the database for the latest version of a process definition with
- * the given name.
+ * queries the database for the latest version of a process definition with the given
name.
*/
public ProcessDefinition findLatestProcessDefinition(String name) {
try {
@@ -173,8 +171,8 @@
}
/**
- * queries the database for the latest version of each process definition.
- * process definitions are distinct by name.
+ * queries the database for the latest version of each process definition. process
definitions
+ * are distinct by name.
*/
public List findLatestProcessDefinitions() {
try {
@@ -210,8 +208,8 @@
}
/**
- * queries the database for all process definitions, ordered by name
- * (ascending), then by version (descending).
+ * queries the database for all process definitions, ordered by name (ascending), then
by
+ * version (descending).
*/
public List findAllProcessDefinitions() {
try {
@@ -224,8 +222,8 @@
}
/**
- * queries the database for all versions of process definitions with the given
- * name, ordered by version (descending).
+ * queries the database for all versions of process definitions with the given name,
ordered
+ * by version (descending).
*/
public List findAllProcessDefinitionVersions(String name) {
try {
@@ -246,17 +244,20 @@
public void deleteProcessDefinition(ProcessDefinition processDefinition) {
try {
- // delete all the process instances of this definition
- List processInstanceIds =
session.getNamedQuery("GraphSession.findAllProcessInstanceIdsForDefinition")
+ // delete all instances of the given process
+ Iterator processInstanceIter =
session.getNamedQuery("GraphSession.findAllProcessInstancesForDefinition")
.setLong("processDefinitionId", processDefinition.getId())
- .list();
- for (Iterator i = processInstanceIds.iterator(); i.hasNext();) {
- Long processInstanceId = (Long) i.next();
- ProcessInstance processInstance =
getProcessInstance(processInstanceId.longValue());
+ .iterate();
+ while (processInstanceIter.hasNext()) {
+ ProcessInstance processInstance = (ProcessInstance) processInstanceIter.next();
if (processInstance != null) {
deleteProcessInstance(processInstance);
+ // flush changes and then evict process instance to avoid exhausting memory
+ session.flush();
+ session.evict(processInstance);
}
}
+ Hibernate.close(processInstanceIter);
List referencingProcessStates = findReferencingProcessStates(processDefinition);
for (Iterator i = referencingProcessStates.iterator(); i.hasNext();) {
@@ -273,7 +274,7 @@
}
}
- List findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
+ private List findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
return session.getNamedQuery("GraphSession.findReferencingProcessStates")
.setEntity("subProcessDefinition", subProcessDefinition)
.list();
@@ -289,10 +290,9 @@
}
/**
- * returns the persistent process instance with the given identifier, assuming
- * the instance exists. if the requested process instance does not exist in
- * the database, {@link ObjectNotFoundException} is thrown when the instance
- * state is first accessed.
+ * returns the persistent process instance with the given identifier, assuming the
instance
+ * exists. if the requested process instance does not exist in the database,
+ * {@link ObjectNotFoundException} is thrown when the instance state is first
accessed.
*/
public ProcessInstance loadProcessInstance(long processInstanceId) {
try {
@@ -308,8 +308,7 @@
/**
* returns the persistent process instance with the given identifier.
*
- * @return the referenced process instance, or <code>null</code> if there
is
- * no such instance
+ * @return the referenced process instance, or <code>null</code> if there
is no such instance
*/
public ProcessInstance getProcessInstance(long processInstanceId) {
try {
@@ -323,10 +322,9 @@
}
/**
- * returns the persistent token with the given identifier, assuming the token
- * exists. if the requested token does not exist in the database,
- * {@link ObjectNotFoundException} is thrown when the token state is first
- * accessed.
+ * returns the persistent token with the given identifier, assuming the token exists.
if the
+ * requested token does not exist in the database, {@link ObjectNotFoundException} is
thrown
+ * when the token state is first accessed.
*/
public Token loadToken(long tokenId) {
try {
@@ -341,8 +339,7 @@
/**
* returns the persistent token with the given identifier.
*
- * @return the referenced token, or <code>null</code> if there is no such
- * token.
+ * @return the referenced token, or <code>null</code> if there is no such
token.
*/
public Token getToken(long tokenId) {
try {
@@ -383,6 +380,7 @@
/**
* finds all instances of the given process definition.
+ *
* @return a list of process instances ordered by start date, earliest first
*/
public List findProcessInstances(long processDefinitionId) {
@@ -439,13 +437,13 @@
}
}
- void deleteJobs(ProcessInstance processInstance) {
+ private void deleteJobs(ProcessInstance processInstance) {
session.getNamedQuery("GraphSession.deleteJobsForProcessInstance")
.setEntity("processInstance", processInstance)
.executeUpdate();
}
- void deleteLogs(ProcessInstance processInstance) {
+ private void deleteLogs(ProcessInstance processInstance) {
List logs =
session.getNamedQuery("GraphSession.findLogsForProcessInstance")
.setEntity("processInstance", processInstance)
.list();
@@ -454,12 +452,12 @@
}
}
- void detachFromSuperProcess(ProcessInstance processInstance, Token superProcessToken)
{
+ private void detachFromSuperProcess(ProcessInstance processInstance, Token
superProcessToken) {
processInstance.setSuperProcessToken(null);
superProcessToken.setSubProcessInstance(null);
}
- void deleteSubProcesses(ProcessInstance processInstance) {
+ private void deleteSubProcesses(ProcessInstance processInstance) {
List subProcessInstances =
session.getNamedQuery("GraphSession.findSubProcessInstances")
.setEntity("processInstance", processInstance)
.list();
@@ -470,7 +468,7 @@
}
}
- void deleteTasks(ProcessInstance processInstance) {
+ private void deleteTasks(ProcessInstance processInstance) {
List tasks =
session.getNamedQuery("GraphSession.findTaskInstancesForProcessInstance")
.setEntity("processInstance", processInstance)
.list();
@@ -582,11 +580,9 @@
}
/**
- * returns the instance of the given process definition with the specified
- * business key.
+ * returns the instance of the given process definition with the specified business
key.
*
- * @return the referenced instance, or <code>null</code> if there is no
such
- * instance
+ * @return the referenced instance, or <code>null</code> if there is no
such instance
*/
public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String
key) {
try {
@@ -602,11 +598,10 @@
}
/**
- * returns the instance of the given process definition with the specified
- * business key, assuming the instance exists.
+ * returns the instance of the given process definition with the specified business
key,
+ * assuming the instance exists.
*
- * @throws JbpmPersistenceException if the referenced process instance does
- * not exist
+ * @throws JbpmPersistenceException if the referenced process instance does not exist
*/
public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String
key) {
ProcessInstance processInstance = getProcessInstance(processDefinition, key);
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/DelegationException.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/DelegationException.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/DelegationException.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -28,17 +28,17 @@
private static final long serialVersionUID = 1L;
- protected transient ExecutionContext executionContext = null;
+ protected transient ExecutionContext executionContext;
+ public DelegationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
public DelegationException(Throwable cause, ExecutionContext executionContext) {
super(cause.getMessage(), cause);
this.executionContext = executionContext;
}
- public DelegationException(String message, Throwable cause) {
- super(message, cause);
- }
-
public ExecutionContext getExecutionContext() {
return executionContext;
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -69,10 +69,9 @@
// events ///////////////////////////////////////////////////////////////////
/**
- * indicative set of event types supported by this graph element. this is
- * currently only used by the process designer to know which event types to
- * show on a given graph element. in process definitions and at runtime, there
- * are no constraints on the event-types.
+ * indicative set of event types supported by this graph element. this is currently
only used
+ * by the process designer to know which event types to show on a given graph element.
in
+ * process definitions and at runtime, there are no constraints on the event-types.
*/
public abstract String[] getSupportedEventTypes();
@@ -164,16 +163,17 @@
exceptionHandlers.add(newIndex, o);
}
else {
- throw new IndexOutOfBoundsException("could not move element from "
- + oldIndex + " to " + newIndex);
+ throw new IndexOutOfBoundsException("could not move element from " +
oldIndex + " to "
+ + newIndex);
}
}
// event handling ///////////////////////////////////////////////////////////
public void fireEvent(String eventType, ExecutionContext executionContext) {
- log.debug("event '" + eventType + "' on " + this + "
for "
- + executionContext.getToken());
+ Token token = executionContext.getToken();
+ log.debug("event '" + eventType + "' on " + this + "
for " + token + " of "
+ + token.getProcessInstance());
GraphElement eventSource = executionContext.getEventSource();
try {
@@ -182,10 +182,8 @@
JbpmContext jbpmContext = executionContext.getJbpmContext();
if (jbpmContext != null) {
EventService eventService = (EventService) jbpmContext.getServices()
- .getService(EventService.SERVICE_NAME);
- if (eventService != null) {
- eventService.fireEvent(eventType, this, executionContext);
- }
+ .getService(EventService.SERVICE_NAME);
+ if (eventService != null) eventService.fireEvent(eventType, this,
executionContext);
}
fireAndPropagateEvent(eventType, executionContext);
@@ -195,8 +193,7 @@
}
}
- public void fireAndPropagateEvent(String eventType,
- ExecutionContext executionContext) {
+ public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext)
{
// check whether the event was fired on this element
// or propagated from another element
boolean isPropagated = !equals(executionContext.getEventSource());
@@ -211,8 +208,7 @@
}
// execute the runtime actions
- List runtimeActions =
- getRuntimeActionsForEvent(executionContext, eventType);
+ List runtimeActions = getRuntimeActionsForEvent(executionContext, eventType);
executeActions(runtimeActions, executionContext, isPropagated);
// remove the event from the context
@@ -225,8 +221,8 @@
}
}
- void executeActions(List actions, ExecutionContext executionContext,
- boolean isPropagated) {
+ private void executeActions(List actions, ExecutionContext executionContext,
+ boolean isPropagated) {
if (actions == null) return;
for (Iterator iter = actions.iterator(); iter.hasNext();) {
@@ -234,10 +230,10 @@
if (!action.acceptsPropagatedEvents() && isPropagated) continue;
if (action.isAsync()) {
- ExecuteActionJob job =
- createAsyncActionExecutionJob(executionContext.getToken(), action);
- MessageService messageService =
- executionContext.getJbpmContext().getServices().getMessageService();
+ ExecuteActionJob job = createAsyncActionExecutionJob(executionContext.getToken(),
action);
+ MessageService messageService = executionContext.getJbpmContext()
+ .getServices()
+ .getMessageService();
messageService.send(job);
}
else {
@@ -246,8 +242,7 @@
}
}
- protected ExecuteActionJob createAsyncActionExecutionJob(Token token,
- Action action) {
+ protected ExecuteActionJob createAsyncActionExecutionJob(Token token, Action action) {
ExecuteActionJob job = new ExecuteActionJob(token);
job.setAction(action);
job.setDueDate(new Date());
@@ -256,66 +251,64 @@
}
public void executeAction(Action action, ExecutionContext executionContext) {
- Token token = executionContext.getToken();
-
// create action log
ActionLog actionLog = new ActionLog(action);
+ Token token = executionContext.getToken();
token.startCompositeLog(actionLog);
- // if this is an action being executed in an event,
- // the token needs to be locked. if this is an action
- // being executed as the node behaviour or if the token
- // is already locked, the token doesn't need to be locked.
- boolean actionMustBeLocked =
- executionContext.getEvent() != null && !token.isLocked();
-
try {
- // update the execution context
- executionContext.setAction(action);
-
- // execute the action
- log.debug("executing " + action);
- String lockOwnerId = "token[" + token.getId() + "]";
- try {
- if (actionMustBeLocked) {
- token.lock(lockOwnerId);
+ // if the action is associated to an event, the token needs to be locked.
+ // conversely, if the action is the behavior of a node or the token is already
locked,
+ // the token does not need to be locked
+ if (executionContext.getEvent() != null && !token.isLocked()) {
+ String lockOwner = action.toString();
+ token.lock(lockOwner);
+ try {
+ executeActionImpl(action, executionContext);
}
-
- UserCodeInterceptor userCodeInterceptor =
- UserCodeInterceptorConfig.getUserCodeInterceptor();
- if (userCodeInterceptor != null) {
- userCodeInterceptor.executeAction(action, executionContext);
+ finally {
+ token.unlock(lockOwner);
}
- else {
- action.execute(executionContext);
- }
}
- finally {
- if (actionMustBeLocked) token.unlock(lockOwnerId);
+ else {
+ executeActionImpl(action, executionContext);
}
}
catch (Exception exception) {
// NOTE that Errors are not caught because that might halt the JVM
// and mask the original Error
- log.error("action threw exception: " + exception.getMessage(),
exception);
-
// log the action exception
actionLog.setException(exception);
-
- // if an exception handler is available
+ // search for an exception handler or throw to the client
raiseException(exception, executionContext);
}
finally {
- executionContext.setAction(null);
token.endCompositeLog();
}
}
- List getRuntimeActionsForEvent(ExecutionContext executionContext,
- String eventType) {
- List runtimeActionsForEvent = null;
- List runtimeActions =
- executionContext.getProcessInstance().getRuntimeActions();
+ private void executeActionImpl(Action action, ExecutionContext executionContext)
+ throws Exception {
+ // set context action
+ executionContext.setAction(action);
+ try {
+ UserCodeInterceptor userCodeInterceptor =
UserCodeInterceptorConfig.getUserCodeInterceptor();
+ if (userCodeInterceptor != null) {
+ userCodeInterceptor.executeAction(action, executionContext);
+ }
+ else {
+ action.execute(executionContext);
+ }
+ }
+ finally {
+ // reset context action
+ executionContext.setAction(null);
+ }
+ }
+
+ private List getRuntimeActionsForEvent(ExecutionContext executionContext, String
eventType) {
+ List eventRuntimeActions = null;
+ List runtimeActions = executionContext.getProcessInstance().getRuntimeActions();
if (runtimeActions != null) {
for (Iterator iter = runtimeActions.iterator(); iter.hasNext();) {
RuntimeAction runtimeAction = (RuntimeAction) iter.next();
@@ -323,26 +316,23 @@
if (equals(runtimeAction.getGraphElement())
&& eventType.equals(runtimeAction.getEventType())) {
// ... add its action to the list of runtime actions
- if (runtimeActionsForEvent == null) {
- runtimeActionsForEvent = new ArrayList();
- }
- runtimeActionsForEvent.add(runtimeAction.getAction());
+ if (eventRuntimeActions == null) eventRuntimeActions = new ArrayList();
+ eventRuntimeActions.add(runtimeAction.getAction());
}
}
}
- return runtimeActionsForEvent;
+ return eventRuntimeActions;
}
/**
- * throws an ActionException if no applicable exception handler is found. An
- * ExceptionHandler is searched for in this graph element and then recursively
- * up the parent hierarchy. If an exception handler is found, it is applied.
- * If the exception handler does not throw an exception, the exception is
- * considered handled. Otherwise the search for an applicable exception
- * handler continues where it left of with the newly thrown exception.
+ * throws an ActionException if no applicable exception handler is found. An
ExceptionHandler
+ * is searched for in this graph element and then recursively up the parent hierarchy.
If an
+ * exception handler is found, it is applied. If the exception handler does not throw
an
+ * exception, the exception is considered handled. Otherwise the search for an
applicable
+ * exception handler continues where it left of with the newly thrown exception.
*/
- public void raiseException(Throwable exception,
- ExecutionContext executionContext) throws DelegationException {
+ public void raiseException(Throwable exception, ExecutionContext executionContext)
+ throws DelegationException {
if (isAbleToHandleExceptions(executionContext)) {
try {
ExceptionHandler exceptionHandler = findExceptionHandler(exception);
@@ -358,21 +348,18 @@
exception = e;
}
+ // if this graph element has parent
GraphElement parent = getParent();
- // if this graph element has a parent
if (parent != null && !equals(parent)) {
- // raise to the parent
+ // propagate exception to parent
parent.raiseException(exception, executionContext);
return;
}
}
- // rollback the actions
- // rollbackActions(executionContext);
-
- // if there is no parent, throw a delegation exception to the client
+ // if exception was not handled, throw delegation exception to client
throw exception instanceof JbpmException ? (JbpmException) exception
- : new DelegationException(exception, executionContext);
+ : new DelegationException(exception, executionContext);
}
/**
@@ -382,19 +369,18 @@
* <li>an active transaction, or no transaction at all</li>
* </ul>
*/
- private static boolean isAbleToHandleExceptions(
- ExecutionContext executionContext) {
+ private static boolean isAbleToHandleExceptions(ExecutionContext executionContext) {
/*
- * if an exception is already set, we are already handling an exception; in
- * this case don't give the exception to the handlers but throw it to the
- * client see
https://jira.jboss.org/jira/browse/JBPM-1887
+ * if an exception is already set, we are already handling an exception; in this case
don't
+ * give the exception to the handlers but throw it to the client see
+ *
https://jira.jboss.org/jira/browse/JBPM-1887
*/
if (executionContext.getException() != null) return false;
/*
- * check whether the transaction is still active before scanning the
- * exception handlers. that way we can load the exception handlers lazily
- * see
https://jira.jboss.org/jira/browse/JBPM-1775
+ * check whether the transaction is still active before scanning the exception
handlers.
+ * that way we can load the exception handlers lazily see
+ *
https://jira.jboss.org/jira/browse/JBPM-1775
*/
JbpmContext jbpmContext = executionContext.getJbpmContext();
if (jbpmContext != null) {
@@ -428,15 +414,11 @@
* @return the ancestors of this graph element ordered by depth.
*/
public List getParents() {
- List parents;
GraphElement parent = getParent();
- if (parent != null) {
- parents = new ArrayList();
- parent.addParentChain(parents);
- }
- else {
- parents = Collections.EMPTY_LIST;
- }
+ if (parent == null) return Collections.EMPTY_LIST;
+
+ List parents = new ArrayList();
+ parent.addParentChain(parents);
return parents;
}
@@ -445,16 +427,14 @@
*/
public List getParentChain() {
List parents = new ArrayList();
- this.addParentChain(parents);
+ addParentChain(parents);
return parents;
}
- void addParentChain(List parentChain) {
+ private void addParentChain(List parentChain) {
parentChain.add(this);
GraphElement parent = getParent();
- if (parent != null) {
- parent.addParentChain(parentChain);
- }
+ if (parent != null) parent.addParentChain(parentChain);
}
// equals ///////////////////////////////////////////////////////////////////
@@ -473,8 +453,7 @@
if (name != null && parent != null) {
result = name.equals(other.getName());
}
- else if (parent instanceof NodeCollection
- && otherParent instanceof NodeCollection) {
+ else if (parent instanceof NodeCollection && otherParent instanceof
NodeCollection) {
NodeCollection nodeCollection = (NodeCollection) parent;
int index = nodeCollection.getNodes().indexOf(this);
assert index != -1 : nodeCollection.getNodes();
@@ -511,7 +490,7 @@
public String toString() {
return ClassUtil.getSimpleName(getClass())
+ (name != null ? '(' + name + ')' : id != 0 ? "(" + id +
')'
- : '@' + Integer.toHexString(hashCode()));
+ : '@' + Integer.toHexString(hashCode()));
}
// getters and setters //////////////////////////////////////////////////////
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Node.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Node.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Node.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -117,8 +117,8 @@
};
/**
- * @deprecated arrays are mutable and thus vulnerable to external
- * manipulation. use {@link #getSupportedEventTypes()} instead
+ * @deprecated arrays are mutable and thus vulnerable to external manipulation. use
+ * {@link #getSupportedEventTypes()} instead
*/
public static final String[] supportedEventTypes = (String[]) EVENT_TYPES.clone();
@@ -180,8 +180,7 @@
}
/**
- * creates a bidirection relation between this node and the given leaving
- * transition.
+ * creates a bidirection relation between this node and the given leaving transition.
*
* @throws IllegalArgumentException if leavingTransition is null.
*/
@@ -197,8 +196,7 @@
}
/**
- * removes the bidirectional relation between this node and the given leaving
- * transition.
+ * removes the bidirectional relation between this node and the given leaving
transition.
*
* @throws IllegalArgumentException if leavingTransition is null.
*/
@@ -213,19 +211,18 @@
}
/**
- * checks for the presence of a leaving transition with the given name. the
- * leaving transitions of the supernode are taken into account as well.
+ * checks for the presence of a leaving transition with the given name. the leaving
+ * transitions of the supernode are taken into account as well.
*
- * @return true if this node has a leaving transition with the given name,
- * false otherwise.
+ * @return true if this node has a leaving transition with the given name, false
otherwise.
*/
public boolean hasLeavingTransition(String transitionName) {
return getLeavingTransition(transitionName) != null;
}
/**
- * retrieves a leaving transition by name. the leaving transitions of the
- * supernode are taken into account as well.
+ * retrieves a leaving transition by name. the leaving transitions of the supernode are
taken
+ * into account as well.
*/
public Transition getLeavingTransition(String transitionName) {
if (leavingTransitions != null) {
@@ -247,8 +244,7 @@
}
/**
- * generates a new name for a transition that will be added as a leaving
- * transition.
+ * generates a new name for a transition that will be added as a leaving transition.
*/
public String generateNextLeavingTransitionName() {
String name = null;
@@ -292,8 +288,7 @@
}
/**
- * moves one leaving transition from the oldIndex and inserts it at the
- * newIndex.
+ * moves one leaving transition from the oldIndex and inserts it at the newIndex.
*/
public void reorderLeavingTransition(int oldIndex, int newIndex) {
if (leavingTransitions != null && Math.min(oldIndex, newIndex) >= 0
@@ -313,8 +308,7 @@
}
/**
- * add a bidirection relation between this node and the given arriving
- * transition.
+ * add a bidirection relation between this node and the given arriving transition.
*
* @throws IllegalArgumentException if t is null.
*/
@@ -329,8 +323,7 @@
}
/**
- * removes the bidirection relation between this node and the given arriving
- * transition.
+ * removes the bidirection relation between this node and the given arriving
transition.
*
* @throws IllegalArgumentException if t is null.
*/
@@ -346,8 +339,7 @@
// various //////////////////////////////////////////////////////////////////
/**
- * is the {@link SuperState} or the {@link ProcessDefinition} in which this
- * node is contained.
+ * is the {@link SuperState} or the {@link ProcessDefinition} in which this node is
contained.
*/
public GraphElement getParent() {
GraphElement parent;
@@ -404,35 +396,26 @@
public void execute(ExecutionContext executionContext) {
// if there is a custom action associated with this node
if (action != null) {
- try {
- // execute the action
- executeAction(action, executionContext);
- }
- catch (RuntimeException exception) {
- // NOTE that Errors are not caught because that might halt the JVM
- // and mask the original Error.
- // search for an exception handler or throw to the client
- raiseException(exception, executionContext);
- }
+ // execute the action
+ executeAction(action, executionContext);
}
else {
- // let this node handle the token
- // the default behaviour is to leave the node over the default transition.
+ // leave the node over the default transition
leave(executionContext);
}
}
/**
- * called by the implementation of this node to continue execution over the
- * default transition.
+ * called by the implementation of this node to continue execution over the default
+ * transition.
*/
public void leave(ExecutionContext executionContext) {
leave(executionContext, getDefaultLeavingTransition());
}
/**
- * called by the implementation of this node to continue execution over the
- * specified transition.
+ * called by the implementation of this node to continue execution over the specified
+ * transition.
*/
public void leave(ExecutionContext executionContext, String transitionName) {
Transition transition = getLeavingTransition(transitionName);
@@ -442,8 +425,7 @@
}
/**
- * called by the implementation of this node to continue execution over the
- * given transition.
+ * called by the implementation of this node to continue execution over the given
transition.
*/
public void leave(ExecutionContext executionContext, Transition transition) {
if (transition == null) throw new JbpmException("transition is null");
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -76,10 +76,10 @@
protected List comments;
protected ProcessInstance subProcessInstance;
protected int nextLogIndex;
- boolean isAbleToReactivateParent = true;
- boolean isTerminationImplicit;
- boolean isSuspended;
- String lock;
+ private boolean isAbleToReactivateParent = true;
+ private boolean isTerminationImplicit;
+ private boolean isSuspended;
+ private String lock;
// constructors
// /////////////////////////////////////////////////////
@@ -637,17 +637,17 @@
*
* @see #unlock(String)
*/
- public void lock(String lockOwnerId) {
- if (lockOwnerId == null) {
+ public void lock(String lockOwner) {
+ if (lockOwner == null) {
throw new JbpmException("lock owner is null");
}
if (lock == null) {
- lock = lockOwnerId;
- log.debug('\'' + lockOwnerId + "' locked " + this);
+ lock = lockOwner;
+ log.debug('\'' + lockOwner + "' locked " + this);
}
- else if (!lock.equals(lockOwnerId)) {
- throw new JbpmException('\'' + lockOwnerId + "' cannot lock
" + this + " because '"
+ else if (!lock.equals(lockOwner)) {
+ throw new JbpmException('\'' + lockOwner + "' cannot lock
" + this + " because '"
+ lock + "' already locked it");
}
}
@@ -655,14 +655,14 @@
/**
* @see #lock(String)
*/
- public void unlock(String lockOwnerId) {
+ public void unlock(String lockOwner) {
if (lock != null) {
- if (!lock.equals(lockOwnerId)) {
- throw new JbpmException('\'' + lockOwnerId + "' cannot
unlock " + this + " because '"
+ if (!lock.equals(lockOwner)) {
+ throw new JbpmException('\'' + lockOwner + "' cannot unlock
" + this + " because '"
+ lock + "' locked it");
}
lock = null;
- log.debug('\'' + lockOwnerId + "' unlocked " + this);
+ log.debug('\'' + lockOwner + "' unlocked " + this);
}
else {
log.warn(this + " was already unlocked");
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -89,64 +89,64 @@
Thread.currentThread().setContextClassLoader(processClassLoader);
Transition transition = null;
- try {
- if (decisionDelegation != null) {
- DecisionHandler decisionHandler = (DecisionHandler)
decisionDelegation.getInstance();
+ if (decisionDelegation != null) {
+ DecisionHandler decisionHandler = (DecisionHandler)
decisionDelegation.getInstance();
+ try {
String transitionName = decisionHandler.decide(executionContext);
transition = getLeavingTransition(transitionName);
if (transition == null) {
throw new JbpmException("no such transition: " + transitionName);
}
}
- else if (decisionExpression != null) {
- Object result = JbpmExpressionEvaluator.evaluate(decisionExpression,
executionContext);
- if (result == null) {
- throw new JbpmException("expression evaluated to null: " +
decisionExpression);
+ catch (Exception e) {
+ raiseException(e, executionContext);
+ }
+ }
+ else if (decisionExpression != null) {
+ Object result = JbpmExpressionEvaluator.evaluate(decisionExpression,
executionContext);
+ if (result == null) {
+ throw new JbpmException("expression evaluated to null: " +
decisionExpression);
+ }
+ String transitionName = result.toString();
+ transition = getLeavingTransition(transitionName);
+ if (transition == null) {
+ throw new JbpmException("no such transition: " + transitionName);
+ }
+ }
+ else if (decisionConditions != null && !decisionConditions.isEmpty()) {
+ // backwards compatible mode based on separate DecisionConditions
+ for (Iterator iter = decisionConditions.iterator(); iter.hasNext();) {
+ DecisionCondition decisionCondition = (DecisionCondition) iter.next();
+ // evaluate condition
+ String expression = decisionCondition.getExpression();
+ Object result = JbpmExpressionEvaluator.evaluate(expression,
executionContext);
+ // if condition was true
+ if (Boolean.TRUE.equals(result)) {
+ // fetch name associated to condition
+ String transitionName = decisionCondition.getTransitionName();
+ // select transition by name
+ transition = getLeavingTransition(transitionName);
+ if (transition != null) break;
}
- String transitionName = result.toString();
- transition = getLeavingTransition(transitionName);
- if (transition == null) {
- throw new JbpmException("no such transition: " + transitionName);
- }
}
- else if (decisionConditions != null && !decisionConditions.isEmpty()) {
- // backwards compatible mode based on separate DecisionConditions
- for (Iterator iter = decisionConditions.iterator(); iter.hasNext();) {
- DecisionCondition decisionCondition = (DecisionCondition) iter.next();
- // evaluate condition
- String expression = decisionCondition.getExpression();
- Object result = JbpmExpressionEvaluator.evaluate(expression,
executionContext);
+ }
+ else {
+ // new mode based on conditions in the transition itself
+ for (Iterator iter = leavingTransitions.iterator(); iter.hasNext();) {
+ Transition candidate = (Transition) iter.next();
+ // evaluate condition if present
+ String condition = candidate.getCondition();
+ if (condition != null) {
+ Object result = JbpmExpressionEvaluator.evaluate(condition,
executionContext);
// if condition was true
if (Boolean.TRUE.equals(result)) {
- // fetch name associated to condition
- String transitionName = decisionCondition.getTransitionName();
- // select transition by name
- transition = getLeavingTransition(transitionName);
- if (transition != null) break;
+ // select transition associated to condition
+ transition = candidate;
+ break;
}
}
}
- else {
- // new mode based on conditions in the transition itself
- for (Iterator iter = leavingTransitions.iterator(); iter.hasNext();) {
- Transition candidate = (Transition) iter.next();
- // evaluate condition if present
- String condition = candidate.getCondition();
- if (condition != null) {
- Object result = JbpmExpressionEvaluator.evaluate(condition,
executionContext);
- // if condition was true
- if (Boolean.TRUE.equals(result)) {
- // select transition associated to condition
- transition = candidate;
- break;
- }
- }
- }
- }
}
- catch (Exception exception) {
- raiseException(exception, executionContext);
- }
// if no transition was selected, just take the default
if (transition == null) {
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/MailNode.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/MailNode.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/MailNode.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -24,16 +24,9 @@
}
public void execute(ExecutionContext executionContext) {
- try {
- // execute mail action
- executeAction(action, executionContext);
- }
- catch (RuntimeException exception) {
- // NOTE that Errors are not caught because that might halt the JVM
- // and mask the original Error.
- // search for an exception handler or throw to the client
- raiseException(exception, executionContext);
- }
+ // execute mail action
+ executeAction(action, executionContext);
+ // leave the node over the default transition
leave(executionContext);
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -20,13 +20,13 @@
private static final long serialVersionUID = 1L;
- static BusinessCalendar businessCalendar = new BusinessCalendar();
+ private static BusinessCalendar businessCalendar = new BusinessCalendar();
- String name;
- String repeat;
- String transitionName;
- Action action;
- GraphElement graphElement;
+ private String name;
+ private String repeat;
+ private String transitionName;
+ private Action action;
+ private GraphElement graphElement;
public Timer() {
}
@@ -50,35 +50,12 @@
// then execute the action if there is one
if (action != null) {
- try {
- log.debug("executing " + this);
- if (graphElement != null) {
- graphElement.executeAction(action, executionContext);
- }
- else {
- action.execute(executionContext);
- }
+ log.debug("executing " + this);
+ if (graphElement != null) {
+ graphElement.executeAction(action, executionContext);
}
- catch (Exception actionException) {
- // NOTE that Errors are not caught because that might halt the JVM
- // and mask the original Error.
- log.warn("timer action threw exception", actionException);
- // if there is a graphElement connected to this timer...
- if (graphElement != null) {
- try {
- // give that graphElement a chance to catch the exception
- graphElement.raiseException(actionException, executionContext);
- log.debug("timer exception got handled by " + graphElement);
- }
- catch (RuntimeException handlerException) {
- // if the exception handler rethrows or the original exception
- // results in a DelegationException...
- throw handlerException;
- }
- }
- else {
- throw actionException;
- }
+ else {
+ action.execute(executionContext);
}
}
@@ -116,7 +93,6 @@
// (b) the engine knows it is not executing and can be deleted
// see
https://jira.jboss.org/jira/browse/JBPM-2036
lockOwner = null;
-
return false;
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/ELException.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/ELException.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/ELException.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -1,95 +1,75 @@
/*
-* Copyright 2004 The Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*
http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jbpm.jpdl.el;
import org.jbpm.JbpmException;
-
/**
- * Represents any of the exception conditions that arise during the
- * operation evaluation of the evaluator.
- *
+ * Represents any of the exception conditions that arise during the operation evaluation
of the
+ * evaluator.
+ *
* @since 2.0
*/
-public class ELException
- extends JbpmException
-{
- private static final long serialVersionUID = 1L;
+public class ELException extends JbpmException {
- //-------------------------------------
- // Member variables
- //-------------------------------------
+ private static final long serialVersionUID = 2L;
- private Throwable mRootCause;
-
- //-------------------------------------
/**
* Creates an ELException with no detail message.
**/
- public ELException ()
- {
- super ();
+ public ELException() {
+ super();
}
- //-------------------------------------
/**
* Creates an ELException with the provided detail message.
- *
+ *
* @param pMessage the detail message
**/
- public ELException (String pMessage)
- {
- super (pMessage);
+ public ELException(String pMessage) {
+ super(pMessage);
}
- //-------------------------------------
/**
* Creates an ELException with the given root cause.
- *
+ *
* @param pRootCause the originating cause of this exception
**/
- public ELException (Throwable pRootCause)
- {
- super( pRootCause.getLocalizedMessage() );
- mRootCause = pRootCause;
+ public ELException(Throwable pRootCause) {
+ super(pRootCause);
}
- //-------------------------------------
/**
* Creates an ELException with the given detail message and root cause.
- *
+ *
* @param pMessage the detail message
* @param pRootCause the originating cause of this exception
**/
- public ELException (String pMessage,
- Throwable pRootCause)
- {
- super (pMessage);
- mRootCause = pRootCause;
+ public ELException(String pMessage, Throwable pRootCause) {
+ super(pMessage, pRootCause);
}
- //-------------------------------------
/**
* Returns the root cause.
- *
+ *
* @return the root cause of this exception
*/
- public Throwable getRootCause ()
- {
- return mRootCause;
+ public Throwable getRootCause() {
+ return getCause();
}
+
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -2,10 +2,8 @@
import java.util.regex.Pattern;
-import org.jbpm.JbpmException;
import org.jbpm.JbpmConfiguration.Configs;
import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.jpdl.el.ELException;
import org.jbpm.jpdl.el.ExpressionEvaluator;
import org.jbpm.jpdl.el.VariableResolver;
import org.jbpm.jpdl.el.FunctionMapper;
@@ -59,11 +57,6 @@
return getExpressionEvaluator().evaluate(dollarExpression, Object.class,
variableResolver, functionMapper);
}
- catch (ELException e) {
- Throwable rootCause = e.getRootCause();
- throw new JbpmException("failed to evaluate " + expression,
- rootCause != null ? rootCause : e);
- }
finally {
ExecutionContext.popCurrentContext(executionContext);
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -80,8 +80,7 @@
private Map customSessions;
/**
- * @deprecated for access to other services, invoke
- * {@link JbpmContext#getServices()}
+ * @deprecated for access to other services, invoke {@link JbpmContext#getServices()}
*/
protected Services services;
@@ -101,21 +100,18 @@
Connection connection = getConnection(false);
if (isCurrentSessionEnabled) {
session = getSessionFactory().getCurrentSession();
- log.debug("using current " + session);
mustSessionBeClosed = false;
mustSessionBeFlushed = false;
mustConnectionBeClosed = false;
}
else if (connection != null) {
session = getSessionFactory().openSession(connection);
- log.debug("created " + session);
mustSessionBeClosed = true;
mustSessionBeFlushed = true;
mustConnectionBeClosed = false;
}
else {
session = getSessionFactory().openSession();
- log.debug("created " + session);
mustSessionBeClosed = true;
mustSessionBeFlushed = true;
mustConnectionBeClosed = false;
@@ -127,9 +123,7 @@
}
public void beginTransaction() {
- log.debug("beginning hibernate transaction");
transaction = session.beginTransaction();
- log.debug("begun " + transaction);
}
public void endTransaction() {
@@ -186,10 +180,9 @@
if (session != null) {
connection = session.connection();
/*
- * If the session is using aggressive collection release (as in a CMT
- * environment), the application is responsible for closing the
- * returned connection. Otherwise, the application should not close
- * the connection.
+ * If the session is using aggressive collection release (as in a CMT
environment),
+ * the application is responsible for closing the returned connection.
Otherwise, the
+ * application should not close the connection.
*/
Configuration configuration = persistenceServiceFactory.getConfiguration();
String releaseMode =
configuration.getProperty(Environment.RELEASE_CONNECTIONS);
@@ -249,7 +242,6 @@
}
protected Exception commit() {
- log.debug("committing " + transaction);
mustSessionBeFlushed = false; // commit does a flush anyway
try {
transaction.commit();
@@ -262,7 +254,6 @@
}
protected Exception rollback() {
- log.debug("rolling back " + transaction);
// flushing updates that will be rolled back is not very clever :-)
mustSessionBeFlushed = false;
try {
@@ -277,7 +268,6 @@
private Exception flushSession() {
if (mustSessionBeFlushed) {
- log.debug("flushing " + session);
try {
session.flush();
}
@@ -292,7 +282,6 @@
private Exception closeSession() {
if (mustSessionBeClosed) {
if (session.isOpen()) {
- log.debug("closing hibernate session");
try {
session.close();
}
@@ -311,7 +300,6 @@
private Exception closeConnection() {
if (mustConnectionBeClosed) {
if (connection != null) {
- log.debug("closing jdbc connection");
try {
connection.close();
}
@@ -412,7 +400,7 @@
}
public DataSource getDataSource() {
- return persistenceServiceFactory.dataSource;
+ return persistenceServiceFactory.getDataSource();
}
/**
@@ -431,8 +419,7 @@
/**
* @deprecated use {@link TxService#setRollbackOnly()} instead
- * @throws IllegalArgumentException if <code>rollbackOnly</code> is
- * <code>false</code>
+ * @throws IllegalArgumentException if <code>rollbackOnly</code> is
<code>false</code>
*/
public void setRollbackOnly(boolean rollbackOnly) {
if (!rollbackOnly) {
@@ -453,21 +440,18 @@
}
/**
- * Injects an external Hibernate session without affecting transaction
- * management.
+ * Injects an external Hibernate session without affecting transaction management.
*
- * @deprecated call {@link #setSession(Session, boolean) setSession(session,
- * true)} instead
+ * @deprecated call {@link #setSession(Session, boolean) setSession(session, true)}
instead
*/
public void setSessionWithoutDisablingTx(Session session) {
setSession(session, true);
}
/**
- * Injects an external Hibernate session. Injecting a session normally
- * disables transaction management. The
<code>keepTransactionEnabled</code>
- * parameter can be used to prevent transaction management from being
- * disabled, according to the following table.
+ * Injects an external Hibernate session. Injecting a session normally disables
transaction
+ * management. The <code>keepTransactionEnabled</code> parameter can be
used to prevent
+ * transaction management from being disabled, according to the following table.
* <table border="1">
* <tr>
* <th>is currently enabled?</th>
@@ -493,10 +477,7 @@
*/
public void setSession(Session session, boolean keepTransactionEnabled) {
this.session = session;
- if (isTransactionEnabled && !keepTransactionEnabled) {
- log.debug("disabling transaction management due to session injection");
- isTransactionEnabled = false;
- }
+ if (isTransactionEnabled && !keepTransactionEnabled) isTransactionEnabled =
false;
}
public void setConnection(Connection connection) {
@@ -508,7 +489,7 @@
}
public void setDataSource(DataSource dataSource) {
- this.persistenceServiceFactory.dataSource = dataSource;
+ persistenceServiceFactory.setDataSource(dataSource);
}
public void setGraphSession(GraphSession graphSession) {
@@ -528,7 +509,7 @@
}
public void setSessionFactory(SessionFactory sessionFactory) {
- this.persistenceServiceFactory.sessionFactory = sessionFactory;
+ persistenceServiceFactory.setSessionFactory(sessionFactory);
}
public Transaction getTransaction() {
@@ -562,5 +543,5 @@
return false;
}
- private static Log log = LogFactory.getLog(DbPersistenceService.class);
+ private static final Log log = LogFactory.getLog(DbPersistenceService.class);
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -23,8 +23,6 @@
import javax.sql.DataSource;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
@@ -39,22 +37,22 @@
private static final long serialVersionUID = 1L;
- Configuration configuration;
+ private Configuration configuration;
String sessionFactoryJndiName;
- SessionFactory sessionFactory;
+ private SessionFactory sessionFactory;
String dataSourceJndiName;
- DataSource dataSource;
+ private DataSource dataSource;
boolean isTransactionEnabled = true;
boolean isCurrentSessionEnabled;
- SchemaExport schemaExport;
- JbpmSchema jbpmSchema;
+ /** @deprecated use {@link #jbpmSchema} instead */
+ private SchemaExport schemaExport;
+ private JbpmSchema jbpmSchema;
public Service openService() {
- log.debug("creating persistence service");
return new DbPersistenceService(this);
}
@@ -93,7 +91,6 @@
public synchronized SessionFactory getSessionFactory() {
if (sessionFactory == null) {
if (sessionFactoryJndiName != null) {
- log.debug("looking up session factory bound to " +
sessionFactoryJndiName);
sessionFactory = (SessionFactory) JndiUtil.lookup(sessionFactoryJndiName,
SessionFactory.class);
}
else {
@@ -105,7 +102,6 @@
public DataSource getDataSource() {
if (dataSource == null && dataSourceJndiName != null) {
- log.debug("looking up data source bound to " + dataSourceJndiName);
dataSource = (DataSource) JndiUtil.lookup(dataSourceJndiName, DataSource.class);
}
return dataSource;
@@ -191,5 +187,4 @@
this.isCurrentSessionEnabled = isCurrentSessionEnabled;
}
- private static Log log = LogFactory.getLog(DbPersistenceServiceFactory.class);
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/svc/Services.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/svc/Services.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -63,7 +63,7 @@
public static final String SERVICENAME_JCR = "jcr";
public static final String SERVICENAME_ADDRESSRESOLVER = "addressresolver";
- static final List defaultSaveOperations = createDefaultSaveOperations();
+ private static final List defaultSaveOperations = createDefaultSaveOperations();
private static List createDefaultSaveOperations() {
SaveOperation[] operations = new SaveOperation[4];
@@ -77,10 +77,10 @@
return Arrays.asList(operations);
}
- final Map serviceFactories;
- Map services;
- List serviceNames;
- List saveOperations;
+ private final Map serviceFactories;
+ private final List serviceNames;
+ private final Map services;
+ private List saveOperations = defaultSaveOperations;
public static Service getCurrentService(String name) {
return getCurrentService(name, true);
@@ -108,7 +108,8 @@
}
this.serviceFactories = serviceFactories;
this.serviceNames = serviceNames;
- this.saveOperations = saveOperations != null ? saveOperations :
defaultSaveOperations;
+ this.services = new HashMap(serviceFactories.size());
+ if (saveOperations != null) this.saveOperations = saveOperations;
}
public void setSaveOperations(List saveOperations) {
@@ -137,13 +138,10 @@
}
public boolean hasService(String name) {
- return services != null ? services.containsKey(name) : false;
+ return services.containsKey(name);
}
public Service getService(String name) {
- if (services == null) {
- services = new HashMap();
- }
Service service = (Service) services.get(name);
if (service == null) {
ServiceFactory serviceFactory = getServiceFactory(name);
@@ -225,8 +223,6 @@
}
public void close() {
- if (services == null) return;
-
RuntimeException firstException = null;
for (Iterator iter = serviceNames.iterator(); iter.hasNext();) {
String serviceName = (String) iter.next();
@@ -234,7 +230,6 @@
if (service == null) continue;
try {
- log.debug("closing '" + serviceName + "' service");
service.close();
}
catch (RuntimeException e) {
@@ -244,8 +239,8 @@
else {
// if this is a locking exception, keep it quiet
if (DbPersistenceService.isLockingException(e)) {
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
- "problem closing '" + serviceName + "'
service", e);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("problem
closing '"
+ + serviceName + "' service", e);
}
else {
log.error("problem closing '" + serviceName + "'
service", e);
@@ -256,7 +251,7 @@
if (firstException != null) throw firstException;
}
-
+
public static boolean isCausedByStaleState(JbpmPersistenceException
persistenceException) {
return DbPersistenceService.isLockingException(persistenceException);
}
@@ -273,5 +268,5 @@
}
}
- private static Log log = LogFactory.getLog(Services.class);
+ private static final Log log = LogFactory.getLog(Services.class);
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -62,12 +62,12 @@
private static final long serialVersionUID = 1L;
- TaskMgmtDefinition taskMgmtDefinition;
- Map swimlaneInstances;
- Set taskInstances;
+ private TaskMgmtDefinition taskMgmtDefinition;
+ private Map swimlaneInstances;
+ private Set taskInstances;
/** stores task instances having variable updates. not persisted. */
- Collection taskInstanceVariableUpdates;
+ private Collection taskInstanceVariableUpdates;
public TaskMgmtInstance() {
}
@@ -215,8 +215,7 @@
swimlaneInstance = new SwimlaneInstance(swimlane);
addSwimlaneInstance(swimlaneInstance);
// assign the swimlaneInstance
- performAssignment(swimlane.getAssignmentDelegation(),
swimlane.getActorIdExpression(),
- swimlane.getPooledActorsExpression(), swimlaneInstance, executionContext);
+ performAssignment(swimlane.getAssignmentDelegation(),
swimlane.getActorIdExpression(), swimlane.getPooledActorsExpression(), swimlaneInstance,
executionContext);
}
return swimlaneInstance;
@@ -224,27 +223,25 @@
public void performAssignment(Delegation assignmentDelegation, String
actorIdExpression,
String pooledActorsExpression, Assignable assignable, ExecutionContext
executionContext) {
- try {
- if (assignmentDelegation != null) {
+ if (assignmentDelegation != null) {
+ try {
performAssignmentDelegation(assignmentDelegation, assignable, executionContext);
}
- else {
- if (actorIdExpression != null) {
- performAssignmentActorIdExpr(actorIdExpression, assignable, executionContext);
- }
- if (pooledActorsExpression != null) {
- performAssignmentPooledActorsExpr(pooledActorsExpression, assignable,
+ catch (Exception e) {
+ GraphElement graphElement = executionContext.getEventSource();
+ if (graphElement == null) {
+ throw e instanceof JbpmException ? (JbpmException) e : new
DelegationException(e,
executionContext);
}
+ graphElement.raiseException(e, executionContext);
}
}
- catch (Exception exception) {
- GraphElement graphElement = executionContext.getEventSource();
- if (graphElement != null) {
- graphElement.raiseException(exception, executionContext);
+ else {
+ if (actorIdExpression != null) {
+ performAssignmentActorIdExpr(actorIdExpression, assignable, executionContext);
}
- else {
- throw new DelegationException(exception, executionContext);
+ if (pooledActorsExpression != null) {
+ performAssignmentPooledActorsExpr(pooledActorsExpression, assignable,
executionContext);
}
}
}
@@ -284,10 +281,8 @@
assignable.setActorId((String) result);
}
else {
- throw new JbpmException("actor-id expression '"
- + actorIdExpression
- + "' did not evaluate to string: '"
- + result);
+ throw new JbpmException("actor-id expression '" + actorIdExpression
+ + "' did not evaluate to string: '" + result);
}
}
@@ -296,8 +291,7 @@
String[] pooledActors = null;
Object result = JbpmExpressionEvaluator.evaluate(pooledActorsExpression,
executionContext);
if (result == null) {
- throw new JbpmException("pooled-actors expression '"
- + pooledActorsExpression
+ throw new JbpmException("pooled-actors expression '" +
pooledActorsExpression
+ "' returned null");
}
@@ -316,18 +310,16 @@
}
}
else {
- throw new JbpmException("pooled-actors expression '"
- + pooledActorsExpression
- + "' did not evaluate to comma-separated string, collection or string
array: "
- + result);
+ throw new JbpmException("pooled-actors expression '" +
pooledActorsExpression
+ + "' did not evaluate to comma-separated string, collection or string
array: " + result);
}
assignable.setPooledActors(pooledActors);
}
/**
- * creates a task instance on the rootToken, and assigns it to the currently
- * authenticated user.
+ * creates a task instance on the rootToken, and assigns it to the currently
authenticated
+ * user.
*/
public TaskInstance createStartTaskInstance() {
TaskInstance taskInstance = null;
@@ -350,16 +342,14 @@
}
/**
- * is true if the given token has task instances that keep the token from
- * leaving the current node.
+ * is true if the given token has task instances that keep the token from leaving the
current
+ * node.
*/
public boolean hasBlockingTaskInstances(Token token) {
if (taskInstances != null) {
for (Iterator i = taskInstances.iterator(); i.hasNext();) {
TaskInstance taskInstance = (TaskInstance) i.next();
- if (!taskInstance.hasEnded()
- && taskInstance.isBlocking()
- && token != null
+ if (!taskInstance.hasEnded() && taskInstance.isBlocking() &&
token != null
&& token.equals(taskInstance.getToken())) {
return true;
}
@@ -376,8 +366,7 @@
}
/**
- * is the collection of {@link TaskInstance}s on the given token that are not
- * ended.
+ * is the collection of {@link TaskInstance}s on the given token that are not ended.
*/
public Collection getUnfinishedTasks(Token token) {
Collection unfinishedTasks = new ArrayList();
@@ -393,16 +382,16 @@
}
/**
- * is true if there are {@link TaskInstance}s on the given token that can
- * trigger the token to continue.
+ * is true if there are {@link TaskInstance}s on the given token that can trigger the
token to
+ * continue.
*/
public boolean hasSignallingTasks(ExecutionContext executionContext) {
return (getSignallingTasks(executionContext).size() > 0);
}
/**
- * is the collection of {@link TaskInstance}s for the given token that can
- * trigger the token to continue.
+ * is the collection of {@link TaskInstance}s for the given token that can trigger the
token
+ * to continue.
*/
public Collection getSignallingTasks(ExecutionContext executionContext) {
Collection signallingTasks = new ArrayList();
@@ -419,8 +408,8 @@
}
/**
- * returns all the taskInstances for the this process instance. This includes
- * task instances that have been completed previously.
+ * returns all the taskInstances for the this process instance. This includes task
instances
+ * that have been completed previously.
*/
public Collection getTaskInstances() {
return taskInstances;
@@ -542,8 +531,7 @@
}
/**
- * removes signalling capabilities from all task instances related to the
- * given token.
+ * removes signalling capabilities from all task instances related to the given token.
*/
public void removeSignalling(Token token) {
if (token != null && taskInstances != null) {
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2010-04-13
08:02:00 UTC (rev 6256)
@@ -91,14 +91,6 @@
]]>
</query>
- <query name="GraphSession.findAllProcessInstanceIdsForDefinition">
- <![CDATA[
- select pi.id
- from org.jbpm.graph.exe.ProcessInstance pi
- where pi.processDefinition.id = :processDefinitionId
- ]]>
- </query>
-
<query name="GraphSession.findReferencingProcessStates">
<![CDATA[
select ps
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -33,12 +33,12 @@
protected void setUp() throws Exception {
super.setUp();
JbpmConfiguration.clearJbpmConfigurationStack();
- JbpmConfiguration.defaultObjectFactory = null;
- JbpmConfiguration.instances.clear();
+ JbpmConfiguration.clearInstances();
+ JbpmConfiguration.setDefaultObjectFactory(null);
}
public void testSingleton() {
- JbpmConfiguration.defaultObjectFactory = new ObjectFactoryImpl(null, null);
+ JbpmConfiguration.setDefaultObjectFactory(new ObjectFactoryImpl(null, null));
JbpmConfiguration instance = JbpmConfiguration.getInstance();
assertNotNull(instance);
assertSame(instance, JbpmConfiguration.getInstance());
@@ -48,9 +48,7 @@
public void testDefaultContextCreation() {
JbpmConfiguration jbpmConfiguration =
JbpmConfiguration.parseXmlString("<jbpm-configuration>"
- + " <jbpm-context name='"
- + JbpmContext.DEFAULT_JBPM_CONTEXT_NAME
- + "' />"
+ + " <jbpm-context />"
+ "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
assertNotNull(jbpmConfiguration.createJbpmContext());
@@ -114,7 +112,7 @@
// 'jbpm.cfg.xml' or the static method
JbpmConfiguration.Configs.setDefaultObjectFactory
// to specify the configuration information.
-
JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString("<jbpm-configuration>"
+
JbpmConfiguration.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString("<jbpm-configuration>"
+ " <string name='myproperty'>myvalue</string>"
+ "</jbpm-configuration>"));
assertEquals("myvalue",
JbpmConfiguration.Configs.getString("myproperty"));
@@ -138,7 +136,7 @@
}
public void testDomainModelConfigsWithCustomObjectFactory() {
- JbpmConfiguration.Configs.setDefaultObjectFactory(new CustomObjectFactory());
+ JbpmConfiguration.setDefaultObjectFactory(new CustomObjectFactory());
assertEquals("mycustomfactoriedvalue",
JbpmConfiguration.Configs.getString("myproperty"));
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmContextTest.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmContextTest.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/JbpmContextTest.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -35,8 +35,9 @@
protected void setUp() throws Exception {
super.setUp();
- JbpmConfiguration.instances.clear();
- JbpmConfiguration.defaultObjectFactory = null;
+ JbpmConfiguration.clearJbpmConfigurationStack();
+ JbpmConfiguration.clearInstances();
+ JbpmConfiguration.setDefaultObjectFactory(null);
}
public void testServices() {
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceConfigurationDbTest.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceConfigurationDbTest.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceConfigurationDbTest.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -28,50 +28,48 @@
public class PersistenceConfigurationDbTest extends AbstractJbpmTestCase {
public void testDisableHibernateTransactions() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context>" +
- " <service name='persistence'>" +
- " <factory>" +
- " <bean
class='org.jbpm.persistence.db.DbPersistenceServiceFactory'>" +
- " <field name='isTransactionEnabled'><false
/></field>" +
- " </bean>" +
- " </factory>" +
- " </service>" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration =
JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context>"
+ + " <service name='persistence'>"
+ + " <factory>"
+ + " <bean
class='org.jbpm.persistence.db.DbPersistenceServiceFactory'>"
+ + " <field name='isTransactionEnabled'><false
/></field>"
+ + " </bean>"
+ + " </factory>" + " </service>" + "
</jbpm-context>" + "</jbpm-configuration>");
+
DbPersistenceServiceFactory dbPersistenceServiceFactory =
(DbPersistenceServiceFactory)
jbpmConfiguration.getServiceFactory("persistence");
assertFalse(dbPersistenceServiceFactory.isTransactionEnabled());
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
- DbPersistenceService dbPersistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ DbPersistenceService dbPersistenceService = (DbPersistenceService)
jbpmContext.getServices()
+ .getPersistenceService();
assertFalse(dbPersistenceService.isTransactionEnabled());
assertNull(dbPersistenceService.getTransaction());
- } finally {
+ }
+ finally {
jbpmContext.close();
}
}
public void testDifferentHibernateCfgFile() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context>" +
- " <service name='persistence'
factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
- " </jbpm-context>" +
- " <string name='resource.hibernate.cfg.xml'
value='org/jbpm/persistence/db/custom.hibernate.cfg.xml' />" +
- " <string name='resource.hibernate.properties'
value='org/jbpm/persistence/db/custom.hibernate.properties' />" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration =
JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context>"
+ + " <service name='persistence'
factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />"
+ + " </jbpm-context>"
+ + " <string name='resource.hibernate.cfg.xml'
value='org/jbpm/persistence/db/custom.hibernate.cfg.xml' />"
+ + " <string name='resource.hibernate.properties'
value='org/jbpm/persistence/db/custom.hibernate.properties' />"
+ + "</jbpm-configuration>");
+
DbPersistenceServiceFactory dbPersistenceServiceFactory =
(DbPersistenceServiceFactory)
jbpmConfiguration.getServiceFactory("persistence");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
- DbPersistenceService dbPersistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ DbPersistenceService dbPersistenceService = (DbPersistenceService)
jbpmContext.getServices()
+ .getPersistenceService();
assertEquals(0,
dbPersistenceService.getSessionFactory().getAllClassMetadata().size());
- assertEquals("org.hibernate.dialect.PostgreSQLDialect",
dbPersistenceServiceFactory.configuration.getProperty("hibernate.dialect"));
- } finally {
+ assertEquals("org.hibernate.dialect.PostgreSQLDialect",
dbPersistenceServiceFactory.getConfiguration()
+ .getProperty("hibernate.dialect"));
+ }
+ finally {
jbpmContext.close();
}
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -38,9 +38,9 @@
import org.jbpm.svc.Services;
public class PersistenceServiceDbTest extends AbstractJbpmTestCase {
-
+
private JbpmConfiguration jbpmConfiguration;
-
+
protected void setUp() throws Exception {
super.setUp();
// pristine, unshared configuration object
@@ -54,22 +54,19 @@
public void testDefaults() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceServiceFactory persistenceServiceFactory = null;
- DbPersistenceService persistenceService = null;
-
+ DbPersistenceServiceFactory persistenceServiceFactory;
+ DbPersistenceService persistenceService;
+
try {
persistenceServiceFactory = (DbPersistenceServiceFactory)
jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
-
+ persistenceService = (DbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
+
assertNotNull(persistenceService);
assertSame(persistenceServiceFactory,
persistenceService.persistenceServiceFactory);
-
- assertNull(persistenceServiceFactory.configuration);
- assertNull(persistenceServiceFactory.dataSource);
+
+ assertNull(persistenceServiceFactory.getDataSource());
assertNull(persistenceServiceFactory.dataSourceJndiName);
- assertNull(persistenceServiceFactory.schemaExport);
- assertNull(persistenceServiceFactory.sessionFactory);
assertNull(persistenceServiceFactory.sessionFactoryJndiName);
assertNull(persistenceService.session);
assertNull(persistenceService.transaction);
@@ -79,39 +76,38 @@
assertNull(persistenceService.loggingSession);
assertNull(persistenceService.jobSession);
assertNull(persistenceService.taskMgmtSession);
-
+
Session session = persistenceService.getSession();
assertSame(session, persistenceService.session);
assertNull(persistenceService.connection);
-
- assertNotNull(persistenceServiceFactory.configuration);
- assertNotNull(persistenceServiceFactory.sessionFactory);
+
+ assertNotNull(persistenceServiceFactory.getConfiguration());
+ assertNotNull(persistenceServiceFactory.getSessionFactory());
assertNotNull(persistenceService.transaction);
assertNull(persistenceService.connection);
assertNotNull(persistenceService.session);
- assertNull(persistenceServiceFactory.dataSource);
+ assertNull(persistenceServiceFactory.getDataSource());
assertNull(persistenceServiceFactory.dataSourceJndiName);
- assertNull(persistenceServiceFactory.schemaExport);
assertNull(persistenceServiceFactory.sessionFactoryJndiName);
assertNull(persistenceService.contextSession);
assertNull(persistenceService.graphSession);
assertNull(persistenceService.loggingSession);
assertNull(persistenceService.jobSession);
assertNull(persistenceService.taskMgmtSession);
-
+
assertTrue(persistenceService.transaction.isActive());
assertTrue(persistenceService.session.isOpen());
assertFalse(persistenceService.transaction.wasCommitted());
assertFalse(persistenceService.transaction.wasRolledBack());
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
- assertNotNull(persistenceServiceFactory.configuration);
- assertNotNull(persistenceServiceFactory.sessionFactory);
+ assertNotNull(persistenceServiceFactory.getConfiguration());
+ assertNotNull(persistenceServiceFactory.getSessionFactory());
assertTrue(persistenceService.transaction.wasCommitted());
assertFalse(persistenceService.transaction.isActive());
@@ -122,14 +118,15 @@
public void testRollbackWithoutSessionCreation() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService persistenceService = null;
-
+ DbPersistenceService persistenceService;
+
try {
- persistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ persistenceService = (DbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
jbpmContext.setRollbackOnly();
- } finally {
+ }
+ finally {
jbpmContext.close();
}
assertNull(persistenceService.transaction);
@@ -137,14 +134,16 @@
public void testRollback() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService persistenceService = null;
-
+ DbPersistenceService persistenceService;
+
try {
- persistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ persistenceService = (DbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
+
+ persistenceService.getSession();
jbpmContext.setRollbackOnly();
- persistenceService.getSession();
- } finally {
+ }
+ finally {
jbpmContext.close();
}
@@ -153,29 +152,28 @@
assertTrue(persistenceService.transaction.wasRolledBack());
assertFalse(persistenceService.session.isOpen());
}
-
+
public void testUserSuppliedConnection() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService persistenceService = null;
- Recorded recordedConnection = null;
-
+ Recorded recordedConnection;
+
try {
- persistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ DbPersistenceService persistenceService = (DbPersistenceService)
jbpmContext.getServices()
+ .getPersistenceService();
DataSource dataSource = Jdbc.createRecordedDataSource();
Connection connection = dataSource.getConnection();
persistenceService.setConnection(connection);
Session session = persistenceService.getSession();
-
+
assertNotNull(persistenceService.transaction);
assertSame(session, persistenceService.session);
recordedConnection = (Recorded) connection;
List invocations = recordedConnection.getInvocations();
assertNull(Invocation.getInvocation(invocations, "commit", 0));
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
@@ -183,15 +181,14 @@
assertNotNull(Invocation.getInvocation(invocations, "commit", 0));
assertNull(Invocation.getInvocation(invocations, "close", 0));
}
-
+
public void testUserSuppliedConnectionWithRollback() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService persistenceService = null;
- Recorded recordedConnection = null;
-
+ Recorded recordedConnection;
+
try {
- persistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ DbPersistenceService persistenceService = (DbPersistenceService)
jbpmContext.getServices()
+ .getPersistenceService();
DataSource dataSource = Jdbc.createRecordedDataSource();
Connection connection = dataSource.getConnection();
@@ -199,41 +196,41 @@
Session session = persistenceService.getSession();
jbpmContext.setRollbackOnly();
-
+
assertNotNull(persistenceService.transaction);
assertSame(session, persistenceService.session);
- recordedConnection = (Recorded)connection;
+ recordedConnection = (Recorded) connection;
List invocations = recordedConnection.getInvocations();
assertNull(Invocation.getInvocation(invocations, "commit", 0));
assertNull(Invocation.getInvocation(invocations, "rollback", 0));
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
-
+
List invocations = recordedConnection.getInvocations();
assertNull(Invocation.getInvocation(invocations, "commit", 0));
assertNotNull(Invocation.getInvocation(invocations, "rollback", 0));
}
-
+
public void testUserSuppliedSession() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService persistenceService = null;
-
+ DbPersistenceService persistenceService;
+
try {
- persistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ persistenceService = (DbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
DbPersistenceServiceFactory persistenceServiceFactory =
(DbPersistenceServiceFactory)
jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
Session session = sessionFactory.openSession();
-
+
jbpmContext.setSession(session);
-
+
persistenceService.getSession();
assertNull(persistenceService.transaction);
-
- } finally {
+ }
+ finally {
jbpmContext.close();
}
@@ -244,11 +241,11 @@
public void testUserSuppliedSessionWithRollback() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
try {
DbPersistenceServiceFactory persistenceServiceFactory =
(DbPersistenceServiceFactory)
jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
-
+
DataSource dataSource = Jdbc.createRecordedDataSource();
Connection connection = dataSource.getConnection();
Session session = sessionFactory.openSession(connection);
@@ -256,11 +253,13 @@
jbpmContext.setSession(session);
jbpmContext.setRollbackOnly();
- } finally {
+ }
+ finally {
try {
jbpmContext.close();
fail("expected exception");
- } catch (JbpmException e) {
+ }
+ catch (JbpmException e) {
// OK
}
}
@@ -268,13 +267,16 @@
public void testTransferResponsibility() throws Exception {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- DbPersistenceService dbPersistenceService = null;
+
+ DbPersistenceService dbPersistenceService = null;
Connection connection;
try {
- dbPersistenceService = (DbPersistenceService)
jbpmContext.getServices().getPersistenceService();
+ dbPersistenceService = (DbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
+
connection = jbpmContext.getConnection();
- } finally {
+ }
+ finally {
jbpmContext.close();
}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceFactoryDbTest.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceFactoryDbTest.java 2010-04-09
09:45:02 UTC (rev 6255)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceFactoryDbTest.java 2010-04-13
08:02:00 UTC (rev 6256)
@@ -32,36 +32,30 @@
public class PersistenceServiceFactoryDbTest extends AbstractJbpmTestCase {
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
Jndi.initialize();
}
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
Jndi.reset();
super.tearDown();
}
public void testDefaults() {
DbPersistenceServiceFactory persistenceServiceFactory = new
DbPersistenceServiceFactory();
- assertNull(persistenceServiceFactory.sessionFactory);
SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
assertNotNull(sessionFactory);
- assertSame(sessionFactory, persistenceServiceFactory.sessionFactory);
-
assertNotNull(persistenceServiceFactory.sessionFactory.getClassMetadata(Token.class));
+ assertNotNull(sessionFactory.getClassMetadata(Token.class));
}
public void testJndiDataSource() throws Exception {
- DataSource dataSource = new Jdbc.MockDataSource();
+ DataSource dataSource = new Jdbc.MockDataSource();
Jndi.putInJndi("java:/jdbc/testDataSource", dataSource);
DbPersistenceServiceFactory persistenceServiceFactory = new
DbPersistenceServiceFactory();
persistenceServiceFactory.dataSourceJndiName =
"java:/jdbc/testDataSource";
- assertNull(persistenceServiceFactory.dataSource);
- assertEquals(dataSource, persistenceServiceFactory.getDataSource());
- assertNotNull(persistenceServiceFactory.dataSource);
+ assertSame(dataSource, persistenceServiceFactory.getDataSource());
}
public void testJndiSessionFactory() throws Exception {
@@ -70,17 +64,14 @@
DbPersistenceServiceFactory persistenceServiceFactory = new
DbPersistenceServiceFactory();
persistenceServiceFactory.sessionFactoryJndiName =
"java:/hibernate/testSessionFactory";
- assertNull(persistenceServiceFactory.sessionFactory);
- assertEquals(sessionFactory, persistenceServiceFactory.getSessionFactory());
- assertNotNull(persistenceServiceFactory.sessionFactory);
+ assertSame(sessionFactory, persistenceServiceFactory.getSessionFactory());
}
-
+
private SessionFactory createSimplestSessionFactory() {
Configuration configuration = new Configuration();
-
configuration.setProperty("hibernate.dialect","org.hibernate.dialect.HSQLDialect");
+ configuration.setProperty("hibernate.dialect",
"org.hibernate.dialect.HSQLDialect");
SessionFactory sessionFactory = configuration.buildSessionFactory();
return sessionFactory;
}
-
-
+
}