[jboss-user] [jBPM] - jBPM 4 - Deploy only if ProcessDefinition changed or new
Andrea Castangelo
do-not-reply at jboss.com
Mon Nov 8 06:20:56 EST 2010
rapa [http://community.jboss.org/people/rapa] created the discussion
"jBPM 4 - Deploy only if ProcessDefinition changed or new"
To view the discussion, visit: http://community.jboss.org/message/570056#570056
--------------------------------------------------------------
Hi,
I successfully integrated jBPM 4.4 with Seam 2.2, running on JBoss 4.2.
In my overridden Jbpm class I deploy all process definitions, which are got from the components.xml
<bpm:jbpm>
<bpm:process-definitions>
<value>bpm/processdefinitions/process_1.jpdl.xml</value>
<value>bpm/processdefinitions/process_2.jpdl.xml</value>
<value>bpm/processdefinitions/process_3.jpdl.xml</value> </bpm:process-definitions>
</bpm:jbpm>
<bpm:jbpm>
<bpm:process-definitions>
<value>bpm/processdefinitions/partner_registration.jpdl.xml</value>
</bpm:process-definitions>
</bpm:jbpm>
The process definitions file paths (resource names) are automatically injected in the String[] processDefinitions array (see Jbpm class)
By having all file paths it is easy to deploy the process definitions through the repository service, but I would like to avoid to deploy them each time
I restart my application server.
What I would like to do is to deploy my process definitions only if the xml file is new or has been modified since it's last deployment. The idea is simple: I just compare the last deployed process definition's xml content with the one of the current process definition.
There is a method in the repository service that allows to get the deployed process definition's xml content
repositoryService.getResourceAsStream(deploymentId, resourceName);
I see that the jbpm4_lob table is the one that contains all the required data (resource_names, deployment_ids, xml files contents), so there must be
a way to retrieve what I need.
The problem is that I looked into the jbpm 4.4 api and I don't see any way to retrieve the highest deploymentId for a given resource name. The only way is to use the process definition key or name, but I would have to map these manually somewhere to their resource name or parse the xml files, which would be very nasty and I absolutely want to avoid that.
Here is the code of my Jbpm class.
@Name("jbpm")
@Scope(ScopeType.APPLICATION)
@AutoCreate
@Startup
@BypassInterceptors
@Install(precedence = Install.APPLICATION)
public class Jbpm extends SeamComponent {
@Getter
private ProcessEngine processEngine;
@Getter @Setter
private String[] processDefinitions;
@Create
public void init() {
// ...
deployProcessDefinitions();
// ...
}
/**
* Deploys all changed or new process definitions.
*/
private void deployProcessDefinitions() {
RepositoryService repositoryService = this.processEngine.getRepositoryService();
for (String processDefinition : this.processDefinitions) {
// deploy d only if new or it has changed
if(isNewOrChanged(processDefinition)) {
NewDeployment d = repositoryService.createDeployment()
.addResourceFromClasspath(processDefinition);
String newDeploymentId = d.deploy();
}
}
private String isNewOrChanged(processDefinition) {
// how to get deploymentId???
InputStream is = repositoryService.getResourceAsStream(deploymentId, processDefinition);
String xml = convertStreamToString(is);
// ...
}
Anyone has a solution for this?
Thanks, cheers!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/570056#570056]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101108/f0881f10/attachment.html
More information about the jboss-user
mailing list