[jbpm-commits] JBoss JBPM SVN: r3165 - in jbpm3/trunk/modules: core/src/main/java/org/jbpm/db and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 2 10:42:58 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-12-02 10:42:58 -0500 (Tue, 02 Dec 2008)
New Revision: 3165
Added:
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
jbpm3/trunk/modules/integration/spec/.classpath
jbpm3/trunk/modules/integration/spec/deploy.sh
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/client/ProcessEngineImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/jpdl32/DialectHandlerImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/EndEventImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExpressionImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/NodeImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessDefinitionImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/SequenceFlowImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/StartEventImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/TaskImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DeploymentServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DialectHandlerServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/IdentityServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/NoopPersistenceServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentPARTest.java
jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentXMLTest.java
Log:
Update spec integration
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmContext.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmContext.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -27,6 +27,8 @@
import java.util.Iterator;
import java.util.List;
+import javax.management.ObjectName;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -44,118 +44,148 @@
/**
* are the graph related database operations.
*/
-public class GraphSession {
+public class GraphSession
+{
JbpmSession jbpmSession = null;
Session session = null;
-
- public GraphSession(JbpmSession jbpmSession) {
+
+ public GraphSession(JbpmSession jbpmSession)
+ {
this.jbpmSession = jbpmSession;
this.session = jbpmSession.getSession();
}
- public GraphSession(Session session) {
+ public GraphSession(Session session)
+ {
this.session = session;
this.jbpmSession = new JbpmSession(session);
}
// process definitions //////////////////////////////////////////////////////
-
-
- public void deployProcessDefinition(ProcessDefinition processDefinition) {
+
+ public void deployProcessDefinition(ProcessDefinition processDefinition)
+ {
String processDefinitionName = processDefinition.getName();
// if the process definition has a name (process versioning only applies to named process definitions)
- if (processDefinitionName!=null) {
+ if (processDefinitionName != null)
+ {
// find the current latest process definition
ProcessDefinition previousLatestVersion = findLatestProcessDefinition(processDefinitionName);
// if there is a current latest process definition
- if (previousLatestVersion!=null) {
+ if (previousLatestVersion != null)
+ {
// take the next version number
- processDefinition.setVersion( previousLatestVersion.getVersion()+1 );
- } else {
+ processDefinition.setVersion(previousLatestVersion.getVersion() + 1);
+ }
+ else
+ {
// start from 1
processDefinition.setVersion(1);
}
-
+
session.save(processDefinition);
-
- } else {
+
+ }
+ else
+ {
throw new JbpmException("process definition does not have a name");
}
}
-
+
/**
- * saves the process definitions. this method does not assign a version
- * number. that is the responsibility of the {@link #deployProcessDefinition(ProcessDefinition)
- * deployProcessDefinition} method.
+ * saves the process definitions. this method does not assign a version number. that is the responsibility of the
+ * {@link #deployProcessDefinition(ProcessDefinition) deployProcessDefinition} method.
*/
- public void saveProcessDefinition( ProcessDefinition processDefinition ) {
- try {
+ public void saveProcessDefinition(ProcessDefinition processDefinition)
+ {
+ try
+ {
session.save(processDefinition);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't save process definition '" + processDefinition + "'", e);
- }
+ }
}
-
+
/**
* loads a process definition from the database by the identifier.
+ *
* @throws JbpmException in case the referenced process definition doesn't exist.
*/
- public ProcessDefinition loadProcessDefinition(long processDefinitionId) {
- try {
- return (ProcessDefinition) session.load( ProcessDefinition.class, new Long(processDefinitionId) );
- } catch (Exception e) {
+ public ProcessDefinition loadProcessDefinition(long processDefinitionId)
+ {
+ try
+ {
+ return (ProcessDefinition)session.load(ProcessDefinition.class, new Long(processDefinitionId));
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't load process definition '" + processDefinitionId + "'", e);
- }
+ }
}
-
+
/**
* gets a process definition from the database by the identifier.
+ *
* @return the referenced process definition or null in case it doesn't exist.
*/
- public ProcessDefinition getProcessDefinition(long processDefinitionId) {
- try {
- return (ProcessDefinition) session.get( ProcessDefinition.class, new Long(processDefinitionId) );
- } catch (Exception e) {
+ public ProcessDefinition getProcessDefinition(long processDefinitionId)
+ {
+ try
+ {
+ return (ProcessDefinition)session.get(ProcessDefinition.class, new Long(processDefinitionId));
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't get process definition '" + processDefinitionId + "'", e);
- }
+ }
}
-
+
/**
* queries the database for a process definition with the given name and version.
*/
- public ProcessDefinition findProcessDefinition(String name, int version) {
+ public ProcessDefinition findProcessDefinition(String name, int version)
+ {
ProcessDefinition processDefinition = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findProcessDefinitionByNameAndVersion");
query.setString("name", name);
query.setInteger("version", version);
- processDefinition = (ProcessDefinition) query.uniqueResult();
- } catch (Exception e) {
+ processDefinition = (ProcessDefinition)query.uniqueResult();
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
- throw new JbpmException("couldn't get process definition with name '"+name+"' and version '"+version+"'", e);
- }
+ throw new JbpmException("couldn't get process definition with name '" + name + "' and version '" + version + "'", e);
+ }
return processDefinition;
}
-
+
/**
* queries the database for the latest version of a process definition with the given name.
*/
- public ProcessDefinition findLatestProcessDefinition(String name) {
+ public ProcessDefinition findLatestProcessDefinition(String name)
+ {
ProcessDefinition processDefinition = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findLatestProcessDefinitionQuery");
query.setString("name", name);
query.setMaxResults(1);
- processDefinition = (ProcessDefinition) query.uniqueResult();
- } catch (Exception e) {
+ processDefinition = (ProcessDefinition)query.uniqueResult();
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't find process definition '" + name + "'", e);
@@ -164,27 +194,30 @@
}
/**
- * 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() {
+ public List findLatestProcessDefinitions()
+ {
List processDefinitions = new ArrayList();
Map processDefinitionsByName = new HashMap();
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findAllProcessDefinitions");
Iterator iter = query.list().iterator();
- while (iter.hasNext()) {
- ProcessDefinition processDefinition = (ProcessDefinition) iter.next();
+ while (iter.hasNext())
+ {
+ ProcessDefinition processDefinition = (ProcessDefinition)iter.next();
String processDefinitionName = processDefinition.getName();
- ProcessDefinition previous = (ProcessDefinition) processDefinitionsByName.get(processDefinitionName);
- if ( (previous==null)
- || (previous.getVersion()<processDefinition.getVersion())
- ){
+ ProcessDefinition previous = (ProcessDefinition)processDefinitionsByName.get(processDefinitionName);
+ if ((previous == null) || (previous.getVersion() < processDefinition.getVersion()))
+ {
processDefinitionsByName.put(processDefinitionName, processDefinition);
}
}
processDefinitions = new ArrayList(processDefinitionsByName.values());
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't find latest versions of process definitions", e);
@@ -195,284 +228,343 @@
/**
* queries the database for all process definitions, ordered by name (ascending), then by version (descending).
*/
- public List findAllProcessDefinitions() {
- try {
+ public List findAllProcessDefinitions()
+ {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findAllProcessDefinitions");
return query.list();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't find all process definitions", e);
- }
+ }
}
/**
* queries the database for all versions of process definitions with the given name, ordered by version (descending).
*/
- public List findAllProcessDefinitionVersions(String name) {
- try {
+ public List findAllProcessDefinitionVersions(String name)
+ {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findAllProcessDefinitionVersions");
query.setString("name", name);
return query.list();
- } catch (HibernateException e) {
+ }
+ catch (HibernateException e)
+ {
log.error(e);
- throw new JbpmException("couldn't find all versions of process definition '"+name+"'", e);
- }
+ throw new JbpmException("couldn't find all versions of process definition '" + name + "'", e);
+ }
}
- public void deleteProcessDefinition(long processDefinitionId) {
- deleteProcessDefinition(loadProcessDefinition(processDefinitionId));
+ public void deleteProcessDefinition(long processDefinitionId)
+ {
+ deleteProcessDefinition(loadProcessDefinition(processDefinitionId));
}
- public void deleteProcessDefinition(ProcessDefinition processDefinition) {
- if (processDefinition==null) {
+ public void deleteProcessDefinition(ProcessDefinition processDefinition)
+ {
+ if (processDefinition == null)
+ {
throw new JbpmException("processDefinition is null");
}
- try {
+ try
+ {
// delete all the process instances of this definition
- for (ProcessInstance processInstance;
- ((processInstance = findNextProcessInstance(processDefinition)) != null);) {
+ for (ProcessInstance processInstance; ((processInstance = findNextProcessInstance(processDefinition)) != null);)
+ {
deleteProcessInstance(processInstance);
}
List referencingProcessStates = findReferencingProcessStates(processDefinition);
- for (Iterator iter = referencingProcessStates.iterator(); iter.hasNext();) {
- ProcessState processState = (ProcessState) iter.next();
+ for (Iterator iter = referencingProcessStates.iterator(); iter.hasNext();)
+ {
+ ProcessState processState = (ProcessState)iter.next();
processState.setSubProcessDefinition(null);
}
// then delete the process definition
session.delete(processDefinition);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't delete process definition '" + processDefinition.getId() + "'", e);
- }
+ }
}
- protected ProcessInstance findNextProcessInstance(ProcessDefinition processDefinition) {
- return (ProcessInstance) session.createCriteria(ProcessInstance.class)
- .add(Restrictions.eq("processDefinition", processDefinition))
- .setMaxResults(1)
- .uniqueResult();
+ protected ProcessInstance findNextProcessInstance(ProcessDefinition processDefinition)
+ {
+ return (ProcessInstance)session.createCriteria(ProcessInstance.class).add(Restrictions.eq("processDefinition", processDefinition)).setMaxResults(1)
+ .uniqueResult();
}
- protected List findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
+ protected List findReferencingProcessStates(ProcessDefinition subProcessDefinition)
+ {
Query query = session.getNamedQuery("GraphSession.findReferencingProcessStates");
query.setEntity("subProcessDefinition", subProcessDefinition);
return query.list();
}
// process instances ////////////////////////////////////////////////////////
-
+
/**
* @deprecated use {@link org.jbpm.JbpmContext#save(ProcessInstance)} instead.
* @throws UnsupportedOperationException
*/
- public void saveProcessInstance(ProcessInstance processInstance) {
- throw new UnsupportedOperationException("use JbpmContext.save(ProcessInstance) instead");
+ public void saveProcessInstance(ProcessInstance processInstance)
+ {
+ throw new UnsupportedOperationException("use JbpmContext.save(ProcessInstance) instead");
}
/**
- * loads a process instance from the database by the identifier.
- * This throws an exception in case the process instance doesn't exist.
+ * loads a process instance from the database by the identifier. This throws an exception in case the process instance
+ * doesn't exist.
+ *
* @see #getProcessInstance(long)
- * @throws JbpmException in case the process instance doesn't exist.
+ * @throws JbpmException in case the process instance doesn't exist.
*/
- public ProcessInstance loadProcessInstance(long processInstanceId) {
- try {
- ProcessInstance processInstance = (ProcessInstance) session.load( ProcessInstance.class, new Long(processInstanceId) );
+ public ProcessInstance loadProcessInstance(long processInstanceId)
+ {
+ try
+ {
+ ProcessInstance processInstance = (ProcessInstance)session.load(ProcessInstance.class, new Long(processInstanceId));
return processInstance;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't load process instance '" + processInstanceId + "'", e);
- }
+ }
}
/**
- * gets a process instance from the database by the identifier.
- * This method returns null in case the given process instance doesn't exist.
+ * gets a process instance from the database by the identifier. This method returns null in case the given process
+ * instance doesn't exist.
*/
- public ProcessInstance getProcessInstance(long processInstanceId) {
- try {
- ProcessInstance processInstance = (ProcessInstance) session.get( ProcessInstance.class, new Long(processInstanceId) );
+ public ProcessInstance getProcessInstance(long processInstanceId)
+ {
+ try
+ {
+ ProcessInstance processInstance = (ProcessInstance)session.get(ProcessInstance.class, new Long(processInstanceId));
return processInstance;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't get process instance '" + processInstanceId + "'", e);
- }
+ }
}
/**
* loads a token from the database by the identifier.
+ *
* @return the token.
* @throws JbpmException in case the referenced token doesn't exist.
*/
- public Token loadToken(long tokenId) {
- try {
- Token token = (Token) session.load(Token.class, new Long(tokenId));
+ public Token loadToken(long tokenId)
+ {
+ try
+ {
+ Token token = (Token)session.load(Token.class, new Long(tokenId));
return token;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't load token '" + tokenId + "'", e);
- }
+ }
}
/**
* gets a token from the database by the identifier.
- * @return the token or null in case the token doesn't exist.
+ *
+ * @return the token or null in case the token doesn't exist.
*/
- public Token getToken(long tokenId) {
- try {
- Token token = (Token) session.get(Token.class, new Long(tokenId));
+ public Token getToken(long tokenId)
+ {
+ try
+ {
+ Token token = (Token)session.get(Token.class, new Long(tokenId));
return token;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't get token '" + tokenId + "'", e);
- }
+ }
}
/**
* locks a process instance in the database.
*/
- public void lockProcessInstance(long processInstanceId) {
- lockProcessInstance(loadProcessInstance(processInstanceId));
+ public void lockProcessInstance(long processInstanceId)
+ {
+ lockProcessInstance(loadProcessInstance(processInstanceId));
}
/**
* locks a process instance in the database.
*/
- public void lockProcessInstance(ProcessInstance processInstance) {
- try {
- session.lock( processInstance, LockMode.UPGRADE );
- } catch (Exception e) {
+ public void lockProcessInstance(ProcessInstance processInstance)
+ {
+ try
+ {
+ session.lock(processInstance, LockMode.UPGRADE);
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't lock process instance '" + processInstance.getId() + "'", e);
- }
+ }
}
/**
- * fetches all processInstances for the given process definition from the database.
- * The returned list of process instances is sorted start date, youngest first.
+ * fetches all processInstances for the given process definition from the database. The returned list of process
+ * instances is sorted start date, youngest first.
*/
- public List findProcessInstances(long processDefinitionId) {
+ public List findProcessInstances(long processDefinitionId)
+ {
List processInstances = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findAllProcessInstancesForADefinition");
query.setLong("processDefinitionId", processDefinitionId);
processInstances = query.list();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't load process instances for process definition '" + processDefinitionId + "'", e);
- }
+ }
return processInstances;
}
- public void deleteProcessInstance(long processInstanceId) {
- deleteProcessInstance(loadProcessInstance(processInstanceId));
+ public void deleteProcessInstance(long processInstanceId)
+ {
+ deleteProcessInstance(loadProcessInstance(processInstanceId));
}
- public void deleteProcessInstance(ProcessInstance processInstance) {
+ public void deleteProcessInstance(ProcessInstance processInstance)
+ {
deleteProcessInstance(processInstance, true, true);
}
- public void deleteProcessInstance(ProcessInstance processInstance, boolean includeTasks, boolean includeJobs) {
- if (processInstance==null) throw new JbpmException("processInstance is null in JbpmSession.deleteProcessInstance()");
- log.debug("deleting process instance "+processInstance.getId());
-
- try {
+ public void deleteProcessInstance(ProcessInstance processInstance, boolean includeTasks, boolean includeJobs)
+ {
+ if (processInstance == null)
+ throw new JbpmException("processInstance is null in JbpmSession.deleteProcessInstance()");
+ log.debug("deleting process instance " + processInstance.getId());
+
+ try
+ {
// jobs
- if (includeJobs) {
- log.debug("deleting jobs for process instance "+processInstance.getId());
+ if (includeJobs)
+ {
+ log.debug("deleting jobs for process instance " + processInstance.getId());
Query query = session.getNamedQuery("GraphSession.deleteJobsForProcessInstance");
query.setEntity("processInstance", processInstance);
query.executeUpdate();
}
-
+
// tasks
- if (includeTasks) {
+ if (includeTasks)
+ {
Query query = session.getNamedQuery("GraphSession.findTaskInstanceIdsForProcessInstance");
query.setEntity("processInstance", processInstance);
List taskInstanceIds = query.list();
-
- if ( (taskInstanceIds!=null)
- && (!taskInstanceIds.isEmpty())
- ) {
- log.debug("deleting tasks "+taskInstanceIds+" for process instance "+processInstance.getId());
+
+ if ((taskInstanceIds != null) && (!taskInstanceIds.isEmpty()))
+ {
+ log.debug("deleting tasks " + taskInstanceIds + " for process instance " + processInstance.getId());
query = session.getNamedQuery("GraphSession.deleteTaskInstancesById");
query.setParameterList("taskInstanceIds", taskInstanceIds);
}
}
// delete the logs
- log.debug("deleting logs for process instance "+processInstance.getId());
+ log.debug("deleting logs for process instance " + processInstance.getId());
deleteLogs(processInstance);
// delete the tokens and subprocess instances
- log.debug("deleting subprocesses for process instance "+processInstance.getId());
+ log.debug("deleting subprocesses for process instance " + processInstance.getId());
deleteSubProcesses(processInstance.getRootToken());
// null out the parent process token
Token superProcessToken = processInstance.getSuperProcessToken();
- if (superProcessToken!=null) {
- log.debug("nulling property subProcessInstance in superProcessToken "+superProcessToken.getId()+" which is referencing the process instance "+processInstance.getId()+" which is being deleted");
+ if (superProcessToken != null)
+ {
+ log.debug("nulling property subProcessInstance in superProcessToken " + superProcessToken.getId() + " which is referencing the process instance "
+ + processInstance.getId() + " which is being deleted");
superProcessToken.setSubProcessInstance(null);
- }
+ }
// add the process instance
- log.debug("hibernate session delete for process instance "+processInstance.getId());
+ log.debug("hibernate session delete for process instance " + processInstance.getId());
session.delete(processInstance);
-
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't delete process instance '" + processInstance.getId() + "'", e);
- }
+ }
}
- void deleteLogs(ProcessInstance processInstance) {
+ void deleteLogs(ProcessInstance processInstance)
+ {
Query query = session.getNamedQuery("GraphSession.findLogsForProcessInstance");
query.setEntity("processInstance", processInstance);
List logs = query.list();
Iterator iter = logs.iterator();
- while (iter.hasNext()) {
- ProcessLog processLog = (ProcessLog) iter.next();
+ while (iter.hasNext())
+ {
+ ProcessLog processLog = (ProcessLog)iter.next();
session.delete(processLog);
}
}
- void deleteSubProcesses(Token token) {
- if (token!=null) {
+ void deleteSubProcesses(Token token)
+ {
+ if (token != null)
+ {
Query query = session.getNamedQuery("GraphSession.findSubProcessInstances");
query.setEntity("processInstance", token.getProcessInstance());
List processInstances = query.list();
-
- if (processInstances == null || processInstances.isEmpty()) {
- log.debug("no subprocesses to delete for token "+token.getId());
- return;
+
+ if (processInstances == null || processInstances.isEmpty())
+ {
+ log.debug("no subprocesses to delete for token " + token.getId());
+ return;
}
-
+
Iterator iter = processInstances.iterator();
- while (iter.hasNext()) {
- ProcessInstance subProcessInstance = (ProcessInstance) iter.next();
+ while (iter.hasNext())
+ {
+ ProcessInstance subProcessInstance = (ProcessInstance)iter.next();
subProcessInstance.setSuperProcessToken(null);
token.setSubProcessInstance(null);
- log.debug("deleting sub process "+subProcessInstance.getId());
+ log.debug("deleting sub process " + subProcessInstance.getId());
deleteProcessInstance(subProcessInstance);
}
}
}
-
- public static class AverageNodeTimeEntry {
+ public static class AverageNodeTimeEntry
+ {
private long nodeId;
private String nodeName;
private int count;
@@ -480,68 +572,84 @@
private long minDuration;
private long maxDuration;
- public long getNodeId() {
+ public long getNodeId()
+ {
return nodeId;
}
- public void setNodeId(final long nodeId) {
+ public void setNodeId(final long nodeId)
+ {
this.nodeId = nodeId;
}
- public String getNodeName() {
+ public String getNodeName()
+ {
return nodeName;
}
- public void setNodeName(final String nodeName) {
+ public void setNodeName(final String nodeName)
+ {
this.nodeName = nodeName;
}
- public int getCount() {
+ public int getCount()
+ {
return count;
}
- public void setCount(final int count) {
+ public void setCount(final int count)
+ {
this.count = count;
}
- public long getAverageDuration() {
+ public long getAverageDuration()
+ {
return averageDuration;
}
- public void setAverageDuration(final long averageDuration) {
+ public void setAverageDuration(final long averageDuration)
+ {
this.averageDuration = averageDuration;
}
- public long getMinDuration() {
+ public long getMinDuration()
+ {
return minDuration;
}
- public void setMinDuration(final long minDuration) {
+ public void setMinDuration(final long minDuration)
+ {
this.minDuration = minDuration;
}
- public long getMaxDuration() {
+ public long getMaxDuration()
+ {
return maxDuration;
}
- public void setMaxDuration(final long maxDuration) {
+ public void setMaxDuration(final long maxDuration)
+ {
this.maxDuration = maxDuration;
}
}
- public List calculateAverageTimeByNode(final long processDefinitionId, final long minumumDurationMillis) {
+ public List calculateAverageTimeByNode(final long processDefinitionId, final long minumumDurationMillis)
+ {
List results = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.calculateAverageTimeByNode");
query.setLong("processDefinitionId", processDefinitionId);
query.setDouble("minimumDuration", minumumDurationMillis);
List listResults = query.list();
-
- if (listResults!=null) {
+
+ if (listResults != null)
+ {
results = new ArrayList();
Iterator iter = listResults.iterator();
- while (iter.hasNext()) {
- Object[] values = (Object[]) iter.next();
+ while (iter.hasNext())
+ {
+ Object[] values = (Object[])iter.next();
AverageNodeTimeEntry averageNodeTimeEntry = new AverageNodeTimeEntry();
averageNodeTimeEntry.setNodeId(((Number)values[0]).longValue());
@@ -554,7 +662,9 @@
results.add(averageNodeTimeEntry);
}
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't load process instances for process definition '" + processDefinitionId + "'", e);
@@ -562,15 +672,18 @@
return results;
}
-
- public List findActiveNodesByProcessInstance(ProcessInstance processInstance) {
+ public List findActiveNodesByProcessInstance(ProcessInstance processInstance)
+ {
List results = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findActiveNodesByProcessInstance");
query.setEntity("processInstance", processInstance);
results = query.list();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't active nodes for process instance '" + processInstance + "'", e);
@@ -578,15 +691,19 @@
return results;
}
- public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String key) {
+ public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String key)
+ {
ProcessInstance processInstance = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findProcessInstanceByKey");
query.setEntity("processDefinition", processDefinition);
query.setString("key", key);
- processInstance = (ProcessInstance) query.uniqueResult();
+ processInstance = (ProcessInstance)query.uniqueResult();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't get process instance with key '" + key + "'", e);
@@ -594,24 +711,29 @@
return processInstance;
}
- public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String key) {
+ public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String key)
+ {
ProcessInstance processInstance = null;
- try {
+ try
+ {
Query query = session.getNamedQuery("GraphSession.findProcessInstanceByKey");
query.setEntity("processDefinition", processDefinition);
query.setString("key", key);
- processInstance = (ProcessInstance) query.uniqueResult();
- if (processInstance==null) {
- throw new JbpmException("no process instance was found with key "+key);
+ processInstance = (ProcessInstance)query.uniqueResult();
+ if (processInstance == null)
+ {
+ throw new JbpmException("no process instance was found with key " + key);
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error(e);
jbpmSession.handleException();
throw new JbpmException("couldn't load process instance with key '" + key + "'", e);
}
return processInstance;
}
-
+
private static final Log log = LogFactory.getLog(GraphSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -50,15 +50,15 @@
import org.jbpm.util.EqualsUtil;
/**
- * is one execution of a {@link org.jbpm.graph.def.ProcessDefinition}.
- * To create a new process execution of a process definition, just use the
- * {@link #ProcessInstance(ProcessDefinition)}.
+ * is one execution of a {@link org.jbpm.graph.def.ProcessDefinition}. To create a new process execution of a process
+ * definition, just use the {@link #ProcessInstance(ProcessDefinition)}.
*
*/
-public class ProcessInstance implements Serializable {
+public class ProcessInstance implements Serializable
+{
private static final long serialVersionUID = 1L;
-
+
long id = 0;
int version = 0;
protected String key = null;
@@ -76,98 +76,96 @@
// constructors /////////////////////////////////////////////////////////////
- public ProcessInstance() {
+ public ProcessInstance()
+ {
}
/**
- * creates a new process instance for the given process definition,
- * puts the root-token (=main path of execution) in the start state
- * and executes the initial node. In case the initial node is a
- * start-state, it will behave as a wait state.
- * For each of the optional module definitions contained in the
- * {@link ProcessDefinition}, the corresponding module instance
- * will be created.
+ * creates a new process instance for the given process definition, puts the root-token (=main path of execution) in
+ * the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait
+ * state. For each of the optional module definitions contained in the {@link ProcessDefinition}, the corresponding
+ * module instance will be created.
+ *
* @throws JbpmException if processDefinition is null.
*/
- public ProcessInstance(ProcessDefinition processDefinition) {
+ public ProcessInstance(ProcessDefinition processDefinition)
+ {
this(processDefinition, null, null);
}
/**
- * creates a new process instance for the given process definition,
- * puts the root-token (=main path of execution) in the start state
- * and executes the initial node. In case the initial node is a
- * start-state, it will behave as a wait state.
- * For each of the optional module definitions contained in the
- * {@link ProcessDefinition}, the corresponding module instance
- * will be created.
- * @param variables will be inserted into the context variables
- * after the context submodule has been created and before the
- * process-start event is fired, which is also before the execution
- * of the initial node.
+ * creates a new process instance for the given process definition, puts the root-token (=main path of execution) in
+ * the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait
+ * state. For each of the optional module definitions contained in the {@link ProcessDefinition}, the corresponding
+ * module instance will be created.
+ *
+ * @param variables will be inserted into the context variables after the context submodule has been created and
+ * before the process-start event is fired, which is also before the execution of the initial node.
* @throws JbpmException if processDefinition is null.
*/
- public ProcessInstance(ProcessDefinition processDefinition, Map variables) {
+ public ProcessInstance(ProcessDefinition processDefinition, Map variables)
+ {
this(processDefinition, variables, null);
}
/**
- * creates a new process instance for the given process definition,
- * puts the root-token (=main path of execution) in the start state
- * and executes the initial node. In case the initial node is a
- * start-state, it will behave as a wait state.
- * For each of the optional module definitions contained in the
- * {@link ProcessDefinition}, the corresponding module instance
- * will be created.
- * @param variables will be inserted into the context variables
- * after the context submodule has been created and before the
- * process-start event is fired, which is also before the execution
- * of the initial node.
+ * creates a new process instance for the given process definition, puts the root-token (=main path of execution) in
+ * the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait
+ * state. For each of the optional module definitions contained in the {@link ProcessDefinition}, the corresponding
+ * module instance will be created.
+ *
+ * @param variables will be inserted into the context variables after the context submodule has been created and
+ * before the process-start event is fired, which is also before the execution of the initial node.
* @throws JbpmException if processDefinition is null.
*/
- public ProcessInstance(ProcessDefinition processDefinition, Map variables, String key) {
- if (processDefinition==null) throw new JbpmException("can't create a process instance when processDefinition is null");
-
+ public ProcessInstance(ProcessDefinition processDefinition, Map variables, String key)
+ {
+ if (processDefinition == null)
+ throw new JbpmException("can't create a process instance when processDefinition is null");
+
// initialize the members
this.processDefinition = processDefinition;
this.rootToken = new Token(this);
this.start = Clock.getCurrentTime();
this.key = key;
-
+
// if this process instance is created in the context of a persistent operation
Services.assignId(this);
// create the optional definitions
Map definitions = processDefinition.getDefinitions();
// if the state-definition has optional definitions
- if ( definitions != null ) {
+ if (definitions != null)
+ {
instances = new HashMap();
// loop over each optional definition
Iterator iter = definitions.values().iterator();
- while (iter.hasNext()) {
- ModuleDefinition definition = (ModuleDefinition) iter.next();
+ while (iter.hasNext())
+ {
+ ModuleDefinition definition = (ModuleDefinition)iter.next();
// and create the corresponding optional instance
ModuleInstance instance = definition.createInstance();
- if (instance != null) {
- addInstance( instance );
+ if (instance != null)
+ {
+ addInstance(instance);
}
}
}
-
+
// add the creation log
rootToken.addLog(new ProcessInstanceCreateLog());
-
+
// set the variables
ContextInstance contextInstance = getContextInstance();
- if ( (contextInstance!=null)
- && (variables!=null)
- ) {
+ if ((contextInstance != null) && (variables != null))
+ {
contextInstance.addVariables(variables);
}
Node initialNode = rootToken.getNode();
// fire the process start event
- if (initialNode!=null) {
+ if (initialNode != null)
+ {
ExecutionContext executionContext = new ExecutionContext(rootToken);
processDefinition.fireEvent(Event.EVENTTYPE_PROCESS_START, executionContext);
@@ -177,27 +175,34 @@
}
// optional module instances ////////////////////////////////////////////////
-
+
/**
* adds the given optional moduleinstance (bidirectional).
*/
- public ModuleInstance addInstance(ModuleInstance moduleInstance) {
- if (moduleInstance == null) throw new IllegalArgumentException("can't add a null moduleInstance to a process instance");
- if (instances == null) instances = new HashMap();
+ public ModuleInstance addInstance(ModuleInstance moduleInstance)
+ {
+ if (moduleInstance == null)
+ throw new IllegalArgumentException("can't add a null moduleInstance to a process instance");
+ if (instances == null)
+ instances = new HashMap();
instances.put(moduleInstance.getClass().getName(), moduleInstance);
moduleInstance.setProcessInstance(this);
return moduleInstance;
}
/**
- * removes the given optional moduleinstance (bidirectional).
+ * removes the given optional moduleinstance (bidirectional).
*/
- public ModuleInstance removeInstance(ModuleInstance moduleInstance) {
+ public ModuleInstance removeInstance(ModuleInstance moduleInstance)
+ {
ModuleInstance removedModuleInstance = null;
- if (moduleInstance == null) throw new IllegalArgumentException("can't remove a null moduleInstance from a process instance");
- if (instances != null) {
- removedModuleInstance = (ModuleInstance) instances.remove(moduleInstance.getClass().getName());
- if (removedModuleInstance!=null) {
+ if (moduleInstance == null)
+ throw new IllegalArgumentException("can't remove a null moduleInstance from a process instance");
+ if (instances != null)
+ {
+ removedModuleInstance = (ModuleInstance)instances.remove(moduleInstance.getClass().getName());
+ if (removedModuleInstance != null)
+ {
moduleInstance.setProcessInstance(null);
}
}
@@ -205,28 +210,36 @@
}
/**
- * looks up an optional module instance by its class.
+ * looks up an optional module instance by its class.
*/
- public ModuleInstance getInstance(Class clazz) {
+ public ModuleInstance getInstance(Class clazz)
+ {
ModuleInstance moduleInstance = null;
- if ( instances != null ) {
- moduleInstance = (ModuleInstance) instances.get( clazz.getName() );
+ if (instances != null)
+ {
+ moduleInstance = (ModuleInstance)instances.get(clazz.getName());
}
-
- if (moduleInstance==null) {
- if (transientInstances==null) transientInstances = new HashMap();
-
+
+ if (moduleInstance == null)
+ {
+ if (transientInstances == null)
+ transientInstances = new HashMap();
+
// client requested an instance that is not in the map of instances.
// so we can safely assume that the client wants a transient instance
- moduleInstance = (ModuleInstance) transientInstances.get( clazz.getName() );
- if (moduleInstance==null) {
- try {
- moduleInstance = (ModuleInstance) clazz.newInstance();
+ moduleInstance = (ModuleInstance)transientInstances.get(clazz.getName());
+ if (moduleInstance == null)
+ {
+ try
+ {
+ moduleInstance = (ModuleInstance)clazz.newInstance();
moduleInstance.setProcessInstance(this);
- } catch (Exception e) {
- throw new JbpmException("couldn't instantiate transient module '"+clazz.getName()+"' with the default constructor");
}
+ catch (Exception e)
+ {
+ throw new JbpmException("couldn't instantiate transient module '" + clazz.getName() + "' with the default constructor");
+ }
transientInstances.put(clazz.getName(), moduleInstance);
}
}
@@ -237,59 +250,67 @@
/**
* process instance extension for process variableInstances.
*/
- public ContextInstance getContextInstance() {
- return (ContextInstance) getInstance(ContextInstance.class);
+ public ContextInstance getContextInstance()
+ {
+ return (ContextInstance)getInstance(ContextInstance.class);
}
/**
* process instance extension for managing the tasks and actors.
*/
- public TaskMgmtInstance getTaskMgmtInstance() {
- return (TaskMgmtInstance) getInstance(TaskMgmtInstance.class);
+ public TaskMgmtInstance getTaskMgmtInstance()
+ {
+ return (TaskMgmtInstance)getInstance(TaskMgmtInstance.class);
}
/**
- * process instance extension for logging. Probably you don't need to access
- * the logging instance directly. Mostly, {@link Token#addLog(ProcessLog)} is
- * sufficient and more convenient.
+ * process instance extension for logging. Probably you don't need to access the logging instance directly. Mostly,
+ * {@link Token#addLog(ProcessLog)} is sufficient and more convenient.
*/
- public LoggingInstance getLoggingInstance() {
- return (LoggingInstance) getInstance(LoggingInstance.class);
+ public LoggingInstance getLoggingInstance()
+ {
+ return (LoggingInstance)getInstance(LoggingInstance.class);
}
// operations ///////////////////////////////////////////////////////////////
/**
- * instructs the main path of execution to continue by taking the default
- * transition on the current node.
+ * instructs the main path of execution to continue by taking the default transition on the current node.
+ *
* @throws IllegalStateException if the token is not active.
*/
- public void signal() {
- if ( hasEnded() ) {
+ public void signal()
+ {
+ if (hasEnded())
+ {
throw new IllegalStateException("couldn't signal token : token has ended");
}
rootToken.signal();
}
/**
- * instructs the main path of execution to continue by taking the specified
- * transition on the current node.
+ * instructs the main path of execution to continue by taking the specified transition on the current node.
+ *
* @throws IllegalStateException if the token is not active.
*/
- public void signal(String transitionName) {
- if ( hasEnded() ) {
+ public void signal(String transitionName)
+ {
+ if (hasEnded())
+ {
throw new IllegalStateException("couldn't signal token : token has ended");
}
rootToken.signal(transitionName);
}
/**
- * instructs the main path of execution to continue by taking the specified
- * transition on the current node.
+ * instructs the main path of execution to continue by taking the specified transition on the current node.
+ *
* @throws IllegalStateException if the token is not active.
*/
- public void signal( Transition transition ) {
- if ( hasEnded() ) {
+ public void signal(Transition transition)
+ {
+ if (hasEnded())
+ {
throw new IllegalStateException("couldn't signal token : token has ended");
}
rootToken.signal(transition);
@@ -298,35 +319,39 @@
/**
* ends (=cancels) this process instance and all the tokens in it.
*/
- public void end() {
+ public void end()
+ {
// end the main path of execution
rootToken.end();
-
- if (end==null) {
+
+ if (end == null)
+ {
// mark this process instance as ended
end = Clock.getCurrentTime();
-
+
// fire the process-end event
ExecutionContext executionContext = new ExecutionContext(rootToken);
processDefinition.fireEvent(Event.EVENTTYPE_PROCESS_END, executionContext);
-
+
// add the process instance end log
rootToken.addLog(new ProcessInstanceEndLog());
// check if this process was started as a subprocess of a super process
- if (superProcessToken!=null) {
+ if (superProcessToken != null)
+ {
addCascadeProcessInstance(superProcessToken.getProcessInstance());
-
ExecutionContext superExecutionContext = new ExecutionContext(superProcessToken);
superExecutionContext.setSubProcessInstance(this);
superProcessToken.signal(superExecutionContext);
}
- // make sure all the timers for this process instance are canceled after the process end updates are posted to the database
- // NOTE Only timers should be deleted, messages should be kept.
- MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE, false);
- if (messageService != null) {
+ // make sure all the timers for this process instance are canceled after the process end updates are posted to the
+ // database
+ // NOTE Only timers should be deleted, messages should be kept.
+ MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE, false);
+ if (messageService != null)
+ {
CleanUpProcessJob job = new CleanUpProcessJob(this);
job.setDueDate(new Date());
messageService.send(job);
@@ -335,24 +360,26 @@
}
/**
- * suspends this execution. This will make sure that tasks, timers and
- * messages related to this process instance will not show up in database
- * queries.
- * @see #resume()
+ * suspends this execution. This will make sure that tasks, timers and messages related to this process instance will
+ * not show up in database queries.
+ *
+ * @see #resume()
*/
- public void suspend() {
+ public void suspend()
+ {
isSuspended = true;
rootToken.suspend();
}
/**
- * resumes a suspended execution. All timers that have been suspended might fire
- * if the duedate has been passed. If an admin resumes a process instance, the option
- * should be offered to update, remove and create the timers and messages related to
- * this process instance.
+ * resumes a suspended execution. All timers that have been suspended might fire if the duedate has been passed. If an
+ * admin resumes a process instance, the option should be offered to update, remove and create the timers and messages
+ * related to this process instance.
+ *
* @see #suspend()
*/
- public void resume() {
+ public void resume()
+ {
isSuspended = false;
rootToken.resume();
}
@@ -362,9 +389,12 @@
/**
* adds an action to be executed upon a process event in the future.
*/
- public RuntimeAction addRuntimeAction( RuntimeAction runtimeAction ) {
- if (runtimeAction == null) throw new IllegalArgumentException("can't add a null runtimeAction to a process instance");
- if (runtimeActions == null) runtimeActions = new ArrayList();
+ public RuntimeAction addRuntimeAction(RuntimeAction runtimeAction)
+ {
+ if (runtimeAction == null)
+ throw new IllegalArgumentException("can't add a null runtimeAction to a process instance");
+ if (runtimeActions == null)
+ runtimeActions = new ArrayList();
runtimeActions.add(runtimeAction);
runtimeAction.processInstance = this;
return runtimeAction;
@@ -373,12 +403,15 @@
/**
* removes a runtime action.
*/
- public RuntimeAction removeRuntimeAction( RuntimeAction runtimeAction ) {
+ public RuntimeAction removeRuntimeAction(RuntimeAction runtimeAction)
+ {
RuntimeAction removedRuntimeAction = null;
if (runtimeAction == null)
throw new IllegalArgumentException("can't remove a null runtimeAction from an process instance");
- if (runtimeActions != null) {
- if (runtimeActions.remove(runtimeAction)) {
+ if (runtimeActions != null)
+ {
+ if (runtimeActions.remove(runtimeAction))
+ {
removedRuntimeAction = runtimeAction;
runtimeAction.processInstance = null;
}
@@ -389,7 +422,8 @@
/**
* is the list of all runtime actions.
*/
- public List getRuntimeActions() {
+ public List getRuntimeActions()
+ {
return runtimeActions;
}
@@ -398,117 +432,161 @@
/**
* tells if this process instance is still active or not.
*/
- public boolean hasEnded() {
- return ( end != null );
+ public boolean hasEnded()
+ {
+ return (end != null);
}
-
+
/**
- * calculates if this process instance has still options to continue.
+ * calculates if this process instance has still options to continue.
*/
- public boolean isTerminatedImplicitly() {
+ public boolean isTerminatedImplicitly()
+ {
boolean isTerminatedImplicitly = true;
- if ( end == null ) {
+ if (end == null)
+ {
isTerminatedImplicitly = rootToken.isTerminatedImplicitly();
}
return isTerminatedImplicitly;
}
-
+
/**
* looks up the token in the tree, specified by the slash-separated token path.
+ *
* @param tokenPath is a slash-separated name that specifies a token in the tree.
* @return the specified token or null if the token is not found.
*/
- public Token findToken(String tokenPath) {
- return ( rootToken!=null ? rootToken.findToken(tokenPath) : null );
+ public Token findToken(String tokenPath)
+ {
+ return (rootToken != null ? rootToken.findToken(tokenPath) : null);
}
-
+
/**
* collects all instances for this process instance.
*/
- public List findAllTokens() {
+ public List findAllTokens()
+ {
List tokens = new ArrayList();
tokens.add(rootToken);
rootToken.collectChildrenRecursively(tokens);
return tokens;
}
- void addCascadeProcessInstance(ProcessInstance cascadeProcessInstance) {
- if (cascadeProcessInstances==null) {
+ void addCascadeProcessInstance(ProcessInstance cascadeProcessInstance)
+ {
+ if (cascadeProcessInstances == null)
+ {
cascadeProcessInstances = new ArrayList();
}
cascadeProcessInstances.add(cascadeProcessInstance);
}
-
- public Collection removeCascadeProcessInstances() {
+
+ public Collection removeCascadeProcessInstances()
+ {
Collection removed = cascadeProcessInstances;
cascadeProcessInstances = null;
return removed;
}
-
+
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
// since this always falls back to ==, we don't need to overwrite the hashcode
- public boolean equals(Object o) {
+ public boolean equals(Object o)
+ {
return EqualsUtil.equals(this, o);
}
-
- public String toString() {
+
+ public String toString()
+ {
return "ProcessInstance" + (key != null ? '(' + key + ')' : "@" + Integer.toHexString(hashCode()));
}
-
+
// getters and setters //////////////////////////////////////////////////////
- public long getId() {
+ public long getId()
+ {
return id;
}
- public Token getRootToken() {
+
+ public Token getRootToken()
+ {
return rootToken;
}
- public Date getStart() {
+
+ public Date getStart()
+ {
return start;
}
- public Date getEnd() {
+
+ public Date getEnd()
+ {
return end;
}
- public Map getInstances() {
+
+ public Map getInstances()
+ {
return instances;
}
- public ProcessDefinition getProcessDefinition() {
+
+ public ProcessDefinition getProcessDefinition()
+ {
return processDefinition;
}
- public Token getSuperProcessToken() {
+
+ public Token getSuperProcessToken()
+ {
return superProcessToken;
}
- public void setSuperProcessToken(Token superProcessToken) {
+
+ public void setSuperProcessToken(Token superProcessToken)
+ {
this.superProcessToken = superProcessToken;
}
- public boolean isSuspended() {
+
+ public boolean isSuspended()
+ {
return isSuspended;
}
- public int getVersion() {
+
+ public int getVersion()
+ {
return version;
}
- public void setVersion(int version) {
+
+ public void setVersion(int version)
+ {
this.version = version;
}
- public void setEnd(Date end) {
+
+ public void setEnd(Date end)
+ {
this.end = end;
}
- public void setProcessDefinition(ProcessDefinition processDefinition) {
+
+ public void setProcessDefinition(ProcessDefinition processDefinition)
+ {
this.processDefinition = processDefinition;
}
- public void setRootToken(Token rootToken) {
+
+ public void setRootToken(Token rootToken)
+ {
this.rootToken = rootToken;
}
- public void setStart(Date start) {
+
+ public void setStart(Date start)
+ {
this.start = start;
}
+
/** a unique business key */
- public String getKey() {
+ public String getKey()
+ {
return key;
}
+
/** set the unique business key */
- public void setKey(String key) {
+ public void setKey(String key)
+ {
this.key = key;
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -71,7 +71,7 @@
protected Date nodeEnter = null;
protected ProcessInstance processInstance = null;
protected Token parent = null;
- protected Map children = null;
+ protected Map<String,Token> children = null;
protected List comments = null;
protected ProcessInstance subProcessInstance = null;
protected int nextLogIndex = 0;
@@ -81,7 +81,8 @@
String lock = null;
// constructors
- // ///////////////////////////////////////////////////////////////////////////
+ // ////////////////////
+ ///////////////////////////////////////////////////////
public Token()
{
@@ -126,7 +127,7 @@
{
if (children == null)
{
- children = new HashMap();
+ children = new HashMap<String,Token>();
}
children.put(token.getName(), token);
}
@@ -846,7 +847,7 @@
return processInstance;
}
- public Map getChildren()
+ public Map<String,Token> getChildren()
{
return children;
}
Modified: jbpm3/trunk/modules/integration/spec/.classpath
===================================================================
--- jbpm3/trunk/modules/integration/spec/.classpath 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/.classpath 2008-12-02 15:42:58 UTC (rev 3165)
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/cts/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/cts/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm3/trunk/modules/integration/spec/deploy.sh
===================================================================
--- jbpm3/trunk/modules/integration/spec/deploy.sh 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/deploy.sh 2008-12-02 15:42:58 UTC (rev 3165)
@@ -1,4 +1,4 @@
#! /bin/bash
-rm $JBOSS422/server/default/deploy/jbpm/jbpm-integration.beans/jbpm-integration-api*.jar
-cp target/jbpm-integration-api-3.3.1-SNAPSHOT.jar $JBOSS422/server/default/deploy/jbpm/jbpm-integration.beans
+rm $JBOSS422/server/default/deploy/jbpm/jbpm-integration.beans/bpm-spec-integration-jbpm3*.jar
+cp target/bpm-spec-integration-jbpm3-3.3.1-SNAPSHOT.jar $JBOSS422/server/default/deploy/jbpm/jbpm-integration.beans
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/client/ProcessEngineImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/client/ProcessEngineImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/client/ProcessEngineImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -39,11 +39,11 @@
public class ProcessEngineImpl extends ProcessEngine
{
private JbpmConfiguration jbpmConfig;
-
+
public void setServices(Set<Service> services)
{
this.services = services;
-
+
// Set this engine on every mutable service
for (Service service : services)
{
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/jpdl32/DialectHandlerImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/jpdl32/DialectHandlerImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/jpdl32/DialectHandlerImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -31,8 +31,8 @@
import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.model.ProcessDefinition;
-import org.jboss.bpm.api.service.AbstractDialectHandler;
import org.jboss.bpm.api.service.DialectHandler;
+import org.jboss.bpm.api.service.internal.AbstractDialectHandler;
import org.jbpm.integration.spec.model.ProcessDefinitionImpl;
/**
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/EndEventImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/EndEventImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/EndEventImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -21,6 +21,8 @@
*/
package org.jbpm.integration.spec.model;
+import java.util.List;
+
import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.model.EndEvent;
import org.jboss.bpm.api.model.ProcessDefinition;
@@ -57,7 +59,13 @@
//@Override
public SequenceFlow getInFlow()
{
- throw new NotImplementedException();
+ List<SequenceFlow> inFlows = getInFlows();
+ if (inFlows.size() == 0)
+ throw new IllegalStateException("No incomming flow on: " + this);
+ if (inFlows.size() > 1)
+ throw new NotImplementedException("Multiple incomming flows on: " + this);
+
+ return inFlows.get(0);
}
public String toString()
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -23,6 +23,7 @@
// $Id$
+import org.jboss.bpm.api.client.ProcessEngine;
import org.jboss.bpm.api.model.ExclusiveGateway;
import org.jboss.bpm.api.model.Expression;
import org.jboss.bpm.api.model.ProcessDefinition;
@@ -34,6 +35,7 @@
import org.jbpm.graph.node.DecisionHandler;
import org.jbpm.instantiation.Delegation;
import org.jbpm.integration.spec.runtime.ExpressionEvaluator;
+import org.jbpm.integration.spec.runtime.TokenImpl;
/**
* An integration wrapper
@@ -69,10 +71,10 @@
private static final long serialVersionUID = 1L;
//@Override
- public String decide(ExecutionContext executionContext) throws Exception
+ public String decide(ExecutionContext execContext) throws Exception
{
- ProcessImpl procImpl = (ProcessImpl)getProcess();
- Token token = procImpl.getRootToken();
+ ProcessEngine engine = getProcessDefinition().getProcessEngine();
+ Token token = new TokenImpl(engine, execContext.getToken());
SequenceFlow selectedGate = null;
for (SequenceFlow auxGate : getGates())
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExpressionImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExpressionImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ExpressionImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -64,4 +64,22 @@
{
return body;
}
+
+ public static Expression valueOf(String exprStr)
+ {
+ Expression expr = null;
+ if (exprStr != null && exprStr.startsWith("[") && exprStr.endsWith("]") && exprStr.indexOf(":") > 0)
+ {
+ int index = exprStr.indexOf(":");
+ String langPart = exprStr.substring(1, index);
+ String bodyPart = exprStr.substring(index + 1, exprStr.length() - 1);
+ expr = new ExpressionImpl(ExpressionLanguage.valueOf(langPart), bodyPart);
+ }
+ return expr;
+ }
+
+ public String toString()
+ {
+ return "[" + lang + ":" + body + "]";
+ }
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/NodeImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/NodeImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/NodeImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -29,10 +29,12 @@
import org.jboss.bpm.api.Constants;
import org.jboss.bpm.api.InvalidProcessException;
+import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.model.Node;
import org.jboss.bpm.api.model.Process;
import org.jboss.bpm.api.model.ProcessDefinition;
import org.jboss.bpm.api.model.SequenceFlow;
+import org.jboss.bpm.api.model.SequenceFlow.ConditionType;
import org.jboss.bpm.api.model.builder.ObjectNameFactory;
import org.jbpm.graph.def.Transition;
@@ -47,10 +49,10 @@
private static final long serialVersionUID = 1L;
private ProcessDefinition procDef;
- private Process proc;
private org.jbpm.graph.def.Node oldNode;
private List<SequenceFlow> outFlows = new ArrayList<SequenceFlow>();
+ private List<SequenceFlow> inFlows = new ArrayList<SequenceFlow>();
public NodeImpl(ProcessDefinition procDef, org.jbpm.graph.def.Node oldNode)
{
@@ -81,14 +83,9 @@
public Process getProcess()
{
- return proc;
+ throw new NotImplementedException();
}
- public void setProcess(Process proc)
- {
- this.proc = proc;
- }
-
public void addSequenceFlow(SequenceFlowImpl flow)
{
String targetRef = flow.getTargetRef();
@@ -103,9 +100,39 @@
targetNode.getOldNode().addArrivingTransition(trans);
}
+ if (flow.getConditionType() == ConditionType.Expression)
+ {
+ trans.setCondition(flow.getConditionExpression().toString());
+ }
+ else if (flow.getConditionType() == ConditionType.Default)
+ {
+ trans.setCondition("[" + ConditionType.Default + "]");
+ }
+
+ targetNode.inFlows.add(flow);
outFlows.add(flow);
}
+ public SequenceFlow getOutFlowByTransition(Transition trans)
+ {
+ SequenceFlow outFlow = null;
+ for (SequenceFlow auxFlow : outFlows)
+ {
+ SequenceFlowImpl flowImpl = (SequenceFlowImpl)auxFlow;
+ if (flowImpl.getOldTransition() == trans)
+ {
+ outFlow = auxFlow;
+ break;
+ }
+ }
+ return outFlow;
+ }
+
+ public List<SequenceFlow> getInFlows()
+ {
+ return Collections.unmodifiableList(inFlows);
+ }
+
public List<SequenceFlow> getOutFlows()
{
return Collections.unmodifiableList(outFlows);
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessDefinitionImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessDefinitionImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -23,27 +23,30 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import javax.management.ObjectName;
import org.jboss.bpm.api.Constants;
import org.jboss.bpm.api.InvalidProcessException;
-import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.model.Expression;
import org.jboss.bpm.api.model.Node;
import org.jboss.bpm.api.model.Process;
import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.model.SequenceFlow.ConditionType;
import org.jboss.bpm.api.model.builder.ObjectNameFactory;
import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.node.Decision;
import org.jbpm.graph.node.EndState;
import org.jbpm.graph.node.Fork;
import org.jbpm.graph.node.Join;
import org.jbpm.graph.node.StartState;
import org.jbpm.graph.node.State;
import org.jbpm.graph.node.TaskNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An integration wrapper
@@ -55,28 +58,25 @@
{
private static final long serialVersionUID = 1L;
+ // provide logging
+ private static final Logger log = LoggerFactory.getLogger(ProcessDefinitionImpl.class);
+
+ private ProcessEngine engine;
private org.jbpm.graph.def.ProcessDefinition oldProcDef;
- private ProcessEngine engine;
- private Map<String, Node> nodes = new LinkedHashMap<String, Node>();
+ private List<Node> nodes;
public ProcessDefinitionImpl(ProcessEngine engine, String name)
{
this(engine, new org.jbpm.graph.def.ProcessDefinition(name));
}
-
+
public ProcessDefinitionImpl(ProcessEngine engine, org.jbpm.graph.def.ProcessDefinition oldProcDef)
{
this.oldProcDef = oldProcDef;
this.engine = engine;
-
+
if (oldProcDef.getName() == null)
throw new InvalidProcessException("ProcessDefinition name cannot be null");
-
- if (oldProcDef.getNodes() != null)
- {
- initializeNodes(oldProcDef);
- initializeSequenceFlows(oldProcDef);
- }
}
public org.jbpm.graph.def.ProcessDefinition getOldProcessDefinition()
@@ -91,13 +91,18 @@
public ObjectName getKey()
{
+ return getKey(oldProcDef);
+ }
+
+ public static ObjectName getKey(org.jbpm.graph.def.ProcessDefinition oldProcDef)
+ {
long id = oldProcDef.getId();
- String version = getVersion();
-
- String keyStr = Constants.ID_DOMAIN + ":procdef=" + getName() + ",id=" + id;
- if (version != null)
+ int version = oldProcDef.getVersion();
+
+ String keyStr = Constants.ID_DOMAIN + ":procdef=" + oldProcDef.getName() + ",id=" + id;
+ if (version > 0)
keyStr += ",version=" + version;
-
+
return ObjectNameFactory.create(keyStr);
}
@@ -114,31 +119,81 @@
public Process newInstance()
{
- ProcessImpl procImpl = new ProcessImpl(this);
- for (Node node : getNodes())
- {
- NodeImpl nodeImpl = (NodeImpl)node;
- nodeImpl.setProcess(procImpl);
- }
+ ProcessImpl procImpl = new ProcessImpl(engine, new ProcessInstance(oldProcDef));
return procImpl;
}
-
+
public void addNode(NodeImpl nodeImpl)
{
org.jbpm.graph.def.Node oldNode = nodeImpl.getOldNode();
oldProcDef.addNode(oldNode);
- nodes.put(oldNode.getName(), nodeImpl);
}
public Node getNode(String name)
{
- return nodes.get(name);
+ if (name == null)
+ throw new IllegalArgumentException("Cannot find node with name: null");
+
+ Node retNode = null;
+ for (Node auxNode : getNodes())
+ {
+ if (name.equals(auxNode.getName()))
+ {
+ retNode = auxNode;
+ break;
+ }
+ }
+ return retNode;
}
public List<Node> getNodes()
{
- List<Node> nodeList = new ArrayList<Node>(nodes.values());
- return Collections.unmodifiableList(nodeList);
+ if (nodes == null)
+ {
+ nodes = new ArrayList<Node>();
+ for(org.jbpm.graph.def.Node oldNode : oldProcDef.getNodes())
+ {
+ NodeImpl nodeImpl;
+ if (oldNode instanceof StartState)
+ {
+ nodeImpl = new StartEventImpl(this, (StartState)oldNode);
+ }
+ else if (oldNode instanceof State)
+ {
+ nodeImpl = new WaitStateImpl(this, (State)oldNode);
+ }
+ else if (oldNode instanceof Fork)
+ {
+ nodeImpl = new ParallelGatewayImpl(this, (Fork)oldNode);
+ }
+ else if (oldNode instanceof Join)
+ {
+ nodeImpl = new ParallelGatewayImpl(this, (Join)oldNode);
+ }
+ else if (oldNode instanceof Decision)
+ {
+ nodeImpl = new ExclusiveGatewayImpl(this, (Decision)oldNode);
+ }
+ else if (oldNode instanceof TaskNode)
+ {
+ nodeImpl = new UserTaskImpl(this, (TaskNode)oldNode);
+ }
+ else if (oldNode instanceof EndState)
+ {
+ nodeImpl = new EndEventImpl(this, (EndState)oldNode);
+ }
+ // Fallback to a general Task node
+ else
+ {
+ nodeImpl = new TaskImpl(this, oldNode);
+ }
+
+ nodes.add(nodeImpl);
+ }
+
+ initializeSequenceFlows(nodes);
+ }
+ return Collections.unmodifiableList(nodes);
}
@SuppressWarnings("unchecked")
@@ -164,53 +219,35 @@
return retNodes;
}
- private void initializeNodes(org.jbpm.graph.def.ProcessDefinition oldProcDef)
+ private void initializeSequenceFlows(List<Node> nodes)
{
- for(org.jbpm.graph.def.Node oldNode : oldProcDef.getNodes())
+ for (Node node : nodes)
{
- NodeImpl nodeImpl;
- if (oldNode instanceof StartState)
- {
- nodeImpl = new StartEventImpl(this, (StartState)oldNode);
- }
- else if (oldNode instanceof State)
- {
- nodeImpl = new WaitStateImpl(this, (State)oldNode);
- }
- else if (oldNode instanceof Fork)
- {
- nodeImpl = new ParallelGatewayImpl(this, (Fork)oldNode);
- }
- else if (oldNode instanceof Join)
- {
- nodeImpl = new ParallelGatewayImpl(this, (Join)oldNode);
- }
- else if (oldNode instanceof TaskNode)
- {
- nodeImpl = new UserTaskImpl(this, (TaskNode)oldNode);
- }
- else if (oldNode instanceof EndState)
- {
- nodeImpl = new EndEventImpl(this, (EndState)oldNode);
- }
- else
- {
- throw new NotImplementedException("Unsupported node type: " + oldNode);
- }
- nodes.put(oldNode.getName(), nodeImpl);
- }
- }
-
- private void initializeSequenceFlows(org.jbpm.graph.def.ProcessDefinition oldProcDef)
- {
- for(org.jbpm.graph.def.Node oldNode : oldProcDef.getNodes())
- {
- NodeImpl nodeImpl = (NodeImpl)nodes.get(oldNode.getName());
+ NodeImpl nodeImpl = (NodeImpl)node;
+ org.jbpm.graph.def.Node oldNode = nodeImpl.getOldNode();
if (oldNode.getLeavingTransitions() != null)
{
for (Transition trans : oldNode.getLeavingTransitions())
{
SequenceFlowImpl seqFlow = new SequenceFlowImpl(trans);
+
+ String condition = trans.getCondition();
+ if (condition != null)
+ {
+ Expression expr = ExpressionImpl.valueOf(condition);
+ if (condition.equals("[" + ConditionType.Default + "]"))
+ {
+ seqFlow = new SequenceFlowImpl(trans, true);
+ }
+ else if (expr != null)
+ {
+ seqFlow = new SequenceFlowImpl(trans, expr.getExpressionLanguage(), expr.getExpressionBody());
+ }
+ else
+ {
+ log.warn("Cannot translate flow condition: " + condition);
+ }
+ }
nodeImpl.addSequenceFlow(seqFlow);
}
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -41,6 +41,7 @@
import org.jboss.bpm.api.service.ProcessService;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.integration.spec.runtime.TokenImpl;
+import org.jbpm.integration.spec.service.ContextWrapper;
/**
* An integration wrapper
@@ -52,33 +53,42 @@
{
private static final long serialVersionUID = 1L;
- private ProcessDefinitionImpl procDef;
+ private ProcessEngine engine;
private ProcessInstance oldProc;
+ private ProcessDefinition procDefCache;
private ProcessStatus status = ProcessStatus.None;
- public ProcessImpl(ProcessDefinitionImpl procDef)
+ public ProcessImpl(ProcessEngine engine, ProcessInstance oldProc)
{
- this.procDef = procDef;
- this.oldProc = new ProcessInstance(procDef.getOldProcessDefinition());
+ this.engine = engine;
+ this.oldProc = oldProc;
}
// @Override
public ObjectName getKey()
{
- long id = oldProc.getId();
- return ObjectNameFactory.create(Constants.ID_DOMAIN + ":proc=" + getName() + ",id=" + id);
+ return getKey(oldProc);
}
+ public static ObjectName getKey(ProcessInstance oldProc)
+ {
+ return ObjectNameFactory.create(Constants.ID_DOMAIN + ":proc=" + oldProc.getProcessDefinition().getName() + ",id=" + oldProc.getId());
+ }
+
// @Override
public ProcessDefinition getProcessDefinition()
{
- return procDef;
+ if (procDefCache == null)
+ {
+ procDefCache = new ProcessDefinitionImpl(engine, oldProc.getProcessDefinition());
+ }
+ return procDefCache;
}
// @Override
public ProcessEngine getProcessEngine()
{
- return procDef.getProcessEngine();
+ return getProcessDefinition().getProcessEngine();
}
public ProcessInstance getOldProcessInstance()
@@ -111,7 +121,7 @@
// @Override
public String getName()
{
- return procDef.getName();
+ return getProcessDefinition().getName();
}
public Date getEndDate()
@@ -127,25 +137,25 @@
// @Override
public <T extends Node> T getNode(Class<T> clazz, String name)
{
- return procDef.getNode(clazz, name);
+ return getProcessDefinition().getNode(clazz, name);
}
// @Override
public Node getNode(String name)
{
- return procDef.getNode(name);
+ return getProcessDefinition().getNode(name);
}
// @Override
public List<Node> getNodes()
{
- return procDef.getNodes();
+ return getProcessDefinition().getNodes();
}
// @Override
public <T extends Node> List<T> getNodes(Class<T> clazz)
{
- return procDef.getNodes(clazz);
+ return getProcessDefinition().getNodes(clazz);
}
// @Override
@@ -157,34 +167,42 @@
// @Override
public Token startProcess(Attachments contextData)
{
- // Register the Process
- ProcessService procService = getProcessEngine().getService(ProcessService.class);
- procService.registerProcess(this);
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
+ {
+ // Register the Process
+ ProcessService procService = getProcessEngine().getService(ProcessService.class);
+ procService.registerProcess(this);
- // Create the root token
- Token token = new TokenImpl(this, oldProc.getRootToken());
+ // Create the root token
+ Token token = new TokenImpl(engine, oldProc.getRootToken());
- // Initialize the context data
- if (contextData != null)
- {
- Attachments tokenAtt = token.getAttachments();
- for (Key key : contextData.getAttachmentKeys())
+ // Initialize the context data
+ if (contextData != null)
{
- Object val = contextData.getAttachment(key.getClassPart(), key.getNamePart());
- tokenAtt.addAttachment(key.getClassPart(), key.getNamePart(), val);
+ Attachments tokenAtt = token.getAttachments();
+ for (Key key : contextData.getAttachmentKeys())
+ {
+ Object val = contextData.getAttachment(key.getClassPart(), key.getNamePart());
+ tokenAtt.addAttachment(key.getClassPart(), key.getNamePart(), val);
+ }
}
- }
- // Signal the root token
- setProcessStatus(ProcessStatus.Active);
- token.signal();
+ // Signal the root token
+ setProcessStatus(ProcessStatus.Active);
+ token.signal();
- return token;
+ return token;
+ }
+ finally
+ {
+ ctxWrapper.close();
+ }
}
public Token getRootToken()
{
- return new TokenImpl(this, oldProc.getRootToken());
+ return new TokenImpl(engine, oldProc.getRootToken());
}
public Set<Token> getTokens()
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/SequenceFlowImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/SequenceFlowImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/SequenceFlowImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -57,6 +57,12 @@
}
}
+ public SequenceFlowImpl(Transition oldTrans, boolean isDefault)
+ {
+ this.oldTrans = oldTrans;
+ this.condType = ConditionType.Default;
+ }
+
public Transition getOldTransition()
{
return oldTrans;
@@ -93,4 +99,9 @@
Node to = oldTrans.getTo();
return to != null ? to.getName() : null;
}
+
+ public String toString()
+ {
+ return "[" + getSourceRef() + "->" + getTargetRef() + ",cond=" + condType + "]";
+ }
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/StartEventImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/StartEventImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/StartEventImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -28,11 +28,10 @@
import org.jboss.bpm.api.model.ProcessDefinition;
import org.jboss.bpm.api.model.SequenceFlow;
import org.jboss.bpm.api.model.StartEvent;
-import org.jbpm.graph.def.Transition;
import org.jbpm.graph.node.StartState;
/**
- * An integration wrapper
+ * An integration wrapper
*
* @author thomas.diesler at jboss.com
* @since 15-Nov-2008
@@ -40,41 +39,40 @@
public class StartEventImpl extends EventImpl implements StartEvent
{
private static final long serialVersionUID = 1L;
-
+
private StartState oldStart;
public StartEventImpl(ProcessDefinition procDef, StartState oldStart)
{
super(procDef, oldStart);
this.oldStart = oldStart;
-
+
if (oldStart.getName() == null)
throw new InvalidProcessException("StartEvent name cannot be null");
}
- //@Override
+ // @Override
public EventDetailType getTriggerType()
{
return EventDetailType.None;
}
- //@Override
+ // @Override
public EventType getEventType()
{
return EventType.Start;
}
- //@Override
+ // @Override
public SequenceFlow getOutFlow()
{
- List<Transition> leavingTransitions = oldStart.getLeavingTransitions();
- if (leavingTransitions == null)
- throw new IllegalStateException ("No leaving transitions on: " + oldStart);
- if (leavingTransitions.size() > 1)
- throw new NotImplementedException ("Multiple leaving transitions on: " + oldStart);
-
- Transition to = leavingTransitions.get(0);
- return new SequenceFlowImpl(to);
+ List<SequenceFlow> outFlows = getOutFlows();
+ if (outFlows.size() == 0)
+ throw new IllegalStateException("No outgoing flow on: " + this);
+ if (outFlows.size() > 1)
+ throw new NotImplementedException("Multiple outgoing flows on: " + this);
+
+ return outFlows.get(0);
}
public String toString()
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/TaskImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/TaskImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/TaskImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -22,7 +22,6 @@
package org.jbpm.integration.spec.model;
import java.util.List;
-import java.util.Set;
import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.model.ProcessDefinition;
@@ -55,33 +54,29 @@
//@Override
public SequenceFlow getInFlow()
{
- Node oldNode = getOldNode();
- Set<Transition> arrivingTransitions = oldNode.getArrivingTransitions();
- if (arrivingTransitions == null)
- throw new IllegalStateException("No leaving transitions on: " + oldNode);
- if (arrivingTransitions.size() > 1)
- throw new NotImplementedException("Multiple leaving transitions on: " + oldNode);
+ List<SequenceFlow> inFlows = getInFlows();
+ if (inFlows.size() == 0)
+ throw new IllegalStateException("No incomming flow on: " + this);
+ if (inFlows.size() > 1)
+ throw new NotImplementedException("Multiple incomming flows on: " + this);
- Transition from = arrivingTransitions.iterator().next();
- return new SequenceFlowImpl(from);
+ return inFlows.get(0);
}
//@Override
public SequenceFlow getOutFlow()
{
- Node oldNode = getOldNode();
- List<Transition> leavingTransitions = oldNode.getLeavingTransitions();
- if (leavingTransitions == null)
- throw new IllegalStateException("No leaving transitions on: " + oldNode);
- if (leavingTransitions.size() > 1)
- throw new NotImplementedException("Multiple leaving transitions on: " + oldNode);
+ List<SequenceFlow> outFlows = getOutFlows();
+ if (outFlows.size() == 0)
+ throw new IllegalStateException("No outgoing flow on: " + this);
+ if (outFlows.size() > 1)
+ throw new NotImplementedException("Multiple outgoing flows on: " + this);
- Transition to = leavingTransitions.get(0);
- return new SequenceFlowImpl(to);
+ return outFlows.get(0);
}
public String toString()
{
- return "Task[" + getTaskType() + "," + getName() + "]";
+ return getTaskType() + "Task[" + getName() + "]";
}
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -21,7 +21,6 @@
*/
package org.jbpm.integration.spec.runtime;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -29,7 +28,6 @@
import javax.management.ObjectName;
import org.jboss.bpm.api.Constants;
-import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.client.ProcessEngine;
import org.jboss.bpm.api.model.Node;
import org.jboss.bpm.api.model.Process;
@@ -39,7 +37,10 @@
import org.jboss.bpm.api.runtime.Attachments;
import org.jboss.bpm.api.runtime.Token;
import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.integration.spec.model.NodeImpl;
import org.jbpm.integration.spec.model.ProcessImpl;
+import org.jbpm.integration.spec.service.ContextWrapper;
/**
* An integration wrapper
@@ -51,16 +52,17 @@
{
private static final long serialVersionUID = 1L;
+ private ProcessEngine engine;
private org.jbpm.graph.exe.Token oldToken;
- private ProcessImpl procImpl;
private Attachments att;
+ private SequenceFlow lastFlow;
- public TokenImpl(ProcessImpl proc, org.jbpm.graph.exe.Token oldToken)
+ public TokenImpl(ProcessEngine engine, org.jbpm.graph.exe.Token oldToken)
{
+ this.engine = engine;
this.oldToken = oldToken;
- this.procImpl = proc;
-
- ContextInstance context = proc.getOldProcessInstance().getContextInstance();
+
+ ContextInstance context = oldToken.getProcessInstance().getContextInstance();
this.att = new TokenAttachmentDelegate(this, context);
}
@@ -76,12 +78,12 @@
public Process getProcess()
{
- return procImpl;
+ return new ProcessImpl(engine, oldToken.getProcessInstance());
}
public ProcessEngine getProcessEngine()
{
- return procImpl.getProcessEngine();
+ return engine;
}
// @Override
@@ -105,14 +107,16 @@
public Set<Token> getChildTokens()
{
Set<Token> childTokens = new HashSet<Token>();
- Map oldChildMap = oldToken.getChildren();
+ Map<String, org.jbpm.graph.exe.Token> oldChildMap = oldToken.getChildren();
if (oldChildMap != null)
{
- Collection<org.jbpm.graph.exe.Token> oldChildTokens = oldChildMap.values();
- for (org.jbpm.graph.exe.Token oldChildToken : oldChildTokens)
+ for (org.jbpm.graph.exe.Token oldChildToken : oldChildMap.values())
{
- TokenImpl childToken = new TokenImpl(procImpl, oldChildToken);
- childTokens.add(childToken);
+ if (oldChildToken.hasEnded() == false)
+ {
+ TokenImpl childToken = new TokenImpl(engine, oldChildToken);
+ childTokens.add(childToken);
+ }
}
}
return childTokens;
@@ -122,20 +126,20 @@
public Node getCurrentNode()
{
String nodeName = oldToken.getNode().getName();
- return procImpl.getNode(nodeName);
+ return getProcess().getNode(nodeName);
}
// @Override
public SequenceFlow getLastFlow()
{
- throw new NotImplementedException();
+ return lastFlow;
}
// @Override
public Token getParentToken()
{
org.jbpm.graph.exe.Token parent = oldToken.getParent();
- return parent != null ? new TokenImpl(procImpl, parent) : null;
+ return parent != null ? new TokenImpl(engine, parent) : null;
}
// @Override
@@ -145,39 +149,76 @@
while (root.getParent() != null)
root = root.getParent();
- return new TokenImpl(procImpl, root);
+ return new TokenImpl(engine, root);
}
// @Override
- public void signal(String name)
+ public void signal()
{
- try
- {
- oldToken.signal(name);
- }
- catch (RuntimeException rte)
- {
- procImpl.setProcessStatus(ProcessStatus.Aborted);
- throw rte;
- }
+ signalInternal(null);
}
// @Override
- public void signal()
+ public void signal(String name)
{
+ signalInternal(name);
+ }
+
+ private void signalInternal(String name)
+ {
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
try
{
- oldToken.signal();
+ // Make sure we have a current node
+ NodeImpl currNode = (NodeImpl)getCurrentNode();
+ if (currNode == null)
+ throw new IllegalStateException("Cannot signal token with no current node: " + this);
+
+ // Make sure we have no active children
+ boolean hasActiveChild = false;
+ for (Token child : getChildTokens())
+ {
+ if (child.getTokenStatus() != TokenStatus.Destroyed)
+ {
+ hasActiveChild = true;
+ break;
+ }
+ }
+ if (hasActiveChild)
+ throw new IllegalStateException("Cannot signal token with active child tokens: " + this);
+
+ // Signal the underlying jBPM node
+ if (name != null)
+ {
+ Transition trans = currNode.getOldNode().getLeavingTransition(name);
+ lastFlow = currNode.getOutFlowByTransition(trans);
+ oldToken.signal(name);
+ }
+ else
+ {
+ Transition trans = currNode.getOldNode().getDefaultLeavingTransition();
+ lastFlow = currNode.getOutFlowByTransition(trans);
+ oldToken.signal();
+ }
}
catch (RuntimeException rte)
{
+ ProcessImpl procImpl = (ProcessImpl)getProcess();
procImpl.setProcessStatus(ProcessStatus.Aborted);
throw rte;
}
+ finally
+ {
+ ctxWrapper.close();
+ }
}
public String toString()
{
- return "[sf=" + getLastFlow() + ",status=" + getTokenStatus() + ",ctx=" + getAttachments() + ",key=" + getKey() + "]";
+ Node currNode = getCurrentNode();
+ int children = getChildTokens().size();
+ boolean root = getParentToken() == null;
+ TokenStatus status = getTokenStatus();
+ return "[key=" + getKey() + ",root=" + root + ",status=" + status + ",node=" + currNode + ",flow=" + lastFlow + ",child=" + children + "]";
}
}
Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.spec.service;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.integration.spec.client.ProcessEngineImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A wrapper arround the jBPM contaxt that maintains a client count.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 30-Nov-2008
+ */
+public class ContextWrapper
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(ContextWrapper.class);
+
+ private static ThreadLocal<ContextWrapper> contextAssociation = new ThreadLocal<ContextWrapper>();
+ private JbpmContext jbpmContext;
+ private int clientCount;
+
+ /**
+ * Get a thread local association of the JbpmContext. If there is no context associated, it
+ * creates the association. The ContextWrapper must always be closed in a finally clause.
+ *
+ * Never close the underlying JbpmContext directly.
+ */
+ public static ContextWrapper getInstance(ProcessEngine engine)
+ {
+ ContextWrapper currContext = contextAssociation.get();
+ if (currContext == null)
+ {
+ ProcessEngineImpl engineImpl = (ProcessEngineImpl)engine;
+ JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
+ JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+ currContext = new ContextWrapper(jbpmContext);
+ contextAssociation.set(currContext);
+ }
+ currContext.clientCount++;
+ return currContext;
+ }
+
+ private ContextWrapper(JbpmContext jbpmContext)
+ {
+ this.jbpmContext = jbpmContext;
+ }
+
+ public JbpmContext getJbpmContext()
+ {
+ return jbpmContext;
+ }
+
+ public Long adaptKey(ObjectName key)
+ {
+ String id = key.getKeyProperty("id");
+ if (id == null)
+ throw new IllegalStateException("Cannot obtain id property from: " + key);
+
+ return new Long(id);
+ }
+
+ public void close()
+ {
+ clientCount--;
+
+ if (clientCount < 0)
+ throw new IllegalStateException("PersistenceContext already closed");
+
+ if (clientCount == 0)
+ {
+ contextAssociation.set(null);
+ jbpmContext.close();
+ }
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DeploymentServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DeploymentServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DeploymentServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -31,8 +31,9 @@
import org.jboss.bpm.api.client.ProcessEngine;
import org.jboss.bpm.api.deployment.Deployment;
import org.jboss.bpm.api.model.ProcessDefinition;
-import org.jboss.bpm.api.service.DeploymentService;
import org.jboss.bpm.api.service.ProcessDefinitionService;
+import org.jboss.bpm.api.service.internal.AbstractDeploymentService;
+import org.jboss.bpm.api.service.internal.AbstractProcessDefinitionService;
import org.jbpm.integration.spec.deployment.PARDeployment;
import org.jbpm.integration.spec.deployment.XMLDeployment;
import org.slf4j.Logger;
@@ -44,7 +45,7 @@
* @author thomas.diesler at jboss.com
* @since 28-Nov-2008
*/
-public class DeploymentServiceImpl extends DeploymentService implements MutableService
+public class DeploymentServiceImpl extends AbstractDeploymentService implements MutableService
{
// Provide logging
final Logger log = LoggerFactory.getLogger(DeploymentServiceImpl.class);
@@ -55,7 +56,6 @@
super.setProcessEngine(engine);
}
- @Override
public Deployment createDeployment(URL depURL)
{
Deployment dep;
@@ -74,7 +74,6 @@
return dep;
}
- @Override
public ProcessDefinition deploy(Deployment dep)
{
try
@@ -84,7 +83,7 @@
// Parse and register the ProcessDefinition
ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
ProcessDefinition procDef = pdService.parseProcessDefinition(pdXML);
- pdService.registerProcessDefinition(procDef);
+ procDef = pdService.registerProcessDefinition(procDef);
ObjectName key = procDef.getKey();
dep.addAttachment(ObjectName.class, "procDefKey", key);
@@ -97,7 +96,6 @@
}
}
- @Override
public boolean undeploy(Deployment dep)
{
ObjectName key = dep.getAttachment(ObjectName.class, "procDefKey");
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DialectHandlerServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DialectHandlerServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/DialectHandlerServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -28,7 +28,7 @@
import org.jboss.bpm.api.client.ProcessEngine;
import org.jboss.bpm.api.service.DialectHandler;
-import org.jboss.bpm.api.service.DialectHandlerService;
+import org.jboss.bpm.api.service.internal.AbstractDialectHandlerService;
/**
* A registry that maps namespaceURI to a {@link DialectHandler}
@@ -36,7 +36,7 @@
* @author thomas.diesler at jboss.com
* @since 18-Jun-2008
*/
-public class DialectHandlerServiceImpl extends DialectHandlerService implements MutableService
+public class DialectHandlerServiceImpl extends AbstractDialectHandlerService implements MutableService
{
//@Override
public void setProcessEngine(ProcessEngine engine)
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -33,6 +33,7 @@
import org.jboss.bpm.api.runtime.Token;
import org.jboss.bpm.api.service.ExecutionService;
import org.jboss.bpm.api.service.ProcessService;
+import org.jboss.bpm.api.service.internal.AbstractProcessService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/IdentityServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/IdentityServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/IdentityServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -29,7 +29,7 @@
import org.jboss.bpm.api.NotImplementedException;
import org.jboss.bpm.api.client.ProcessEngine;
-import org.jboss.bpm.api.service.IdentityService;
+import org.jboss.bpm.api.service.internal.AbstractIdentityService;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.identity.Group;
@@ -45,7 +45,7 @@
* @author thomas.diesler at jboss.com
* @since 28-Nov-2008
*/
-public class IdentityServiceImpl extends IdentityService implements MutableService
+public class IdentityServiceImpl extends AbstractIdentityService implements MutableService
{
// Provide logging
final Logger log = LoggerFactory.getLogger(IdentityServiceImpl.class);
@@ -56,7 +56,6 @@
super.setProcessEngine(engine);
}
- @Override
public List<String> getActors()
{
List<String> actors = new ArrayList<String>();
@@ -78,7 +77,6 @@
return actors;
}
- @Override
public List<String> getActorsByGroup(String group)
{
List<String> actors = new ArrayList<String>();
@@ -104,13 +102,11 @@
return actors;
}
- @Override
public List<String> getGroups()
{
throw new NotImplementedException();
}
- @Override
public List<String> getGroupsByActor(String actor)
{
List<String> groups = new ArrayList<String>();
Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.spec.service;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.jboss.bpm.api.client.ProcessEngine;
+
+/**
+ * Decorates management invocations with common system aspects.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ * @author Thomas.Diesler at jboss.com
+ */
+public class InvocationProxy implements InvocationHandler
+{
+ private ProcessEngine engine;
+ private Object obj;
+
+ @SuppressWarnings("unchecked")
+ public static Object newInstance(ProcessEngine engine, Object obj, Class[] interfaces)
+ {
+ return Proxy.newProxyInstance(obj.getClass().getClassLoader(), interfaces, new InvocationProxy(engine, obj));
+ }
+
+ private InvocationProxy(ProcessEngine engine, Object obj)
+ {
+ this.engine = engine;
+ this.obj = obj;
+ }
+
+ public Object invoke(Object proxy, Method m, Object[] args) throws Throwable
+ {
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(engine);
+ try
+ {
+ return m.invoke(obj, args);
+ }
+ finally
+ {
+ ctxWrapper.close();
+ }
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/NoopPersistenceServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/NoopPersistenceServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/NoopPersistenceServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -34,7 +34,7 @@
import org.jboss.bpm.api.model.Node;
import org.jboss.bpm.api.model.Process;
import org.jboss.bpm.api.model.ProcessDefinition;
-import org.jboss.bpm.api.service.PersistenceService;
+import org.jboss.bpm.incubator.service.PersistenceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -24,19 +24,17 @@
// $Id$
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.HashSet;
import java.util.Set;
import javax.management.ObjectName;
import org.jboss.bpm.api.client.ProcessEngine;
import org.jboss.bpm.api.model.ProcessDefinition;
-import org.jboss.bpm.api.service.ProcessDefinitionService;
import org.jboss.bpm.api.service.ProcessService;
-import org.jbpm.JbpmConfiguration;
+import org.jboss.bpm.api.service.internal.AbstractProcessDefinitionService;
import org.jbpm.JbpmContext;
-import org.jbpm.integration.spec.client.ProcessEngineImpl;
+import org.jbpm.db.GraphSession;
import org.jbpm.integration.spec.model.ProcessDefinitionImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,14 +45,11 @@
* @author thomas.diesler at jboss.com
* @since 18-Jun-2008
*/
-public class ProcessDefinitionServiceImpl extends ProcessDefinitionService implements MutableService
+public class ProcessDefinitionServiceImpl extends AbstractProcessDefinitionService implements MutableService
{
// Provide logging
final static Logger log = LoggerFactory.getLogger(ProcessDefinitionServiceImpl.class);
- // The set of registered ProcessDefinitions
- private Map<ObjectName, ProcessDefinition> procDefs = new HashMap<ObjectName, ProcessDefinition>();
-
@Override
public void setProcessEngine(ProcessEngine engine)
{
@@ -63,87 +58,94 @@
public ProcessDefinition getProcessDefinition(ObjectName procDefID)
{
- return procDefs.get(procDefID);
+ ProcessDefinition procDef = null;
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
+ {
+ Long id = ctxWrapper.adaptKey(procDefID);
+ GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ org.jbpm.graph.def.ProcessDefinition oldProcDef = graphSession.getProcessDefinition(id);
+ if (oldProcDef != null)
+ {
+ procDef = new ProcessDefinitionImpl(getProcessEngine(), oldProcDef);
+ }
+ }
+ finally
+ {
+ ctxWrapper.close();
+ }
+ return procDef;
}
public Set<ObjectName> getProcessDefinitions()
{
- return Collections.unmodifiableSet(procDefs.keySet());
+ Set<ObjectName> procDefs = new HashSet<ObjectName>();
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
+ {
+ GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ for (Object item : graphSession.findAllProcessDefinitions())
+ {
+ org.jbpm.graph.def.ProcessDefinition oldProcDef = (org.jbpm.graph.def.ProcessDefinition)item;
+ procDefs.add(ProcessDefinitionImpl.getKey(oldProcDef));
+ }
+ }
+ finally
+ {
+ ctxWrapper.close();
+ }
+ return Collections.unmodifiableSet(procDefs);
}
- public ObjectName registerProcessDefinition(ProcessDefinition procDef)
+ public ProcessDefinition registerProcessDefinition(ProcessDefinition procDef)
{
- if (getProcessDefinition(procDef.getKey()) != null)
- throw new IllegalStateException("Process definition already registered: " + procDef);
-
log.debug("registerProcessDefinition: " + procDef);
- JbpmContext jbpmContext = getJbpmContext();
-
- ObjectName procDefID;
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
try
{
+ if (getProcessDefinition(procDef.getKey()) != null)
+ throw new IllegalStateException("Process definition already registered: " + procDef);
+
+ JbpmContext jbpmContext = ctxWrapper.getJbpmContext();
ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
jbpmContext.deployProcessDefinition(procDefImpl.getOldProcessDefinition());
-
- procDefID = procDef.getKey();
- procDefs.put(procDefID, procDef);
}
- catch (RuntimeException rte)
- {
- throw rte;
- }
finally
{
- jbpmContext.close();
+ ctxWrapper.close();
}
- return procDefID;
+
+ return procDef;
}
public boolean unregisterProcessDefinition(ObjectName procDefID)
{
boolean removed = false;
- ProcessDefinition procDef = procDefs.get(procDefID);
- if (procDef != null)
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
{
- log.debug("unregisterProcessDefinition: " + procDef);
-
- ProcessEngine engine = getProcessEngine();
-
- // Unregister the associated process instances
- ProcessService procService = engine.getService(ProcessService.class);
- for (ObjectName procID : procService.getProcesses(procDefID, null))
- procService.unregisterProcess(procID);
-
- // Save the ProcessDefinition
- JbpmContext jbpmContext = getJbpmContext();
- try
+ ProcessDefinition procDef = getProcessDefinition(procDefID);
+ if (procDef != null)
{
+ log.debug("unregisterProcessDefinition: " + procDef);
+
+ // Unregister the associated process instances
+ ProcessService procService = getProcessEngine().getService(ProcessService.class);
+ for (ObjectName procID : procService.getProcesses(procDefID, null))
+ procService.unregisterProcess(procID);
+
ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
long oldID = procDefImpl.getOldProcessDefinition().getId();
- jbpmContext.getGraphSession().deleteProcessDefinition(oldID);
-
- procDefs.remove(procDefID);
+ ctxWrapper.getJbpmContext().getGraphSession().deleteProcessDefinition(oldID);
removed = true;
}
- catch (RuntimeException rte)
- {
- throw rte;
- }
- finally
- {
- jbpmContext.close();
- }
}
+ finally
+ {
+ ctxWrapper.close();
+ }
return removed;
}
-
- private JbpmContext getJbpmContext()
- {
- ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
- JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
- JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
- return jbpmContext;
- }
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -25,10 +25,8 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.management.ObjectName;
@@ -38,10 +36,10 @@
import org.jboss.bpm.api.model.ProcessDefinition;
import org.jboss.bpm.api.model.Process.ProcessStatus;
import org.jboss.bpm.api.service.ProcessDefinitionService;
-import org.jboss.bpm.api.service.ProcessService;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.integration.spec.client.ProcessEngineImpl;
+import org.jboss.bpm.api.service.internal.AbstractProcessDefinitionService;
+import org.jboss.bpm.api.service.internal.AbstractProcessService;
+import org.jbpm.db.GraphSession;
+import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.integration.spec.model.ProcessImpl;
import org.jbpm.integration.spec.runtime.NodeInterceptor;
import org.slf4j.Logger;
@@ -53,15 +51,14 @@
* @author thomas.diesler at jboss.com
* @since 18-Jun-2008
*/
-public class ProcessServiceImpl extends ProcessService implements MutableService
+public class ProcessServiceImpl extends AbstractProcessService implements MutableService
{
// Provide logging
final static Logger log = LoggerFactory.getLogger(ProcessServiceImpl.class);
-
- private Map<ObjectName, Process> registeredProcs = new HashMap<ObjectName, Process>();
+
private List<NodeInterceptor> nodeInterceptors = new ArrayList<NodeInterceptor>();
-
- //@Override
+
+ // @Override
public void setProcessEngine(ProcessEngine engine)
{
super.setProcessEngine(engine);
@@ -84,20 +81,55 @@
/**
* Get a Process for a given id
*/
- //@Override
+ // @Override
public Process getProcess(ObjectName procID)
{
- Process proc = registeredProcs.get(procID);
+ Process proc = null;
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
+ {
+ Long id = ctxWrapper.adaptKey(procID);
+ GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ ProcessInstance oldProc = graphSession.getProcessInstance(id);
+ if (oldProc != null)
+ {
+ proc = new ProcessImpl(getProcessEngine(), oldProc);
+ }
+ }
+ finally
+ {
+ ctxWrapper.close();
+ }
return proc;
}
/**
* Get the set of registered Processes
*/
- //@Override
+ // @Override
public Set<ObjectName> getProcesses()
{
- return Collections.unmodifiableSet(registeredProcs.keySet());
+ Set<ObjectName> procs = new HashSet<ObjectName>();
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
+ {
+ ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
+ for (ObjectName procDefID : pdService.getProcessDefinitions())
+ {
+ Long id = ctxWrapper.adaptKey(procDefID);
+ GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ for (Object item : graphSession.findProcessInstances(id))
+ {
+ ProcessInstance oldProc = (ProcessInstance)item;
+ procs.add(ProcessImpl.getKey(oldProc));
+ }
+ }
+ }
+ finally
+ {
+ ctxWrapper.close();
+ }
+ return Collections.unmodifiableSet(procs);
}
/**
@@ -107,20 +139,28 @@
* @param status The optional process status
* @return An empty set if the process cannot be found
*/
- //@Override
+ // @Override
public Set<ObjectName> getProcesses(ObjectName procDefID, ProcessStatus status)
{
- Set<ObjectName> procSet = new HashSet<ObjectName>();
- for (Process auxProc : registeredProcs.values())
+ Set<ObjectName> procs = new HashSet<ObjectName>();
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
{
- ObjectName auxProcDefID = auxProc.getProcessDefinition().getKey();
- if (auxProcDefID.equals(procDefID))
+ Long id = ctxWrapper.adaptKey(procDefID);
+ GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ for (Object item : graphSession.findProcessInstances(id))
{
+ ProcessInstance oldProc = (ProcessInstance)item;
+ ProcessImpl auxProc = new ProcessImpl(getProcessEngine(), oldProc);
if (status == null || auxProc.getProcessStatus() == status)
- procSet.add(auxProc.getKey());
+ procs.add(auxProc.getKey());
}
}
- return procSet;
+ finally
+ {
+ ctxWrapper.close();
+ }
+ return Collections.unmodifiableSet(procs);
}
/**
@@ -130,43 +170,36 @@
{
log.debug("registerProcess: " + proc);
- ObjectName procID = proc.getKey();
- if (getProcess(procID) != null)
- throw new IllegalStateException("Process already registered: " + proc);
+ ObjectName procID;
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
+ {
+ if (getProcess(proc.getKey()) != null)
+ throw new IllegalStateException("Process already registered: " + proc);
- ProcessImpl procImpl = (ProcessImpl)proc;
- ProcessStatus procStatus = proc.getProcessStatus();
- ProcessDefinition procDef = proc.getProcessDefinition();
- ProcessEngine engine = getProcessEngine();
+ ProcessImpl procImpl = (ProcessImpl)proc;
+ ProcessStatus procStatus = proc.getProcessStatus();
+ ProcessDefinition procDef = proc.getProcessDefinition();
- if (procStatus != ProcessStatus.None)
- throw new IllegalStateException("Cannot register process in state: " + procStatus);
+ if (procStatus != ProcessStatus.None)
+ throw new IllegalStateException("Cannot register process in state: " + procStatus);
- // Register the process definition if needed
- ProcessDefinitionService procDefService = engine.getService(ProcessDefinitionService.class);
- if (procDefService.getProcessDefinition(procDef.getKey()) == null)
- procDefService.registerProcessDefinition(procDef);
+ // Register the process definition if needed
+ ProcessDefinitionService procDefService = getProcessEngine().getService(ProcessDefinitionService.class);
+ if (procDefService.getProcessDefinition(procDef.getKey()) == null)
+ procDefService.registerProcessDefinition(procDef);
- // Save the Process instance
- JbpmContext jbpmContext = getJbpmContext();
- try
- {
- jbpmContext.save(procImpl.getOldProcessInstance());
+ // Save the Process instance
+ ctxWrapper.getJbpmContext().save(procImpl.getOldProcessInstance());
+
+ procImpl.setProcessStatus(ProcessStatus.Ready);
procID = proc.getKey();
}
- catch (RuntimeException rte)
- {
- throw rte;
- }
finally
{
- jbpmContext.close();
+ ctxWrapper.close();
}
-
- // Register the process
- registeredProcs.put(procID, proc);
- procImpl.setProcessStatus(ProcessStatus.Ready);
-
+
return procID;
}
@@ -176,31 +209,25 @@
public boolean unregisterProcess(ObjectName procID)
{
boolean removed = false;
- Process proc = registeredProcs.get(procID);
- if (proc != null)
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ try
{
- log.debug("unregisterProcess: " + proc);
-
- // Delete the Process instance
- JbpmContext jbpmContext = getJbpmContext();
- try
+ Process proc = getProcess(procID);
+ if (proc != null)
{
+ log.debug("unregisterProcess: " + proc);
+
ProcessImpl procImpl = (ProcessImpl)proc;
- jbpmContext.getGraphSession().deleteProcessInstance(procImpl.getOldProcessInstance());
+ ctxWrapper.getJbpmContext().getGraphSession().deleteProcessInstance(procImpl.getOldProcessInstance());
+ removed = true;
}
- catch (RuntimeException rte)
- {
- throw rte;
- }
- finally
- {
- jbpmContext.close();
- }
-
- registeredProcs.remove(procID);
- removed = true;
}
+ finally
+ {
+ ctxWrapper.close();
+ }
return removed;
+
}
private NodeInterceptor loadNodeInterceptor(String className)
@@ -220,12 +247,4 @@
}
return itor;
}
-
- private JbpmContext getJbpmContext()
- {
- ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
- JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
- JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
- return jbpmContext;
- }
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -29,11 +29,9 @@
import javax.management.ObjectName;
import org.jboss.bpm.api.client.ProcessEngine;
-import org.jboss.bpm.api.service.TaskService;
+import org.jboss.bpm.api.service.internal.AbstractTaskService;
import org.jboss.bpm.api.task.Task;
-import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
-import org.jbpm.integration.spec.client.ProcessEngineImpl;
import org.jbpm.integration.spec.task.TaskImpl;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.slf4j.Logger;
@@ -45,7 +43,7 @@
* @author thomas.diesler at jboss.com
* @since 28-Nov-2008
*/
-public class TaskServiceImpl extends TaskService implements MutableService
+public class TaskServiceImpl extends AbstractTaskService implements MutableService
{
// Provide logging
final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class);
@@ -56,14 +54,14 @@
super.setProcessEngine(engine);
}
- @Override
public Task getTask(ObjectName taskID)
{
Task task = null;
- JbpmContext jbpmContext = getJbpmContext();
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
try
{
+ JbpmContext jbpmContext = ctxWrapper.getJbpmContext();
TaskInstance oldTask = jbpmContext.getTaskInstance(adaptKey(taskID));
task = new TaskImpl(getProcessEngine(), oldTask);
}
@@ -73,20 +71,20 @@
}
finally
{
- jbpmContext.close();
+ ctxWrapper.close();
}
return task;
}
- @Override
public List<Task> getTasksByActor(String actor)
{
List<Task> tasks = new ArrayList<Task>();
- JbpmContext jbpmContext = getJbpmContext();
+ ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
try
{
+ JbpmContext jbpmContext = ctxWrapper.getJbpmContext();
for (TaskInstance oldTask : (List<TaskInstance>)jbpmContext.getTaskList(actor))
{
tasks.add(new TaskImpl(getProcessEngine(), oldTask));
@@ -98,13 +96,12 @@
}
finally
{
- jbpmContext.close();
+ ctxWrapper.close();
}
return tasks;
}
- @Override
public void closeTask(ObjectName taskID, String signalName)
{
TaskImpl taskImpl = (TaskImpl)getTask(taskID);
@@ -116,7 +113,6 @@
taskInstance.end();
}
- @Override
public void reassignTask(ObjectName taskID, String actor)
{
TaskImpl taskImpl = (TaskImpl)getTask(taskID);
@@ -139,12 +135,4 @@
return new Long(id);
}
-
- private JbpmContext getJbpmContext()
- {
- ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
- JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
- JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
- return jbpmContext;
- }
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml 2008-12-02 15:42:58 UTC (rev 3165)
@@ -15,10 +15,12 @@
<set elementClass="org.jboss.bpm.api.service.Service">
<inject bean="BPMDeploymentService"/>
<inject bean="BPMDialectHandlerService"/>
+ <inject bean="BPMExecutionService"/>
<inject bean="BPMIdentityService"/>
<inject bean="BPMProcessBuilderService"/>
<inject bean="BPMProcessDefinitionService"/>
<inject bean="BPMProcessService"/>
+ <inject bean="BPMTaskService"/>
</set>
</property>
</bean>
@@ -49,8 +51,10 @@
<!-- Other Services -->
<bean name="BPMDeploymentService" class="org.jbpm.integration.spec.service.DeploymentServiceImpl" />
+ <bean name="BPMExecutionService" class="org.jbpm.integration.spec.service.ExecutionServiceImpl" />
<bean name="BPMIdentityService" class="org.jbpm.integration.spec.service.IdentityServiceImpl" />
<bean name="BPMProcessBuilderService" class="org.jbpm.integration.spec.service.ProcessBuilderServiceImpl" />
<bean name="BPMProcessDefinitionService" class="org.jbpm.integration.spec.service.ProcessDefinitionServiceImpl" />
+ <bean name="BPMTaskService" class="org.jbpm.integration.spec.service.TaskServiceImpl" />
</deployment>
Modified: jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentPARTest.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentPARTest.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentPARTest.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -24,10 +24,18 @@
// $Id$
import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.jboss.bpm.api.deployment.Deployment;
+import org.jboss.bpm.api.model.Process;
import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.runtime.Token;
import org.jboss.bpm.api.service.DeploymentService;
+import org.jboss.bpm.api.service.TaskService;
+import org.jboss.bpm.api.task.Task;
import org.jboss.bpm.api.test.APITestCase;
/**
@@ -48,6 +56,30 @@
ProcessDefinition procDef = depService.deploy(dep);
assertNotNull("ProcDef not null", procDef);
+ Process proc = procDef.newInstance();
+ Token token = proc.startProcess();
+
+ assertEquals("fork1", token.getCurrentNode().getName());
+ assertEquals(2, token.getChildTokens().size());
+
+ // Get the child tokens
+ Map<String,Token> childToks = new HashMap<String, Token>();
+ Iterator<Token> itTok = token.getChildTokens().iterator();
+ while (itTok.hasNext())
+ {
+ Token child = itTok.next();
+ childToks.put(child.getCurrentNode().getName(), child);
+ }
+ Token childOne = childToks.get("Prepare shipping");
+ Token childTwo = childToks.get("Review Order");
+
+ assertNotNull("Prepare shipping", childOne);
+ assertNotNull("Review Order", childTwo);
+
+ TaskService taskService = getProcessEngine().getService(TaskService.class);
+ List<Task> tasks = taskService.getTasksByActor("sales");
+ System.out.println(tasks);
+
// Undeploy the process
assertTrue("Undeploy successful", depService.undeploy(dep));
}
Modified: jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentXMLTest.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentXMLTest.java 2008-12-02 15:41:16 UTC (rev 3164)
+++ jbpm3/trunk/modules/integration/spec/src/test/java/org/jbpm/test/integration/spec/deployment/DeploymentXMLTest.java 2008-12-02 15:42:58 UTC (rev 3165)
@@ -31,6 +31,7 @@
import org.jboss.bpm.api.model.Process.ProcessStatus;
import org.jboss.bpm.api.runtime.Token;
import org.jboss.bpm.api.service.DeploymentService;
+import org.jboss.bpm.api.service.internal.AbstractDeploymentService;
import org.jboss.bpm.api.test.APITestCase;
/**
@@ -45,7 +46,7 @@
{
URL pdURL = getResourceURL("deployment/simple-process.xml");
- DeploymentService depService = getProcessEngine().getService(DeploymentService.class);
+ DeploymentService depService = getProcessEngine().getService(AbstractDeploymentService.class);
Deployment dep = depService.createDeployment(pdURL);
ProcessDefinition procDef = depService.deploy(dep);
More information about the jbpm-commits
mailing list