[jbpm-commits] JBoss JBPM SVN: r5539 - in jbpm4/trunk/modules: distro/src/main/files/install and 8 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Aug 26 05:11:54 EDT 2009
Author: jbarrez
Date: 2009-08-26 05:11:53 -0400 (Wed, 26 Aug 2009)
New Revision: 5539
Added:
jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/
jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/shutdown.sql
jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.bat
jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.sh
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartHsqldbServerTask.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetDeploymentResourceNamesCmd.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinition.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/JBPMIntegration.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ManagementFactoryImpl.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEnginePluginImpl.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/FormDispatcherComposite.java
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java
jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
Log:
* Fix for JBPM-2353: remove transaction demarcation from console integration layer. Transactions will be managed now only by jBPM engine. This allows the console to run on Tomcat.
* Enhanced install script to allow jBPM and console installation into Tomcat.
* Enhanced install script to allow installation of standalone HSQLDB server.
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -39,6 +39,12 @@
static Map<String, String> implementationClassNames = null;
Configuration impl;
+
+ /**
+ * Cached processEngine instance used by the
+ * convience 'getProcessEngine()' operation.
+ */
+ private static ProcessEngine cachedProcessEngine;
/** default constructor */
public Configuration() {
@@ -143,4 +149,23 @@
public Configuration setHibernateSessionFactory(Object hibernateSessionFactory){
return impl.setHibernateSessionFactory(hibernateSessionFactory);
}
+
+ /**
+ * Convenience method to retrieve the default {@link ProcessEngine}. To
+ * construct this {@link ProcessEngine}, the classpath resource 'jbpm.cfg.xml'
+ * will be used.
+ *
+ * Subsequent calls will return the same {@link ProcessEngine} instance.
+ */
+ public static ProcessEngine getProcessEngine() {
+ if (cachedProcessEngine == null) {
+ synchronized (Configuration.class) {
+ if (cachedProcessEngine == null) {
+ cachedProcessEngine = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine();
+ }
+ }
+ }
+ return Configuration.cachedProcessEngine;
+ }
+
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinition.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinition.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinition.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -58,4 +58,8 @@
/** description of the process definition */
String getDescription();
+
+ /** Returns whether this process definition is currently suspended. */
+ boolean isSuspended();
+
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.util.List;
+import java.util.Set;
import org.jbpm.api.model.ActivityCoordinates;
@@ -60,7 +61,10 @@
/** deletes deployment, contained process definitions, related process instances
* and their history information */
void deleteDeploymentCascade(String deploymentId);
-
+
+ /** Returns all the resources stored in the deployment with the given id. */
+ Set<String> getResourceNames(String deploymentId);
+
/** obtain an InputStream to a resource in a deployment */
InputStream getResourceAsStream(String deploymentId, String resourceName);
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-08-26 09:11:53 UTC (rev 5539)
@@ -31,6 +31,9 @@
<property name="tomcat.distro.dir" value="downloads" />
<property name="tomcat.distro.url" value="http://www.apache.org/dist/tomcat/tomcat-6/v${tomcat.version}/bin/${tomcat.filename}" />
<property name="tomcat.distro.path" value="${tomcat.distro.dir}/${tomcat.filename}" />
+
+ <property name="hsqldb.server.install.dir" value="${jbpm.home}/hsqldb-server"/>
+ <property name="hsqldb.server.source.dir" value="${jbpm.home}/install/src/hsqldb-server" />
<property name="jboss.version" value="5.1.0.GA" />
<property name="jboss.parent.dir" value="${jbpm.home}" />
@@ -318,16 +321,19 @@
<!-- ### INSTALL JBPM INTO TOMCAT ####################################### -->
<target name="install.jbpm.into.tomcat"
- depends="create.cfg"
+ depends="create.cfg"
description="Installs jBPM into tomcat">
+
+ <property name="is.tomcat" value="true" />
- <!-- create the jbpm configuration jar file -->
+ <!-- create the jbpm configuration jar file and drop in /lib -->
<jar destfile="${tomcat.home}/lib/jbpm.cfg.jar">
<fileset dir="generated/cfg">
<exclude name="logging.properties"/>
</fileset>
</jar>
+ <!-- Copy jBPM third party libs into /lib -->
<copy todir="${tomcat.home}/lib" overwrite="true">
<fileset dir="${jbpm.home}">
<include name="jbpm.jar" />
@@ -336,6 +342,7 @@
<include name="activation.jar" />
<include name="antlr.jar" />
<include name="commons-collections.jar" />
+ <include name="commons-logging.jar" />
<include name="dom4j.jar" />
<include name="freemarker.jar" />
<include name="hibernate-core.jar" />
@@ -344,6 +351,7 @@
<include name="jta.jar" />
<include name="juel*.jar" />
<include name="livetribe-jsr223.jar" />
+ <include name="log4j.jar" />
<include name="mail.jar" />
<include name="slf4j-api.jar" />
<include name="slf4j-jdk14.jar" />
@@ -355,12 +363,18 @@
</fileset>
</copy>
+ <!-- Copy jbpm-console wars into /webapps -->
<copy todir="${tomcat.home}/webapps" overwrite="true">
<fileset dir="${jbpm.home}/lib">
- <include name="gwt-console.war" />
- <include name="gwt-console-server.war" />
+ <include name="gwt-console-jbpm.war" />
+ <include name="gwt-console-server-jbpm.war" />
</fileset>
</copy>
+
+ <!-- Rename wars (the context root is configured by WEB-INF/jboss-web.xml,
+ which is neglected by Tomcat -->
+ <move file="${tomcat.home}/webapps/gwt-console-jbpm.war" tofile="${tomcat.home}/webapps/jbpm-console.war" />
+ <move file="${tomcat.home}/webapps/gwt-console-server-jbpm.war" tofile="${tomcat.home}/webapps/gwt-console-server.war" />
<!-- reporting -->
<property name="birt.dir" value="${tomcat.home}/birt"/>
@@ -369,10 +383,54 @@
<unzip src="${jbpm.home}/lib/jbpm-console-reports.jar" dest="${birt.dir}"/>
<!-- copy database driver -->
- <property name="driver.destination.dir" value="${tomcat.home}/" />
- <property name="is.tomcat" value="true" />
+ <property name="database.driver.destination.dir" value="${tomcat.home}/lib" />
<antcall target="internal.copy.database.driver" />
+
</target>
+
+ <!-- ### INSTALL HSQLDB SERVER ################################################ -->
+ <target name="install.hsqldb.server">
+ <delete dir="${hsqldb.server.install.dir}" /> <!-- Also deletes old data -->
+ <mkdir dir="${hsqldb.server.install.dir}"/>
+ <copy file="${jbpm.home}/lib/hsqldb.jar" todir="${hsqldb.server.install.dir}" />
+ <copy todir="${hsqldb.server.install.dir}">
+ <fileset dir="${hsqldb.server.source.dir}" />
+ </copy>
+ <chmod perm="a+x" os="Linux, Mac OS X">
+ <fileset dir="${hsqldb.server.install.dir}">
+ <include name="*.sh"/>
+ </fileset>
+ </chmod>
+ </target>
+
+ <!-- ### START HSQLDB SERVER ################################################ -->
+ <target name="start.hsqldb.server" >
+ <taskdef name="start-hsqldb-server" classname="org.jbpm.pvm.internal.ant.StartHsqldbServerTask">
+ <classpath>
+ <fileset dir="${jbpm.home}">
+ <include name="jbpm.jar"/>
+ </fileset>
+ </classpath>
+ </taskdef>
+ <start-hsqldb-server hsqldbServerHome="${hsqldb.server.install.dir}" />
+ </target>
+
+ <!-- ### SHUTDOWN HSQLDB SERVER ################################################ -->
+ <target name="shutdown.hsqldb.server">
+ <property file="${jbpm.home}/install/src/jdbc/${database}.properties" />
+ <sql driver="${jdbc.driver}"
+ password="${jdbc.password}"
+ url="${jdbc.url}"
+ userid="${jdbc.username}"
+ autocommit="true"
+ src="${hsqldb.server.install.dir}/shutdown.sql">
+ <classpath>
+ <fileset dir="${hsqldb.server.install.dir}">
+ <include name="hsqldb.jar"/>
+ </fileset>
+ </classpath>
+ </sql>
+ </target>
<!-- ### START TOMCAT ################################################### -->
@@ -431,6 +489,8 @@
<target name="create.jbpm.schema"
description="creates the jbpm tables in the database">
<property file="${jbpm.home}/install/src/jdbc/${database}.properties" />
+ <echo message="DB driver ... ${jdbc.driver}" />
+ <echo message="DB URL ...... ${jdbc.url}" />
<sql driver="${jdbc.driver}"
url="${jdbc.url}"
userid="${jdbc.username}"
@@ -502,7 +562,8 @@
<target name="internal.copy.database.driver.if.needed" if="database.driver">
<available file="${jbpm.home}/lib/${database.driver}" property="database.driver.jar.available" />
<fail message="please download the ${database} driver jar and put it in the ${jbpm.home}/lib directory" unless="database.driver.jar.available" />
- <copy file="${jbpm.home}/lib/${database.driver}" todir="${database.driver.destination.dir}" />
+ <echo message="Copying database driver ${database.driver} to ${database.driver.destination.dir}" />
+ <copy file="${jbpm.home}/lib/${database.driver}" todir="${database.driver.destination.dir}" />
</target>
</project>
Added: jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/shutdown.sql
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/shutdown.sql (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/shutdown.sql 2009-08-26 09:11:53 UTC (rev 5539)
@@ -0,0 +1 @@
+SHUTDOWN
\ No newline at end of file
Added: jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.bat
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.bat (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.bat 2009-08-26 09:11:53 UTC (rev 5539)
@@ -0,0 +1 @@
+java -cp hsqldb.jar org.hsqldb.Server -address localhost -port 1701 -dbname.0 jbpmDatabase
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.bat
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.sh
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.sh (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.sh 2009-08-26 09:11:53 UTC (rev 5539)
@@ -0,0 +1 @@
+java -cp hsqldb.jar org.hsqldb.Server -address localhost -port 1701 -dbname.0 jbpmDatabase
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/distro/src/main/files/install/src/hsqldb-server/start-hsqldb-server.sh
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/JBPMIntegration.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/JBPMIntegration.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/JBPMIntegration.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,33 +21,47 @@
*/
package org.jbpm.integration.console;
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.HistoryService;
import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.api.TaskService;
import javax.naming.InitialContext;
/**
* Base class for jbpm integration
+ *
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public abstract class JBPMIntegration
-{
+public abstract class JBPMIntegration {
+
protected ProcessEngine processEngine;
+
+ protected ExecutionService executionService;
+
+ protected TaskService taskService;
+
+ protected HistoryService historyService;
+
+ protected RepositoryService repositoryService;
- public JBPMIntegration()
- {
+ public JBPMIntegration() {
initializeProcessEngine();
}
- protected void initializeProcessEngine()
- {
- try
- {
- InitialContext ctx = new InitialContext();
- this.processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
+ protected void initializeProcessEngine() {
+ processEngine = ProcessEngineUtil.retrieveProcessEngine();
+
+ if (processEngine == null) {
+ throw new RuntimeException("Process engine not initialized!");
}
- catch (Exception e)
- {
- throw new RuntimeException("Failed to lookup process engine", e);
- }
+
+ executionService = processEngine.getExecutionService();
+ taskService = processEngine.getTaskService();
+ historyService = processEngine.getHistoryService();
+ repositoryService = processEngine.getRepositoryService();
}
+
}
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ManagementFactoryImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ManagementFactoryImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ManagementFactoryImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,32 +21,27 @@
*/
package org.jbpm.integration.console;
-import org.jboss.bpm.console.server.util.InvocationProxy;
import org.jboss.bpm.console.server.integration.ManagementFactory;
-import org.jboss.bpm.console.server.integration.TaskManagement;
import org.jboss.bpm.console.server.integration.ProcessManagement;
+import org.jboss.bpm.console.server.integration.TaskManagement;
import org.jboss.bpm.console.server.integration.UserManagement;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
+ * @author jbarrez
*/
-public class ManagementFactoryImpl extends ManagementFactory
-{
- public ProcessManagement createProcessManagement()
- {
- return (ProcessManagement)
- InvocationProxy.newInstance(new ProcessManagementImpl());
+public class ManagementFactoryImpl extends ManagementFactory {
+
+ public ProcessManagement createProcessManagement() {
+ return new ProcessManagementImpl();
}
- public TaskManagement createTaskManagement()
- {
- return (TaskManagement)
- InvocationProxy.newInstance(new TaskManagementImpl());
+ public TaskManagement createTaskManagement() {
+ return new TaskManagementImpl();
}
-
- public UserManagement createUserManagement()
- {
- throw new IllegalArgumentException("Not implemented");
+ public UserManagement createUserManagement() {
+ throw new UnsupportedOperationException("Not implemented");
}
+
}
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,62 +21,74 @@
*/
package org.jbpm.integration.console;
-import org.jboss.bpm.console.client.model.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.bpm.console.client.model.DeploymentRef;
+import org.jboss.bpm.console.client.model.JobRef;
+import org.jboss.bpm.console.client.model.ParticipantRef;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.TaskRef;
+import org.jboss.bpm.console.client.model.TokenReference;
import org.jbpm.api.Deployment;
+import org.jbpm.api.Execution;
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.HistoryService;
import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.api.TaskService;
import org.jbpm.api.job.Job;
import org.jbpm.api.task.Participation;
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.model.Transition;
-import org.jbpm.pvm.internal.repository.DeploymentImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
+ * @author jbarrez
*/
-public class ModelAdaptor
-{
- public static ProcessDefinitionRef adoptDefinition(ProcessDefinition processDefinition)
- {
+public class ModelAdaptor {
+
+ public static ProcessDefinitionRef adoptDefinition(ProcessDefinition processDefinition) {
ProcessDefinitionRef def = new ProcessDefinitionRef();
- def.setId( processDefinition.getId() );
+ def.setId(processDefinition.getId());
def.setName(processDefinition.getName());
def.setVersion(processDefinition.getVersion());
- def.setKey( processDefinition.getKey() );
-
- // TODO: why is that not part of the API and requires cast?
- ProcessDefinitionImpl cast = (ProcessDefinitionImpl)processDefinition;
-
- //def.setDescription(processDefinition.getDescription());
- def.setPackageName(cast.getPackageName());
- def.setDeploymentId(String.valueOf(cast.getDeploymentId()));
+ def.setKey(processDefinition.getKey());
+ def.setSuspended(processDefinition.isSuspended());
+ def.setDeploymentId(processDefinition.getDeploymentId());
+
+ // TODO: Are these needed?
+ // ProcessDefinitionImpl cast = (ProcessDefinitionImpl) processDefinition;
+ // def.setDescription(processDefinition.getDescription());
+ // def.setPackageName(cast.getPackageName());
+
return def;
-
}
- public static ProcessInstanceRef adoptExecution(ExecutionImpl e0)
- {
+ public static ProcessInstanceRef adoptExecution(Execution execution) {
ProcessInstanceRef ref = new ProcessInstanceRef();
- ref.setId( e0.getId() );
- ref.setKey(e0.getKey());
- ref.setDefinitionId(e0.getProcessDefinition().getId() );
- ref.setStartDate( new Date() ); // TODO: FIXME
+ ref.setId(execution.getId());
+ ref.setKey(execution.getKey());
+ ref.setDefinitionId(execution.getProcessDefinitionId());
+
+ // Start date is only available through historyService
+ HistoryService historyService = ProcessEngineUtil.retrieveProcessEngine().getHistoryService();
+ Date startDate = historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(execution.getId())
+ .uniqueResult().getStartTime();
+ ref.setStartDate(startDate);
- ExecutionImpl topLevelExecution = e0.getProcessInstance();
+ Execution topLevelExecution = execution.getProcessInstance();
TokenReference tok = execution2TokenReference(topLevelExecution);
- Collection<ExecutionImpl> childExecutions = (Collection)topLevelExecution.getExecutions();
- if(childExecutions!=null)
- {
- for(ExecutionImpl childExecution : childExecutions)
- {
+ Collection<ExecutionImpl> childExecutions = (Collection) topLevelExecution.getExecutions();
+ if (childExecutions != null) {
+ for (ExecutionImpl childExecution : childExecutions) {
TokenReference childTok = execution2TokenReference(childExecution);
tok.getChildren().add(childTok);
}
@@ -87,122 +99,121 @@
return ref;
}
- private static TokenReference execution2TokenReference(ExecutionImpl topLevelExecution)
- {
+ private static TokenReference execution2TokenReference(Execution execution) {
TokenReference tok = new TokenReference();
- tok.setName(topLevelExecution.getName());
- tok.setId(topLevelExecution.getId());
- tok.setCurrentNodeName( topLevelExecution.getActivityName() );
-
+ tok.setName(execution.getName());
+ tok.setId(execution.getId());
+
+ // Only if the set of current activitities has one element, we can
+ // set the current node name (otherwise it's a parent execution)
+ Set<String> currentActivities = execution.findActiveActivityNames();
+ if (currentActivities.size() == 1) {
+ tok.setCurrentNodeName(currentActivities.iterator().next());
+ }
+
+
+
// transitions
List<String> availableSignals = new ArrayList<String>();
-
- ExecutionImpl openTopLevelExecution = (ExecutionImpl) topLevelExecution;
+ /* TODO: FIX THIS
+ ExecutionImpl openTopLevelExecution = (ExecutionImpl) execution;
+
List<Transition> outTransitions = openTopLevelExecution.getActivity().getOutgoingTransitions();
- if(outTransitions!=null) // crappy jBPM API
- {
- for(Transition t : outTransitions)
- {
+ if (outTransitions != null) {
+ for (Transition t : outTransitions) {
// TODO: Fix when https://jira.jboss.org/jira/browse/JBPM-2220 is done
- String transitionName = t.getName()!=null ? t.getName() : "to_"+t.getDestination().getName();
+ String transitionName = t.getName() != null ? t.getName() : "to_" + t.getDestination().getName();
availableSignals.add(transitionName);
}
}
tok.setAvailableSignals(availableSignals);
+*/
return tok;
}
- public static TaskRef adoptTask(Task t0)
- {
+ public static TaskRef adoptTask(Task jbpmTask) {
TaskRef task = new TaskRef();
- task.setId( ((TaskImpl)t0).getDbid() );
- task.setName( t0.getName());
- task.setAssignee( t0.getAssignee() );
+
+ task.setId(((TaskImpl) jbpmTask).getDbid());
+ task.setName(jbpmTask.getName());
+ task.setAssignee(jbpmTask.getAssignee());
+
+ task.setPriority(jbpmTask.getPriority());
+ task.setDueDate(jbpmTask.getDuedate());
+ task.setCreateDate(jbpmTask.getCreateTime());
+
+ ExecutionService executionService = ProcessEngineUtil.retrieveProcessEngine().getExecutionService();
+ Execution pi = executionService.findExecutionById(jbpmTask.getExecutionId()).getProcessInstance();
+ task.setProcessInstanceId(pi.getId());
+ task.setProcessId(pi.getProcessDefinitionId());
+
+ // cast
+ //TaskImpl cast = ((TaskImpl) jbpmTask);
+ //task.setSignalling(cast.isSignalling()); // TODO: wat met dit?
- TaskImpl cast = ((TaskImpl) t0);
- task.setSignalling( cast.isSignalling());
+ //ExecutionImpl execution = cast.getProcessInstance();
+ //task.setProcessInstanceId(cast.getProcessInstance().getId());
- ExecutionImpl execution = cast.getProcessInstance();
- task.setProcessInstanceId( cast.getProcessInstance().getId() );
-
- // TODO: weird API
- task.setProcessId( execution.getProcessInstance().getProcessDefinition().getId() );
-
// participations
- for(Participation p0 : cast.getParticipations())
- {
- if(p0.getType().equals(Participation.CANDIDATE))
- {
- if(p0.getGroupId()!=null)
- {
- ParticipantRef participant = new ParticipantRef("candidate", p0.getGroupId());
+ TaskService taskService = ProcessEngineUtil.retrieveProcessEngine().getTaskService();
+ List<Participation> participations = taskService.getTaskParticipations(jbpmTask.getId());
+ for (Participation participation : participations) {
+
+ if (participation.getType().equals(Participation.CANDIDATE)) {
+ if (participation.getGroupId() != null) {
+ ParticipantRef participant = new ParticipantRef("candidate", participation.getGroupId());
participant.setGroup(true);
task.getParticipantGroups().add(participant);
- }
- else if(p0.getUserId()!=null)
- {
- ParticipantRef participant = new ParticipantRef("candidate", p0.getUserId());
+ } else if (participation.getUserId() != null) {
+ ParticipantRef participant = new ParticipantRef("candidate", participation.getUserId());
task.getParticipantUsers().add(participant);
+ } else {
+ throw new IllegalArgumentException("Participation doesn't have user or group: " + participation);
}
- else
- {
- throw new IllegalArgumentException("Participation doesn't have user or group: " + p0);
- }
+ } else {
+ throw new IllegalArgumentException("Unknown participation type: " + participation.getType());
}
- else
- {
- throw new IllegalArgumentException("Unknown participation type: " +p0.getType());
- }
}
- // prio and duedate
- task.setPriority(t0.getPriority());
- task.setDueDate(t0.getDuedate());
- task.setCreateDate(t0.getCreateTime());
-
// task formResourceName url
- String url = t0.getFormResourceName()!=null ? t0.getFormResourceName() : "";
- task.setUrl( url );
-
+ String url = jbpmTask.getFormResourceName() != null ? jbpmTask.getFormResourceName() : "";
+ task.setUrl(url);
+
return task;
}
- public static DeploymentRef adoptDeployment(Deployment dpl)
- {
- DeploymentImpl d0 = (DeploymentImpl)dpl;
- DeploymentRef dRef = new DeploymentRef(
- dpl.getId(), d0.isSuspended()
- );
+ public static DeploymentRef adoptDeployment(Deployment deployment) {
+ DeploymentRef dRef = new DeploymentRef();
+ dRef.setId(deployment.getId());
+ dRef.setSuspended(deployment.getState().equals(Deployment.STATE_SUSPENDED));
+ dRef.setTimestamp(deployment.getTimestamp());
+
+ RepositoryService repositoryService = ProcessEngineUtil.retrieveProcessEngine().getRepositoryService();
+ Set<String> resourceNames = repositoryService.getResourceNames(deployment.getId());
+ dRef.getResourceNames().addAll(resourceNames);
- String name = d0.getName();
- dRef.getResourceNames().addAll(d0.getResourceNames());
-
+ String name = deployment.getName();
// strip path info
- if(name.indexOf("/")!=-1)
- {
- name = name.substring(name.lastIndexOf("/")+1, name.length());
+ if (name.indexOf("/") != -1) {
+ name = name.substring(name.lastIndexOf("/") + 1, name.length());
}
-
dRef.setName(name);
- dRef.setTimestamp(d0.getTimestamp());
return dRef;
}
- public static JobRef adoptJob(Job j)
- {
- JobRef job = new JobRef();
- job.setId(String.valueOf(j.getId()));
- if(j.getDueDate()!=null)
- {
- job.setTimestamp(j.getDueDate().getTime());
+ public static JobRef adoptJob(Job job) {
+ JobRef jobRef = new JobRef();
+ jobRef.setId(String.valueOf(job.getId()));
+
+ if (job.getDuedate() != null) {
+ jobRef.setTimestamp(job.getDuedate().getTime());
}
- if(j.getException()!=null)
- {
- job.setErrMsg(j.getException());
+ if (job.getException() != null) {
+ jobRef.setErrMsg(job.getException());
}
- return job;
+ return jobRef;
}
}
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEnginePluginImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEnginePluginImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEnginePluginImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,166 +21,102 @@
*/
package org.jbpm.integration.console;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.bpm.console.client.model.DeploymentRef;
import org.jboss.bpm.console.client.model.JobRef;
import org.jboss.bpm.console.server.plugin.ProcessEnginePlugin;
-import org.jbpm.api.*;
+import org.jbpm.api.Deployment;
+import org.jbpm.api.ManagementService;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessDefinitionQuery;
+import org.jbpm.api.RepositoryService;
import org.jbpm.api.job.Job;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
+ * @author jbarrez
*/
-public class ProcessEnginePluginImpl extends JBPMIntegration
- implements ProcessEnginePlugin
-{
+public class ProcessEnginePluginImpl extends JBPMIntegration implements ProcessEnginePlugin {
- public ProcessEnginePluginImpl()
- {
- initializeProcessEngine();
+ public ProcessEnginePluginImpl() {
+ super();
}
- public List<DeploymentRef> getDeployments()
- {
+ public List<DeploymentRef> getDeployments() {
List<DeploymentRef> results = new ArrayList<DeploymentRef>();
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ List<Deployment> dpls = repositoryService.createDeploymentQuery().list();
- try
- {
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- DeploymentQuery dquery = repositoryService.createDeploymentQuery();
+ for (Deployment dpl : dpls) {
+ DeploymentRef deploymentRef = ModelAdaptor.adoptDeployment(dpl);
- List<Deployment> dpls = dquery.list();
+ // active processes for deployment
+ ProcessDefinitionQuery pdQuery = repositoryService.createProcessDefinitionQuery();
+ pdQuery.deploymentId(dpl.getId());
+ List<ProcessDefinition> activePds = pdQuery.list();
- for(Deployment dpl : dpls)
- {
- DeploymentRef ref = ModelAdaptor.adoptDeployment(dpl);
+ for (ProcessDefinition procDef : activePds) {
+ deploymentRef.getDefinitions().add(procDef.getId());
+ }
- // active processes
- ProcessDefinitionQuery pdQuery = repositoryService.createProcessDefinitionQuery();
- pdQuery.deploymentId(dpl.getId());
- List<ProcessDefinition> activePds = pdQuery.list();
+ // suspended processes for deployment
+ List<ProcessDefinition> suspendedPds =
+ repositoryService.createProcessDefinitionQuery()
+ .deploymentId(dpl.getId())
+ .suspended()
+ .list();
- for(ProcessDefinition p : activePds)
- {
- ref.getDefinitions().add(p.getId());
- }
-
- // suspended processes
- ProcessDefinitionQuery pdQuery2 = repositoryService.createProcessDefinitionQuery();
- pdQuery2.deploymentId(dpl.getId());
- pdQuery2.suspended();
- List<ProcessDefinition> suspendedPds = pdQuery2.list();
-
- for(ProcessDefinition p : suspendedPds)
- {
- ref.getDefinitions().add(p.getId());
- }
-
- results.add(ref);
+ for (ProcessDefinition procDef : suspendedPds) {
+ deploymentRef.getDefinitions().add(procDef.getId());
}
- return results;
+ results.add(deploymentRef);
}
- finally
- {
- env.close();
- }
- }
- public void deleteDeployment(String id)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- repositoryService.deleteDeploymentCascade(id);
- }
- finally
- {
- env.close();
- }
-
+ return results;
}
+
+ public void deleteDeployment(String id) {
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ repositoryService.deleteDeploymentCascade(id);
+ }
- public void suspendDeployment(String id, boolean isSuspended)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- if(isSuspended)
- repositoryService.suspendDeployment(id);
- else
- repositoryService.resumeDeployment(id);
- }
- finally
- {
- env.close();
- }
-
+ public void suspendDeployment(String id, boolean isSuspended) {
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ if (isSuspended)
+ repositoryService.suspendDeployment(id);
+ else
+ repositoryService.resumeDeployment(id);
}
- public List<JobRef> getJobs()
- {
+ public List<JobRef> getJobs() {
+ ManagementService mgmtService = this.processEngine.getManagementService();
List<JobRef> results = new ArrayList<JobRef>();
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ // timers
+ List<Job> timers = mgmtService.createJobQuery().timers().list();
+ for (Job t : timers) {
+ JobRef ref = ModelAdaptor.adoptJob(t);
+ ref.setType("timer");
+ results.add(ref);
+ }
- try
- {
- ManagementService mgmtService = this.processEngine.getManagementService();
-
- // jobs
- JobQuery timerQuery = mgmtService.createJobQuery();
- timerQuery.timers();
- List<Job> timers = timerQuery.list();
- for(Job t : timers)
- {
- JobRef ref = ModelAdaptor.adoptJob(t);
- ref.setType("timer");
- results.add(ref);
- }
-
- // messages
- JobQuery msgQuery= mgmtService.createJobQuery();
- msgQuery.messages();
- List<Job> msgs = msgQuery.list();
- for(Job t : msgs)
- {
- JobRef ref = ModelAdaptor.adoptJob(t);
- ref.setType("message");
- results.add(ref);
- }
+ // messages
+ List<Job> msgs = mgmtService.createJobQuery().messages().list();
+ for (Job t : msgs) {
+ JobRef ref = ModelAdaptor.adoptJob(t);
+ ref.setType("message");
+ results.add(ref);
}
- finally
- {
- env.close();
- }
return results;
}
-
- public void executeJob(String jobId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- ManagementService mgmtService = this.processEngine.getManagementService();
- mgmtService.executeJob(jobId);
- }
- finally
- {
- env.close();
- }
+ public void executeJob(String jobId) {
+ ManagementService mgmtService = this.processEngine.getManagementService();
+ mgmtService.executeJob(jobId);
}
}
Added: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java (rev 0)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -0,0 +1,40 @@
+package org.jbpm.integration.console;
+
+import javax.naming.InitialContext;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ProcessEngine;
+
+/**
+ * Utility class for retrieving the {@link ProcessEngine}.
+ *
+ * @author jbarrez
+ */
+public final class ProcessEngineUtil {
+
+ private static ProcessEngine processEngine;
+
+ private static final String PROCESS_ENGINE_JNDI_NAME = "java:/ProcessEngine";
+
+ public static ProcessEngine retrieveProcessEngine() {
+ if (processEngine == null) {
+ synchronized (ProcessEngine.class) {
+
+ if (processEngine == null) {
+
+ try {
+ InitialContext ctx = new InitialContext();
+ processEngine = (ProcessEngine) ctx.lookup(PROCESS_ENGINE_JNDI_NAME);
+ } catch (Exception e) {
+ // Fall back to default mechanism which build a procEngine from a default jbpm.cfg.xml
+ processEngine = Configuration.getProcessEngine();
+ }
+
+ }
+
+ }
+ }
+ return processEngine;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessEngineUtil.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -22,7 +22,11 @@
package org.jbpm.integration.console;
import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
@@ -33,316 +37,155 @@
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.ProcessInstanceQuery;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.api.history.HistoryProcessInstanceQuery;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.model.ExecutionImpl;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
+ * @author jbarrez
*/
-class ProcessManagementImpl extends JBPMIntegration implements ProcessManagement
-{
+class ProcessManagementImpl extends JBPMIntegration implements ProcessManagement {
+
+
+ public ProcessManagementImpl() {
+ super();
+ }
- public List<ProcessDefinitionRef> getProcessDefinitions()
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public List<ProcessDefinitionRef> getProcessDefinitions() {
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();
- try
- {
- List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();
+ // active process definitions
+ List<ProcessDefinition> activePds =
+ repositoryService.createProcessDefinitionQuery()
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .list();
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
-
- // active processes
- List<ProcessDefinition> activePds = repositoryService.createProcessDefinitionQuery()
- .notSuspended()
- .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
- .list();
-
- for(ProcessDefinition processDefinition : activePds)
- {
- ProcessDefinitionRef ref = ModelAdaptor.adoptDefinition(processDefinition);
- results.add(ref);
- }
-
- // suspended processes
- ProcessDefinitionQuery pdQuery2 = repositoryService.createProcessDefinitionQuery();
- pdQuery2.suspended();
- List<ProcessDefinition> suspendedPds = pdQuery2.list();
-
- for(ProcessDefinition p : suspendedPds)
- {
- ProcessDefinitionRef ref = ModelAdaptor.adoptDefinition(p);
- ref.setSuspended(true);
- results.add(ref);
- }
-
- return results;
+ for (ProcessDefinition processDefinition : activePds) {
+ results.add(ModelAdaptor.adoptDefinition(processDefinition));
}
- finally
- {
- env.close();
- }
+ return results;
}
- public ProcessDefinitionRef getProcessDefinition(String procDefId)
- {
+ public ProcessDefinitionRef getProcessDefinition(String procDefId) {
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).uniqueResult();
+ return ModelAdaptor.adoptDefinition(processDefinition);
+ }
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
- .processDefinitionId(procDefId)
- .uniqueResult();
- return ModelAdaptor.adoptDefinition(processDefinition);
-
+ public List<ProcessDefinitionRef> removeProcessDefinition(String procDefId) {
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).uniqueResult();
+ if (processDefinition != null) {
+ // Todo: this deletes a complete deployment. Currently, there is no way of deleting a procDef only
+ repositoryService.deleteDeploymentCascade(processDefinition.getDeploymentId());
}
- finally
- {
- env.close();
- }
+ return getProcessDefinitions();
}
- public List<ProcessDefinitionRef> removeProcessDefinition(String procDefId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public List<ProcessInstanceRef> getProcessInstances(String procDefId) {
+ ExecutionService execService = this.processEngine.getExecutionService();
+ List<ProcessInstance> processInstances = execService.createProcessInstanceQuery()
+ .processDefinitionId(procDefId)
+ .list();
- try
- {
+ List<ProcessInstanceRef> results = adoptProcessInstances(processInstances);
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
- .processDefinitionId(procDefId)
- .uniqueResult();
- if (processDefinition!=null) {
- repositoryService.deleteDeploymentCascade(processDefinition.getDeploymentId());
- }
- return getProcessDefinitions();
+ // add history info
+ // TODO: optimize w. batch query
+ HistoryService histService = this.processEngine.getHistoryService();
+ for (ProcessInstanceRef inst : results) {
+ HistoryProcessInstanceQuery hQuery = histService.createHistoryProcessInstanceQuery();
+ hQuery.processInstanceId(inst.getId());
+ HistoryProcessInstance entry = hQuery.uniqueResult();
+ inst.setStartDate(entry.getStartTime());
}
- finally
- {
- env.close();
- }
+ return results;
}
- public List<ProcessInstanceRef> getProcessInstances(String procDefId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
-
- ExecutionService execService = this.processEngine.getExecutionService();
- ProcessInstanceQuery query = execService.createProcessInstanceQuery();
- query.processDefinitionId(String.valueOf(procDefId));
-
- List<ProcessInstance> processInstances = query.list();
-
- List<ProcessInstanceRef> results = adoptProcessInstances(processInstances);
-
- // add history info
- // TODO: optimize w. batch query
- HistoryService histService = this.processEngine.getHistoryService();
- for(ProcessInstanceRef inst : results)
- {
- HistoryProcessInstanceQuery hQuery = histService.createHistoryProcessInstanceQuery();
- hQuery.processInstanceId(inst.getId());
- HistoryProcessInstance entry = hQuery.uniqueResult();
- inst.setStartDate(entry.getStartTime());
+ private List<ProcessInstanceRef> adoptProcessInstances(List<ProcessInstance> processInstances) {
+ List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
+ for (Execution processInstance : processInstances) {
+ if (processInstance.isEnded()) {
+ continue; // JBPM-2055: Execution is already ended. Should not show up in query
}
- return results;
- }
- finally
- {
- env.close();
- }
- }
-
- private List<ProcessInstanceRef> adoptProcessInstances(List<ProcessInstance> processInstances)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
-
- List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
- for(Execution processInstance : processInstances)
- {
- if(processInstance.isEnded())
- {
- //JBPM-2055: Execution is already ended. Should not show up in query
- continue;
- }
-
- if(processInstance.isProcessInstance()) // parent execution
- {
- results.add( ModelAdaptor.adoptExecution((ExecutionImpl)processInstance) );
- }
+ if (processInstance.isProcessInstance()) { // parent execution
+ results.add(ModelAdaptor.adoptExecution((ExecutionImpl) processInstance));
}
- return results;
}
- finally
- {
- env.close();
- }
+ return results;
}
- public ProcessInstanceRef getProcessInstance(String instanceId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- ExecutionService execService = this.processEngine.getExecutionService();
- ProcessInstanceQuery query = execService.createProcessInstanceQuery();
- query.processInstanceId(instanceId);
- ProcessInstance processInstance = query.uniqueResult();
- return ModelAdaptor.adoptExecution( (ExecutionImpl)processInstance);
- }
- finally
- {
- env.close();
- }
+ public ProcessInstanceRef getProcessInstance(String instanceId) {
+ ExecutionService execService = this.processEngine.getExecutionService();
+ ProcessInstance processInstance = execService.createProcessInstanceQuery()
+ .processInstanceId(instanceId)
+ .uniqueResult();
+ return ModelAdaptor.adoptExecution((ExecutionImpl) processInstance);
}
-
- public Map<String, Object> getInstanceData(String instanceId)
- {
+ public Map<String, Object> getInstanceData(String instanceId) {
Map<String, Object> data = new HashMap<String, Object>();
-
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- ExecutionService execService = this.processEngine.getExecutionService();
- Set<String> keys = execService.getVariableNames(instanceId);
- data = execService.getVariables(instanceId, keys);
- }
- finally
- {
- env.close();
- }
-
+ ExecutionService execService = this.processEngine.getExecutionService();
+ Set<String> keys = execService.getVariableNames(instanceId);
+ data = execService.getVariables(instanceId, keys);
return data;
}
- public void setInstanceData(String instanceId, Map<String, Object> data)
- {
+ public void setInstanceData(String instanceId, Map<String, Object> data) {
throw new RuntimeException("Not implemented");
}
- public ProcessInstanceRef newInstance(String definitionId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- ExecutionService execService = this.processEngine.getExecutionService();
- Execution exec = execService.startProcessInstanceById(definitionId);
- return ModelAdaptor.adoptExecution((ExecutionImpl)exec);
- }
- finally{
- env.close();
- }
+ public ProcessInstanceRef newInstance(String definitionId) {
+ ExecutionService execService = this.processEngine.getExecutionService();
+ Execution exec = execService.startProcessInstanceById(definitionId);
+ return ModelAdaptor.adoptExecution((ExecutionImpl) exec);
}
-
- public ProcessInstanceRef newInstance(String definitionId, Map<String, Object> processVars)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- ExecutionService execService = this.processEngine.getExecutionService();
- Execution exec = execService.startProcessInstanceById(definitionId, processVars);
-
- return ModelAdaptor.adoptExecution((ExecutionImpl)exec);
- }
- finally{
- env.close();
- }
+ public ProcessInstanceRef newInstance(String definitionId, Map<String, Object> processVars) {
+ ExecutionService execService = this.processEngine.getExecutionService();
+ Execution exec = execService.startProcessInstanceById(definitionId, processVars);
+ return ModelAdaptor.adoptExecution((ExecutionImpl) exec);
}
- public void endInstance(String instanceId, ProcessInstanceRef.RESULT result)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public void endInstance(String instanceId, ProcessInstanceRef.RESULT result) {
+ ExecutionService execService = this.processEngine.getExecutionService();
+ Execution exec = execService.findExecutionById(instanceId);
+ if (null == exec)
+ throw new IllegalArgumentException("No such execution with id " + instanceId);
- try
- {
-
- ExecutionService execService = this.processEngine.getExecutionService();
- Execution exec = execService.findExecutionById(instanceId);
- if(null==exec)
- throw new IllegalArgumentException("No such execution with id "+ instanceId);
-
- ProcessInstanceRef.RESULT actualResult = result!=null ? result : ProcessInstanceRef.RESULT.COMPLETED;
- execService.endProcessInstance(instanceId, actualResult.toString());
- }
- finally
- {
- env.close();
- }
+ ProcessInstanceRef.RESULT actualResult = result != null ? result : ProcessInstanceRef.RESULT.COMPLETED;
+ execService.endProcessInstance(instanceId, actualResult.toString());
}
- public void deleteInstance(String instanceId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public void deleteInstance(String instanceId) {
+ ExecutionService execService = this.processEngine.getExecutionService();
+ Execution exec = execService.findExecutionById(instanceId);
+
+ if (null == exec)
+ throw new IllegalArgumentException("No such execution with id " + instanceId);
- try
- {
-
- ExecutionService execService = this.processEngine.getExecutionService();
- Execution exec = execService.findExecutionById(instanceId);
- if(null==exec)
- throw new IllegalArgumentException("No such execution with id "+ instanceId);
-
- execService.deleteProcessInstance(instanceId);
- }
- finally
- {
- env.close();
- }
+ execService.deleteProcessInstance(instanceId);
}
- public void setProcessState(
- String executionId,
- ProcessInstanceRef.STATE nextState
- )
- {
+ public void setProcessState(String executionId, ProcessInstanceRef.STATE nextState) {
throw new RuntimeException("Not implemented");
}
- public void signalExecution(String executionId, String signal)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public void signalExecution(String executionId, String signal) {
+ ExecutionService execService = this.processEngine.getExecutionService();
- try
- {
- ExecutionService execService = this.processEngine.getExecutionService();
-
- if(null==signal)
- execService.signalExecutionById(executionId);
- else
- execService.signalExecutionById(executionId, signal);
- }
- finally
- {
- env.close();
- }
-
+ if (null == signal)
+ execService.signalExecutionById(executionId);
+ else
+ execService.signalExecutionById(executionId, signal);
}
- public void deploy(String fileName, String contentType, InputStream deployment)
- {
+ public void deploy(String fileName, String contentType, InputStream deployment) {
throw new RuntimeException("Not implemented");
}
}
-
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -30,146 +30,76 @@
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Participation;
import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class TaskManagementImpl extends JBPMIntegration implements TaskManagement
-{
- public List<TaskRef> getAssignedTasks(String idRef)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+public class TaskManagementImpl extends JBPMIntegration implements TaskManagement {
+
+
+ public TaskManagementImpl() {
+ super();
+ }
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- List<TaskRef> results = new ArrayList<TaskRef>();
+ public List<TaskRef> getAssignedTasks(String idRef) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ List<TaskRef> results = new ArrayList<TaskRef>();
- List<Task> assignedTasks = taskService.findPersonalTasks(idRef);
- adoptTasks(assignedTasks, results);
-
- return results;
- }
- finally
- {
- env.close();
- }
+ List<Task> assignedTasks = taskService.findPersonalTasks(idRef);
+ adoptTasks(assignedTasks, results);
+ return results;
}
- public List<TaskRef> getUnassignedTasks(String idRef, String participationType)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public List<TaskRef> getUnassignedTasks(String idRef, String participationType) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ List<TaskRef> results = new ArrayList<TaskRef>();
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- List<TaskRef> results = new ArrayList<TaskRef>();
-
- if(null==participationType || participationType.equals(Participation.CANDIDATE))
- {
- List<Task> groupTasks = taskService.findGroupTasks(idRef);
- adoptTasks(groupTasks, results);
- }
- else
- {
- throw new IllegalArgumentException("Unknown participation type: " +participationType);
- }
-
- return results;
+ if (null == participationType || participationType.equals(Participation.CANDIDATE)) {
+ List<Task> groupTasks = taskService.findGroupTasks(idRef);
+ adoptTasks(groupTasks, results);
+ } else {
+ throw new IllegalArgumentException("Unknown participation type: " + participationType);
}
- finally
- {
- env.close();
- }
+
+ return results;
}
- private void adoptTasks(List<Task> tasks, List<TaskRef> results)
- {
- for(Task t0 : tasks)
- {
- results.add( ModelAdaptor.adoptTask(t0) );
+ private void adoptTasks(List<Task> tasks, List<TaskRef> results) {
+ for (Task t0 : tasks) {
+ results.add(ModelAdaptor.adoptTask(t0));
}
}
- public TaskRef getTaskById(long taskId)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- Task t0 = taskService.getTask(Long.toString(taskId));
- return ModelAdaptor.adoptTask(t0);
- }
- finally{
- env.close();
- }
+ public TaskRef getTaskById(long taskId) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ Task t0 = taskService.getTask(Long.toString(taskId));
+ return ModelAdaptor.adoptTask(t0);
}
- public void assignTask(long taskId, String idRef, String performingUser)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- taskService.assignTask(Long.toString(taskId), idRef);
- }
- finally{
- env.close();
- }
+ public void assignTask(long taskId, String idRef, String performingUser) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ taskService.assignTask(Long.toString(taskId), idRef);
}
- public void releaseTask(long taskId, String performingUser)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- taskService.assignTask(Long.toString(taskId), null);
- }
- finally{
- env.close();
- }
+ public void releaseTask(long taskId, String performingUser) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ taskService.assignTask(Long.toString(taskId), null);
}
- public void completeTask(long taskId, Map data, String performingUser)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public void completeTask(long taskId, Map data, String performingUser) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ if (data != null)
+ taskService.setVariables(Long.toString(taskId), data);
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- if(data!=null)
- taskService.setVariables(Long.toString(taskId), data);
-
- taskService.completeTask(Long.toString(taskId));
- }
- finally{
- env.close();
- }
+ taskService.completeTask(Long.toString(taskId));
}
- public void completeTask(long taskId, String outcome, Map data, String performingUser)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ public void completeTask(long taskId, String outcome, Map data, String performingUser) {
+ TaskService taskService = this.processEngine.get(TaskService.class);
+ if (data != null)
+ taskService.setVariables(Long.toString(taskId), data);
- try
- {
- TaskService taskService = this.processEngine.get(TaskService.class);
- if(data!=null)
- taskService.setVariables(Long.toString(taskId), data);
-
- taskService.completeTask(Long.toString(taskId), outcome);
- }
- finally
- {
- env.close();
- }
+ taskService.completeTask(Long.toString(taskId), outcome);
}
}
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -23,6 +23,8 @@
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
+
+import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
import org.jbpm.integration.spi.mgmt.ServerConfig;
import org.jbpm.integration.spi.mgmt.ServerConfigFactory;
@@ -34,69 +36,61 @@
import java.util.Map;
/**
- * Base class for freemarker based form dispatcher implementations
- * that should run on JBoss. Uses {@link org.jbpm.integration.spi.mgmt.ServerConfig}
- * to resolve the HTTP host and port.
+ * Base class for freemarker based form dispatcher implementations that should
+ * run on JBoss. Uses {@link org.jbpm.integration.spi.mgmt.ServerConfig} to
+ * resolve the HTTP host and port.
*
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class AbstractFormDispatcher
-{
- //private static final Log log = LogFactory.getLog(AbstractFormDispatcher.class);
+public class AbstractFormDispatcher {
+ // private static final Log log =
+ // LogFactory.getLog(AbstractFormDispatcher.class);
+
protected final static String WEB_CONTEXT = "/gwt-console-server/rs";
-
+
protected ProcessEngine processEngine;
- protected ServerConfig serverConfig = null; // lazy
+
+ protected ServerConfig serverConfig = null; // lazy
+
protected static final String FORM_DIRECTIVE_KEY = "form";
+
protected static final String OUTCOME_DIRECTIVE_NAME = "outcome";
- public AbstractFormDispatcher()
- {
+ public AbstractFormDispatcher() {
initializeProcessEngine();
}
- protected void initializeProcessEngine()
- {
- try
- {
+ protected void initializeProcessEngine() {
+ try {
InitialContext ctx = new InitialContext();
- this.processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
+ this.processEngine = (ProcessEngine) ctx.lookup("java:/ProcessEngine");
+ } catch (Exception e) {
+ // Fall back to default mechanism
+ this.processEngine = Configuration.getProcessEngine();
}
- catch (Exception e)
- {
- throw new RuntimeException("Failed to lookup process engine", e);
- }
}
- protected ServerConfig getServerConfig()
- {
- if(null==serverConfig)
- {
+ protected ServerConfig getServerConfig() {
+ if (null == serverConfig) {
serverConfig = ServerConfigFactory.getServerConfig();
}
return serverConfig;
}
- protected StringBuilder getBaseUrl()
- {
+ protected StringBuilder getBaseUrl() {
StringBuilder spec = new StringBuilder();
spec.append("http://");
spec.append(getServerConfig().getWebServiceHost());
spec.append(":").append(getServerConfig().getWebServicePort());
spec.append(WEB_CONTEXT);
- return spec;
+ return spec;
}
- protected DataHandler processTemplate(
- final String name, InputStream src,
- Map<String, Object> renderContext
- )
- {
+ protected DataHandler processTemplate(final String name, InputStream src, Map<String, Object> renderContext) {
DataHandler merged = null;
- try
- {
+ try {
freemarker.template.Configuration cfg = new freemarker.template.Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setTemplateUpdateDelay(0);
@@ -104,12 +98,11 @@
Template temp = new Template(name, new InputStreamReader(src), cfg);
// dump template
- /* if(log.isDebugEnabled())
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- temp.dump(new PrintWriter(bout));
- log.debug(new String(bout.toByteArray()));
- }*/
+ /*
+ * if(log.isDebugEnabled()) { ByteArrayOutputStream bout = new
+ * ByteArrayOutputStream(); temp.dump(new PrintWriter(bout));
+ * log.debug(new String(bout.toByteArray())); }
+ */
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
Writer out = new OutputStreamWriter(bout);
@@ -118,34 +111,26 @@
merged = new DataHandler(
- new DataSource()
- {
+ new DataSource() {
- public InputStream getInputStream() throws IOException
- {
- return new ByteArrayInputStream(bout.toByteArray());
- }
+ public InputStream getInputStream() throws IOException {
+ return new ByteArrayInputStream(bout.toByteArray());
+ }
- public OutputStream getOutputStream() throws IOException
- {
- return bout;
- }
+ public OutputStream getOutputStream() throws IOException {
+ return bout;
+ }
- public String getContentType()
- {
- return "application/octet-stream";
- }
+ public String getContentType() {
+ return "application/octet-stream";
+ }
- public String getName()
- {
- return name + "_DataSource";
- }
- }
- );
+ public String getName() {
+ return name + "_DataSource";
+ }
+ });
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new RuntimeException("Failed to process task template", e);
}
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/FormDispatcherComposite.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/FormDispatcherComposite.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/FormDispatcherComposite.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,13 +21,13 @@
*/
package org.jbpm.integration.console.forms;
-import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
-import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
+import java.net.URL;
import javax.activation.DataHandler;
-import java.net.URL;
-import java.util.Map;
+import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
+import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,14 +21,6 @@
*/
package org.jbpm.integration.console.forms;
-import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
-import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.RepositoryService;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-
-import javax.activation.DataHandler;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -36,120 +28,90 @@
import java.util.List;
import java.util.Map;
+import javax.activation.DataHandler;
+
+import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
+import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.RepositoryService;
+
/**
* Processes form data to start processes.
*
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class ProcessFormDispatcher extends AbstractFormDispatcher
- implements FormDispatcherPlugin
-{
+public class ProcessFormDispatcher extends AbstractFormDispatcher implements FormDispatcherPlugin {
- public URL getDispatchUrl(FormAuthorityRef ref)
- {
- if(!processHasForm(ref.getReferenceId()))
+ public URL getDispatchUrl(FormAuthorityRef ref) {
+ if (!processHasForm(ref.getReferenceId())) {
return null;
-
+ }
+
StringBuilder baseUrl = getBaseUrl();
baseUrl.append("/form/process/");
- baseUrl.append( ref.getReferenceId());
+ baseUrl.append(ref.getReferenceId());
baseUrl.append("/render");
- try
- {
+ try {
return new URL(baseUrl.toString());
- }
- catch (MalformedURLException e)
- {
+ } catch (MalformedURLException e) {
throw new RuntimeException("Failed to resolve task dispatch url", e);
}
}
- private boolean processHasForm(String id)
- {
- return getStartFormName(id)!=null;
+ private boolean processHasForm(String id) {
+ return getStartFormName(id) != null;
}
- private String getStartFormName(String id)
- {
- String name = null;
+ private String getStartFormName(String procDefId) {
+ RepositoryService repoService = processEngine.getRepositoryService();
+ List<String> startActivityNames = repoService.getStartActivityNames(procDefId);
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
- try
- {
- RepositoryService repoService = processEngine.getRepositoryService();
- List<String> startActivityNames = repoService.getStartActivityNames(id);
+ if (null == startActivityNames)
+ throw new RuntimeException("Unable to resolve start activity names for process: " + procDefId);
- if(null==startActivityNames) // who knows? I'd expect anything from jbpm
- throw new RuntimeException("Unable to resolve start activity names for process: "+id);
-
- String defaultActitvity = startActivityNames.get(0);
- if(startActivityNames.size()>1)
- {
- System.out.println("WARN: More then 1 start activity found. Default to " + defaultActitvity + " to resolve the form name.");
- }
-
- name = repoService.getStartFormResourceName(id, defaultActitvity);
- }
- finally{
- env.close();
- }
-
- return name;
+ String defaultActitvity = startActivityNames.get(0);
+ if (startActivityNames.size() > 1) {
+ System.out.println("WARN: More then 1 start activity found. Default to " + defaultActitvity + " to resolve the form name.");
+ }
+
+ return repoService.getStartFormResourceName(procDefId, defaultActitvity);
}
- public DataHandler provideForm(FormAuthorityRef ref)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
+ public DataHandler provideForm(FormAuthorityRef ref) {
DataHandler result = null;
- try
- {
+ RepositoryService repoService = processEngine.getRepositoryService();
- RepositoryService repoService = processEngine.getRepositoryService();
+ // check if a template exists
+ String startFormResourceName = getStartFormName(ref.getReferenceId());
+ if (null == startFormResourceName)
+ throw new IllegalArgumentException("Process " + ref.getReferenceId() + " doesn't provide a start form");
- // check if a template exists
- String startFormResourceName = getStartFormName(ref.getReferenceId());
- if(null==startFormResourceName)
- throw new IllegalArgumentException("Process " +ref.getReferenceId() + " doesn't provide a start form");
+ ProcessDefinition procDef = repoService.createProcessDefinitionQuery().processDefinitionId(ref.getReferenceId()).uniqueResult();
+ InputStream template = repoService.getResourceAsStream(procDef.getDeploymentId(), startFormResourceName);
- ProcessDefinition procDef =
- repoService
- .createProcessDefinitionQuery()
- .processDefinitionId(ref.getReferenceId())
- .uniqueResult();
+ // merge template with process variables
+ if (template != null) {
+ // plugin context
+ StringBuilder action = getBaseUrl();
+ action.append("/form/process/");
+ action.append(ref.getReferenceId());
+ action.append("/complete");
- InputStream template = repoService.getResourceAsStream(
- procDef.getDeploymentId(), startFormResourceName
- );
+ Map<String, Object> renderContext = new HashMap<String, Object>();
- // merge template with process variables
- if(template!=null)
- {
- // plugin context
- StringBuilder action = getBaseUrl();
- action.append("/form/process/");
- action.append( ref.getReferenceId() );
- action.append("/complete");
+ // form directive
+ FormDirective formDirective = new FormDirective();
+ formDirective.setAction(action.toString());
+ renderContext.put(FORM_DIRECTIVE_KEY, formDirective);
- Map<String, Object> renderContext = new HashMap<String,Object>();
-
- // form directive
- FormDirective formDirective = new FormDirective();
- formDirective.setAction( action.toString() );
- renderContext.put(FORM_DIRECTIVE_KEY, formDirective);
-
- // outcome directive
- renderContext.put(OUTCOME_DIRECTIVE_NAME, new OutcomeDirective());
-
- result = processTemplate(startFormResourceName, template, renderContext);
- }
-
- return result;
+ // outcome directive
+ renderContext.put(OUTCOME_DIRECTIVE_NAME, new OutcomeDirective());
+
+ result = processTemplate(startFormResourceName, template, renderContext);
}
- finally{
- env.close();
- }
+
+ return result;
}
}
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -21,150 +21,113 @@
*/
package org.jbpm.integration.console.forms;
-import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
-import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
-import org.jbpm.api.*;
-import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.Transition;
-import org.jbpm.pvm.internal.task.TaskImpl;
-
-import javax.activation.DataHandler;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.activation.DataHandler;
+
+import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
+import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+import org.jbpm.api.Execution;
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.api.TaskService;
+import org.jbpm.api.task.Task;
+
/**
* Processes form data to complete tasks.
- *
+ *
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class TaskFormDispatcher extends AbstractFormDispatcher
- implements FormDispatcherPlugin
-{
+public class TaskFormDispatcher extends AbstractFormDispatcher implements FormDispatcherPlugin {
- public TaskFormDispatcher()
- {
+ public TaskFormDispatcher() {
super();
}
- public URL getDispatchUrl(FormAuthorityRef ref)
- {
- if(!taskHasForm(ref.getReferenceId()))
+ public URL getDispatchUrl(FormAuthorityRef ref) {
+ if (!taskHasForm(ref.getReferenceId()))
return null;
StringBuilder baseUrl = getBaseUrl();
baseUrl.append("/form/task/");
- baseUrl.append( ref.getReferenceId());
+ baseUrl.append(ref.getReferenceId());
baseUrl.append("/render");
- try
- {
+ try {
return new URL(baseUrl.toString());
- }
- catch (MalformedURLException e)
- {
+ } catch (MalformedURLException e) {
throw new RuntimeException("Failed to resolve task dispatch url", e);
}
}
- private boolean taskHasForm(String id)
- {
+ private boolean taskHasForm(String id) {
boolean result = false;
-
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
- try
- {
- TaskService taskService = processEngine.getTaskService();
- Task task = taskService.getTask(id);
- result = (task.getFormResourceName()!=null);
- }
- finally
- {
- env.close();
- }
-
+ TaskService taskService = processEngine.getTaskService();
+ Task task = taskService.getTask(id);
+ result = (task.getFormResourceName() != null);
return result;
}
- public DataHandler provideForm(FormAuthorityRef ref)
- {
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
-
- try
- {
- TaskService taskService = processEngine.getTaskService();
- Task task = taskService.getTask(ref.getReferenceId());
+ public DataHandler provideForm(FormAuthorityRef ref) {
+ TaskService taskService = processEngine.getTaskService();
+ ExecutionService executionService = processEngine.getExecutionService();
+ RepositoryService repoService = processEngine.getRepositoryService();
+ Task task = taskService.getTask(ref.getReferenceId());
- // access the processdefition
- TaskImpl cast = ((TaskImpl) task);
- ExecutionImpl processInstance = cast.getProcessInstance();
- String processInstanceId = processInstance.getId();
- String processId = processInstance.getProcessDefinition().getId();
+ String executionId = task.getExecutionId();
+ Execution execution = executionService.findExecutionById(executionId);
+ String procInstId = execution.getProcessInstance().getId();
+ ProcessDefinition procDef = repoService.createProcessDefinitionQuery()
+ .processDefinitionId(execution.getProcessDefinitionId())
+ .uniqueResult();
- RepositoryService repoService = processEngine.getRepositoryService();
- ProcessDefinitionQuery query = repoService.createProcessDefinitionQuery();
- query.processDefinitionId(processId);
- ProcessDefinition procDef = query.uniqueResult();
+ // check if a template exists
+ String name = task.getFormResourceName();
+ InputStream template = repoService.getResourceAsStream(procDef.getDeploymentId(), name);
- // check if a template exists
- String name = task.getFormResourceName();
- InputStream template = repoService.getResourceAsStream(
- procDef.getDeploymentId(), name
- );
+ // merge template with process variables
+ if (template == null)
+ throw new IllegalArgumentException("Task form resource '" + name + "' doesn't exist.");
- // merge template with process variables
- if(template==null)
- throw new IllegalArgumentException("Task form resource '"+name+"' doesn't exist.");
+ Map<String, Object> processContext = new HashMap<String, Object>();
+ ExecutionService execService = processEngine.getExecutionService();
+ Set<String> varNames = execService.getVariableNames(procInstId);
- Map<String, Object> processContext = new HashMap<String, Object>(); // empty default
- ExecutionService execService = processEngine.getExecutionService();
- Set<String> varNames = execService.getVariableNames(processInstanceId);
+ if (varNames != null)
+ processContext = execService.getVariables(procInstId, varNames);
- if(varNames!=null)
- processContext = execService.getVariables(processInstanceId, varNames);
+ // plugin context
+ StringBuilder action = getBaseUrl();
+ action.append("/form/task/");
+ action.append(ref.getReferenceId());
+ action.append("/complete");
- // plugin context
- StringBuilder action = getBaseUrl();
- action.append("/form/task/");
- action.append( ref.getReferenceId() );
- action.append("/complete");
+ Map<String, Object> renderContext = new HashMap<String, Object>();
- Map<String, Object> renderContext = new HashMap<String,Object>();
+ // form directive
+ FormDirective formDirective = new FormDirective();
+ formDirective.setAction(action.toString());
+ renderContext.put(FORM_DIRECTIVE_KEY, formDirective);
- // form directive
- FormDirective formDirective = new FormDirective();
- formDirective.setAction( action.toString() );
- renderContext.put(FORM_DIRECTIVE_KEY, formDirective);
+ // outcome directive
+ OutcomeDirective outcomeDirective = new OutcomeDirective();
+ Set<String> outcomes = taskService.getOutcomes(task.getId());
+ for (String outcome : outcomes) {
+ outcomeDirective.getValues().add(outcome);
+ }
+ renderContext.put(OUTCOME_DIRECTIVE_NAME, outcomeDirective);
- // outcome directive
- // TODO: Fix when https://jira.jboss.org/jira/browse/JBPM-2220 is done
- OutcomeDirective outcomeDirective = new OutcomeDirective();
- List<Transition> transitions =
- ((ExecutionImpl) processInstance).getActivity().getOutgoingTransitions();
- for(Transition t : transitions)
- {
- String outcomeName = t.getName()!=null ? t.getName() : "to_"+t.getDestination().getName();
- outcomeDirective.getValues().add(outcomeName);
- }
- renderContext.put(OUTCOME_DIRECTIVE_NAME, outcomeDirective);
+ // process variables
+ renderContext.putAll(processContext);
- // process variables
- renderContext.putAll(processContext);
-
- DataHandler result = processTemplate(name, template, renderContext);
- return result;
- }
- finally
- {
- env.close();
- }
+ DataHandler result = processTemplate(name, template, renderContext);
+ return result;
}
}
Modified: jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -24,10 +24,11 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.List;
-import java.util.ArrayList;
-import java.net.URL;
import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
import javax.naming.InitialContext;
@@ -35,46 +36,47 @@
import org.jboss.bpm.console.client.model.DiagramInfo;
import org.jboss.bpm.console.client.model.DiagramNodeInfo;
import org.jboss.bpm.console.server.plugin.GraphViewerPlugin;
-import org.jbpm.api.ExecutionService;
+import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.ProcessInstanceQuery;
+import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.model.ActivityCoordinates;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.integration.spi.mgmt.ServerConfig;
import org.jbpm.integration.spi.mgmt.ServerConfigFactory;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class GraphViewerPluginImpl implements GraphViewerPlugin
-{
+public class GraphViewerPluginImpl implements GraphViewerPlugin {
protected final static String WEB_CONTEXT = "/gwt-console-server/rs";
protected ProcessEngine processEngine;
- protected ServerConfig serverConfig = null; // lazy
+ protected ServerConfig serverConfig = null; // lazy
-
- public GraphViewerPluginImpl()
- {
+ public GraphViewerPluginImpl() {
initializeProcessEngine();
}
- protected ServerConfig getServerConfig()
- {
- if(null==serverConfig)
- {
+ protected void initializeProcessEngine() {
+ try {
+ InitialContext ctx = new InitialContext();
+ this.processEngine = (ProcessEngine) ctx.lookup("java:/ProcessEngine");
+ } catch (Exception e) {
+ // Fall back to default mechanism
+ this.processEngine = Configuration.getProcessEngine();
+ }
+ }
+
+ protected ServerConfig getServerConfig() {
+ if (null == serverConfig) {
serverConfig = ServerConfigFactory.getServerConfig();
}
return serverConfig;
}
- protected StringBuilder getBaseUrl()
- {
+ protected StringBuilder getBaseUrl() {
StringBuilder spec = new StringBuilder();
spec.append("http://");
spec.append(getServerConfig().getWebServiceHost());
@@ -83,171 +85,90 @@
return spec;
}
- public byte[] getProcessImage(String processId)
- {
+ public byte[] getProcessImage(String processId) {
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processId).uniqueResult();
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ String imgRes = processDefinition.getImageResourceName();
+ InputStream in = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), imgRes);
- try
- {
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
- .processDefinitionId(processId)
- .uniqueResult();
+ if (null == in)
+ throw new RuntimeException("Failed to retrieve image resource: " + imgRes);
- String imgRes = processDefinition.getImageResourceName();
- InputStream in = repositoryService.getResourceAsStream(
- processDefinition.getDeploymentId(), imgRes
- );
-
- if(null==in)
- throw new RuntimeException("Failed to retrieve image resource: " +imgRes);
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- final int BUF_SIZE = 1 << 8; //1KiB buffer
- byte[] buffer = new byte[BUF_SIZE];
- int bytesRead = -1;
- try
- {
- while((bytesRead = in.read(buffer)) > -1)
- {
- out.write(buffer, 0, bytesRead);
- }
- in.close();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final int BUF_SIZE = 1 << 8; // 1KiB buffer
+ byte[] buffer = new byte[BUF_SIZE];
+ int bytesRead = -1;
+ try {
+ while ((bytesRead = in.read(buffer)) > -1) {
+ out.write(buffer, 0, bytesRead);
}
- catch (IOException e)
- {
- throw new RuntimeException("Failed to read image resource: "+imgRes, e);
- }
+ in.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read image resource: " + imgRes, e);
+ }
- byte[] imageBytes = out.toByteArray();
+ byte[] imageBytes = out.toByteArray();
- return imageBytes;
-
- }
- finally{
- env.close();
- }
+ return imageBytes;
}
- public DiagramInfo getDiagramInfo(String processId)
- {
+ public DiagramInfo getDiagramInfo(String processId) {
throw new RuntimeException("Not implemented");
}
- public List<ActiveNodeInfo> getActiveNodeInfo(String instanceId)
- {
-
+ public List<ActiveNodeInfo> getActiveNodeInfo(String processInstanceId) {
List<ActiveNodeInfo> results = new ArrayList<ActiveNodeInfo>();
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
+ ProcessInstance pi = processEngine.getExecutionService().findProcessInstanceById(processInstanceId);
+ Set<String> currentActivities = pi.findActiveActivityNames();
- try
- {
- ExecutionService execService = this.processEngine.getExecutionService();
- ProcessInstanceQuery query = execService.createProcessInstanceQuery();
- query.processInstanceId(instanceId);
- ExecutionImpl processInstance = (ExecutionImpl) query.uniqueResult();
-
- String currentActivity = processInstance.getProcessInstance().getActivityName();
-
- // get coordinates
- RepositoryService repoService = this.processEngine.getRepositoryService();
- ActivityCoordinates coords = repoService.getActivityCoordinates(
- processInstance.getProcessDefinitionId(), currentActivity
- );
-
-
- results.add(new ActiveNodeInfo(
- coords.getWidth(), coords.getHeight(),
- new DiagramNodeInfo(
- currentActivity,
- coords.getX(), coords.getY(),
- coords.getWidth(), coords.getHeight()
- )
- )
- );
-
+ RepositoryService repoService = this.processEngine.getRepositoryService();
+ for (String activityName : currentActivities) {
+ ActivityCoordinates coords = repoService.getActivityCoordinates(pi.getProcessDefinitionId(), activityName);
+ results.add(new ActiveNodeInfo(coords.getWidth(), coords.getHeight(),
+ new DiagramNodeInfo(activityName, coords.getX(),
+ coords.getY(), coords.getWidth(), coords.getHeight())));
}
- finally
- {
- env.close();
- }
return results;
}
- protected void initializeProcessEngine()
- {
- try
- {
- InitialContext ctx = new InitialContext();
- this.processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to lookup process engine", e);
- }
- }
-
- public URL getDiagramURL(String id)
- {
+ public URL getDiagramURL(String id) {
URL result = null;
// check resource availability
- EnvironmentImpl env = ((EnvironmentFactory)processEngine).openEnvironment();
boolean hasImageResource = false;
+ RepositoryService repositoryService = this.processEngine.getRepositoryService();
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).uniqueResult();
- try
- {
- RepositoryService repositoryService = this.processEngine.getRepositoryService();
- ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
- .processDefinitionId(id)
- .uniqueResult();
+ InputStream inputStream = null;
+ if (processDefinition != null) {
+ String imgRes = processDefinition.getImageResourceName();
+ inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), imgRes);
+ }
- InputStream inputStream = null;
- if(processDefinition!=null)//TODO: JBPM-2383 Suspended definitions don't show up here
- {
- String imgRes = processDefinition.getImageResourceName();
- inputStream = repositoryService.getResourceAsStream(
- processDefinition.getDeploymentId(), imgRes
- );
+ if (inputStream != null) {
+ hasImageResource = true;
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to close stream", e);
}
-
- if(inputStream!=null)
- {
- hasImageResource = true;
- try
- {
- inputStream.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("Failed to close stream", e);
- }
- }
-
}
- finally{
- env.close();
- }
- if(hasImageResource)
- {
+ if (hasImageResource) {
StringBuilder sb = getBaseUrl().append("/process/definition/");
sb.append(id);
sb.append("/image");
- try
- {
+ try {
result = new URL(sb.toString());
- }
- catch (MalformedURLException e)
- {
+ } catch (MalformedURLException e) {
throw new RuntimeException("Failed to create url", e);
}
}
-
+
return result;
}
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartHsqldbServerTask.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartHsqldbServerTask.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartHsqldbServerTask.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+
+/**
+ * @author jbarrez
+ */
+public class StartHsqldbServerTask extends Task {
+
+ private static final String END_MESSAGE = "use [Ctrl]+[C] to abort abruptly";
+
+ String configuration = null;
+ String hsqldbServerHome = null;
+
+ public void execute() throws BuildException {
+ try {
+ // get some environment variableInstances
+ String fileSeparator = System.getProperty( "file.separator" );
+ String os = getProject().getProperty( "os.name" ).toLowerCase();
+
+ // build the command string
+ String[] command = null;
+ if ( os.indexOf( "windows" ) != -1 ) {
+ command = new String[] {getHsqldbServerHome() + fileSeparator + "start-hsqldb-server.bat"};
+ } else if ( os.indexOf( "linux" ) != -1 || os.indexOf( "mac" ) != -1) {
+ command = new String[] {getHsqldbServerHome() + fileSeparator + "start-hsqldb-server.sh"};
+ } else {
+ throw new BuildException( "os '" + os + "' not supported in the start-hsqldb-server task." );
+ }
+
+ // launch the command and wait till the END_MESSAGE appears
+ Thread launcher = new Launcher(this, command, END_MESSAGE, getHsqldbServerHome());
+ launcher.start();
+ launcher.join();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getHsqldbServerHome() {
+ return hsqldbServerHome;
+ }
+
+ public void setHsqldbServerHome(String hsqldbServerHome) {
+ this.hsqldbServerHome = hsqldbServerHome;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartHsqldbServerTask.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetDeploymentResourceNamesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetDeploymentResourceNamesCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetDeploymentResourceNamesCmd.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Set;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.session.RepositorySession;
+
+/**
+ * Command used to retrieve all the resource names of a deployment. The
+ * resources itself can be retrieved using other commands (eg
+ * {@link GetResourceAsStreamCmd}).
+ *
+ * @author jbarrez
+ */
+public class GetDeploymentResourceNamesCmd implements Command<Set<String>> {
+
+ private static final long serialVersionUID = 1L;
+
+ private String deploymentId;
+
+ public GetDeploymentResourceNamesCmd(String deploymentId) {
+ this.deploymentId = deploymentId;
+ }
+
+ public Set<String> execute(Environment environment) throws Exception {
+ RepositorySession repositorySession = environment.get(RepositorySession.class);
+ DeploymentImpl depImpl = repositorySession.getDeployment(deploymentId);
+ return depImpl.getResourceNames();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetDeploymentResourceNamesCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -24,6 +24,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
+import java.util.Set;
import org.jbpm.api.DeploymentQuery;
import org.jbpm.api.NewDeployment;
@@ -35,6 +36,7 @@
import org.jbpm.pvm.internal.cmd.CreateProcessDefinitionQueryCmd;
import org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd;
import org.jbpm.pvm.internal.cmd.GetActivityCoordinatesCmd;
+import org.jbpm.pvm.internal.cmd.GetDeploymentResourceNamesCmd;
import org.jbpm.pvm.internal.cmd.GetResourceAsStreamCmd;
import org.jbpm.pvm.internal.cmd.GetStartActivityNamesCmd;
import org.jbpm.pvm.internal.cmd.GetStartFormResourceNameCmd;
@@ -69,6 +71,10 @@
public void deleteDeploymentCascade(String deploymentId) {
commandService.execute(new DeleteDeploymentCmd(deploymentId, true));
}
+
+ public Set<String> getResourceNames(String deploymentId) {
+ return commandService.execute(new GetDeploymentResourceNamesCmd(deploymentId));
+ }
public InputStream getResourceAsStream(String deploymentId, String resource) {
byte[] bytes = commandService.execute(new GetResourceAsStreamCmd(deploymentId, resource));
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-08-26 02:56:14 UTC (rev 5538)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-08-26 09:11:53 UTC (rev 5539)
@@ -152,9 +152,6 @@
} else {
validateRepositoryCache();
}
-
- // if null -> invalidate cache?
- System.out.println("---------------->" + repositoryCache.get("1", "test_process"));
return null;
}
@@ -170,9 +167,6 @@
} else {
validateRepositoryCache();
}
-
- // ? if null -> delete from cache?
- System.out.println("---------------->" + repositoryCache.get("1", "test_process"));
return null;
}
More information about the jbpm-commits
mailing list