[jbpm-commits] JBoss JBPM SVN: r5662 - in projects/jopr-integration/trunk/src/main: java/org/rhq/plugins/jbpm4/connector and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Sep 20 23:07:51 EDT 2009


Author: jim.ma
Date: 2009-09-20 23:07:50 -0400 (Sun, 20 Sep 2009)
New Revision: 5662

Modified:
   projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java
   projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java
   projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java
   projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml
Log:
Added startProcessInstance operation and refactored the RemoteJBPMEngineConnector

Modified: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java	2009-09-18 15:39:33 UTC (rev 5661)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java	2009-09-21 03:07:50 UTC (rev 5662)
@@ -66,6 +66,7 @@
         List<URL> clientJars = new ArrayList<URL>();
         //TODO:Review it and removed the jars not needed
         String[] jarFileNames = { "lib/jbpm.jar",
+        		                  "./../../common/lib/hibernate-core.jar",
                                   "deploy/jbpm/jbpm-service.sar/freemarker.jar",
                                   "deploy/jbpm/jbpm-service.sar/juel.jar",
                                   "deploy/jbpm/jbpm-service.sar/juel-engine.jar",

Modified: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java	2009-09-18 15:39:33 UTC (rev 5661)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java	2009-09-21 03:07:50 UTC (rev 5662)
@@ -214,9 +214,8 @@
 	
 	public Job executeJob(String jobDbid) {
 		 //These will cause jbpm4.1 class not fund org.jbpm.pvm.internal.cmd.Command execption
-		 /*CommandService commandService = processEngine.get(CommandService.class);
-		 return commandService.execute(new ExecuteJobCmd(jobDbid));*/
-		 return null;
+		 CommandService commandService = processEngine.get(CommandService.class);
+		 return commandService.execute(new ExecuteJobCmd(jobDbid));
 	}
 	
   	public List<HistoryProcessInstance> getHistoryProcessInstances(String definitionId, String processInstanceId, String state, Page page) {

Modified: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java	2009-09-18 15:39:33 UTC (rev 5661)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java	2009-09-21 03:07:50 UTC (rev 5662)
@@ -61,6 +61,7 @@
 import org.jbpm.pvm.internal.cmd.StartProcessInstanceCmd;
 import org.jbpm.pvm.internal.cmd.SuspendDeploymentCmd;
 import org.jbpm.pvm.internal.query.AvgDurationPerActivityQueryCmd;
+import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
 import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
 import org.jbpm.pvm.internal.query.HistoryTaskQueryImpl;
 import org.jbpm.pvm.internal.query.JobQueryImpl;
@@ -91,7 +92,7 @@
 	private String providerURL;
 	private String principal;
 	private String credentials;
-	private RemoteCommandExecutor remoteCommandExecutor = null;
+	private static RemoteCommandExecutor remoteCommandExecutor = null;
 
 	public RemoteJBPMEngineConnector(String providerURL, String principal, String credentials) {
 		this.providerURL = providerURL;
@@ -99,14 +100,15 @@
 		this.credentials = credentials;
 	}
 
-	public JBPMEngineConnection connect() {
-		try {
-			remoteCommandExecutor = this.retrieveCommandExecutor();
-			return this;
-		} catch (Exception e) {
-			log.error("Failed to retrieve CommandExecutor");
-		}
-		return null;
+	public synchronized JBPMEngineConnection connect() {
+		if (remoteCommandExecutor == null) {
+			try {
+				remoteCommandExecutor = this.retrieveCommandExecutor();
+			} catch (Exception e) {
+				log.error("Failed to retrieve CommandExecutor");
+			}
+		} 
+		return this;
 	}
 
 	public void disconnect() {
@@ -143,16 +145,20 @@
 	}
 
 	public List<Deployment> getDeployments() {
-		CreateDeploymentQueryCmd queryCmd = new CreateDeploymentQueryCmd();
-		DeploymentQuery deploymentQuery = execute(queryCmd);
-		return deploymentQuery.list();
+		DeploymentQueryImpl queryImpl = new DeploymentQueryImpl();
+		List<Deployment> deployments = (List<Deployment>)execute(queryImpl);
+		return deployments;
 
 	}
 
 	public Deployment getDeployment(String deploymentId) {
-		CreateDeploymentQueryCmd queryCmd = new CreateDeploymentQueryCmd();
-		DeploymentQuery deploymentQuery = execute(queryCmd);
-		return (Deployment) deploymentQuery.deploymentDbid(Long.valueOf(deploymentId)).uniqueResult();
+		DeploymentQueryImpl queryImpl = new DeploymentQueryImpl();
+		queryImpl.deploymentDbid(Long.valueOf(deploymentId));
+		List<Deployment> deployments = (List<Deployment>)execute(queryImpl);
+		if (deployments.size() > 0) {
+			return deployments.get(0);
+		}
+		return null;
 
 	}
 
@@ -179,27 +185,26 @@
 
 	// definition api
 	public List<ProcessDefinition> getProcessDefs() {
-		CreateProcessDefinitionQueryCmd queryCmd = new CreateProcessDefinitionQueryCmd();
+		ProcessDefinitionQueryImpl queryImpl = new ProcessDefinitionQueryImpl();
+		List<ProcessDefinition> definitions = (List<ProcessDefinition>)execute(queryImpl);
+		return definitions;
 
-		ProcessDefinitionQueryImpl queryIml = (ProcessDefinitionQueryImpl) execute(queryCmd);
-		return queryIml.list();
-
 	}
 
 	public ProcessDefinition getProcessDefById(String id) {
-		CreateProcessDefinitionQueryCmd queryCmd = new CreateProcessDefinitionQueryCmd();
+		ProcessDefinitionQueryImpl queryImpl = new ProcessDefinitionQueryImpl();
+		queryImpl.processDefinitionId(id);
+		List<ProcessDefinition> definitions = (List<ProcessDefinition>)execute(queryImpl);
+		if (definitions.size() > 0) {
+			return definitions.get(0);
+		}
+		return null;
 
-		ProcessDefinitionQueryImpl queryIpml = (ProcessDefinitionQueryImpl) execute(queryCmd);
-		queryIpml.processDefinitionId(id);
-		return queryIpml.uniqueResult();
-
 	}
 
 	// process instance api
 	public List<ProcessInstance> getProcessInstances(String defId, String processInstanceId, String state, Page page) {
-		CreateProcessInstanceQueryCmd queryCmd = new CreateProcessInstanceQueryCmd();
-
-		ProcessInstanceQueryImpl query = (ProcessInstanceQueryImpl) execute(queryCmd);
+		ProcessInstanceQueryImpl query = new ProcessInstanceQueryImpl();
 		if (defId != null) {
 			query.processDefinitionId(defId);
 		}
@@ -217,9 +222,9 @@
 		if (page != null) {
 			query.page(page.firstResult, page.maxResults);
 		}
+		List<ProcessInstance> definitions = (List<ProcessInstance>)execute(query);
+		return definitions;
 
-		return query.list();
-
 	}
 
 	public void deleteProcessInstance(String instanceId) {
@@ -232,15 +237,13 @@
 	public ProcessInstance startProcessInstance(String defId) {
 		StartProcessInstanceCmd startCmd = new StartProcessInstanceCmd(defId, null, null);
 
-		return (ProcessInstance)execute(startCmd);
+		return (ProcessInstance) execute(startCmd);
 
 	}
 
 	// Job api
 	public List<Job> queryJob(boolean timerOnly, boolean messageOnly, boolean exception, String processInstanceId) {
-		CreateJobQueryCmd queryCmd = new CreateJobQueryCmd();
-
-		JobQuery jobQuery = (JobQuery) execute(queryCmd);
+		JobQueryImpl jobQuery = new JobQueryImpl();
 		if (processInstanceId != null) {
 			jobQuery.processInstanceId(processInstanceId);
 		}
@@ -250,21 +253,18 @@
 		}
 
 		if (timerOnly) {
-			jobQuery = jobQuery.timers();
+			jobQuery.timers();
 		} else if (messageOnly) {
-			jobQuery = jobQuery.messages();
+			jobQuery.messages();
 		}
-		return jobQuery.list();
+		List<Job> jobs = (List<Job>)execute(jobQuery);
+		return jobs;
 
 	}
 
 	public Job getJob(String jobId) {
-		CreateJobQueryCmd queryCmd = new CreateJobQueryCmd();
-
-		JobQuery jobQuery = (JobQuery) execute(queryCmd);
-
-		List<Job> jobs = jobQuery.list();
-
+		JobQueryImpl jobQuery = new JobQueryImpl();
+		List<Job> jobs = (List<Job>)execute(jobQuery);
 		for (Job job : jobs) {
 			if (job.getId().equals(jobId)) {
 				return job;
@@ -284,7 +284,6 @@
 	// Activity api
 	public Map<String, Long> avgDurationPerActivity(String processDefinitionId) {
 		AvgDurationPerActivityQueryCmd command = new AvgDurationPerActivityQueryCmd(processDefinitionId);
-
 		return (Map<String, Long>) execute(command);
 
 	}
@@ -292,9 +291,8 @@
 	// History process instance api
 	public List<HistoryProcessInstance> getHistoryProcessInstances(String definitionId, String processInstanceId,
 			String state, Page page) {
-		CreateHistoryProcessInstanceQueryCmd command = new CreateHistoryProcessInstanceQueryCmd();
 
-		HistoryProcessInstanceQueryImpl historyQuery = (HistoryProcessInstanceQueryImpl) execute(command);
+		HistoryProcessInstanceQueryImpl historyQuery =  new HistoryProcessInstanceQueryImpl();
 		if (definitionId != null) {
 			historyQuery.processDefinitionId(definitionId);
 		}
@@ -309,15 +307,14 @@
 		if (page != null) {
 			historyQuery.page(page.firstResult, page.maxResults);
 		}
-		return historyQuery.list();
+		List<HistoryProcessInstance> instances = (List<HistoryProcessInstance>)execute(historyQuery);
+		return instances;
 
 	}
 
 	// Task api
 	public List<Task> getTasks(String definitionId, String processInstanceId) {
-		CreateTaskQueryCmd command = new CreateTaskQueryCmd();
-
-		TaskQueryImpl taskQuery = (TaskQueryImpl) execute(command);
+		TaskQueryImpl taskQuery = new TaskQueryImpl();
 		if (definitionId != null) {
 			taskQuery.processDefinitionId(definitionId);
 		}
@@ -325,15 +322,14 @@
 		if (processInstanceId != null) {
 			taskQuery.processInstanceId(processInstanceId);
 		}
+		List<Task> tasks = (List<Task>)execute(taskQuery);
+		return tasks;
 
-		return taskQuery.list();
-
 	}
 
 	public List<Task> getTasks(TaskQueryCondition condition) {
-		CreateTaskQueryCmd command = new CreateTaskQueryCmd();
-
-		TaskQueryImpl taskQuery = (TaskQueryImpl) execute(command);
+	
+		TaskQueryImpl taskQuery = new TaskQueryImpl();
 		if (condition.getActivityName() != null) {
 			taskQuery.activityName(condition.getActivityName());
 		}
@@ -363,16 +359,14 @@
 		if (condition.getPage() != null) {
 			taskQuery.page(condition.getPage().firstResult, condition.getPage().maxResults);
 		}
+		List<Task> tasks = (List<Task>)execute(taskQuery);
+		return tasks;
 
-		return taskQuery.list();
-
 	}
 
 	// History task api
 	public List<HistoryTask> getHIstoryTasks(TaskHistoryQueryCondition condition) {
-		CreateHistoryTaskQueryCmd command = new CreateHistoryTaskQueryCmd();
-
-		HistoryTaskQueryImpl historyTaskQuery = (HistoryTaskQueryImpl) execute(command);
+		HistoryTaskQueryImpl historyTaskQuery = new HistoryTaskQueryImpl();
 		if (condition.getTaskId() != null) {
 			historyTaskQuery.taskId(condition.getTaskId());
 		}
@@ -405,7 +399,7 @@
 			historyTaskQuery.tookLongerThen(condition.getTookLongerThen());
 		}
 
-		List<HistoryTask> historyTasks = historyTaskQuery.list();
+		List<HistoryTask> historyTasks = (List<HistoryTask>)execute(historyTaskQuery);
 		// TODO: ask jbpm team to add select historyTasks by process
 		// instance id
 		if (condition.getDefinitionId() != null) {

Modified: projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml	2009-09-18 15:39:33 UTC (rev 5661)
+++ projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml	2009-09-21 03:07:50 UTC (rev 5662)
@@ -146,6 +146,16 @@
                         </c:list-property>
                 </results>
              </operation>
+             
+             <operation name="createProcessInstance" displayName="startProcessInstance"
+                        description="start a new process instance">
+                <results>
+                    <c:simple-property  name="operationResult" readOnly="true" description="Start process instance result"/>
+                </results>
+             </operation>
+             
+             
+             
             <operation name="processInstanceSelector" displayName="processInstanceSelector"
                         description="Lists the process instance for the given condition">
                 <parameters>



More information about the jbpm-commits mailing list