Extending Spring Modules to Include Processimage.jpg and gpd.xml Files

Extending ProcessDefinitionFactoryBean

Spring Modules provides ProcessDefinitionFactoryBean to integrate with jBPM through Spring.

ProcessDefinitionFactoryBean has a definitionLocation property which only allow the location of the processdefinition.xml file to be specified. Consequently, this factory bean only loads the ProcessDefinition object from the processdefintion.xml file specified.

It would be nice to display the status of the process flow by using the processimage.jpg and gpd.xml files generated by JBoss IDE and so ProcessDefinitionFactoryBean was inadequate. In order for the process definition to include the processimage.jpg and gpd.xml files, LocalProcessDefinitionFactoryBean was introduced.

LocalProcessDefinitionFactoryBean has a definitionDirectoryLocation property, which specifies the directory location of processdefinition.xml file.

If the processimage.jpg and gpd.xml exist in the directory specified, they will be loaded into the fileDefinition property of the process definition.

FileDefinition fileDefinition = (FileDefinition) getProcessDefinition().getDefinition(FileDefinition.class);

   if (fileDefinition == null) {
     fileDefinition = new FileDefinition();

   addFileResourceToFileDefinition(fileDefinition, processDefinitionDirectory.getPath(), PROCESSIMAGE_JPG);
   addFileResourceToFileDefinition(fileDefinition, processDefinitionDirectory.getPath(), GPD_XML);

private void addFileResourceToFileDefinition(FileDefinition fileDefinition, String processDefinitionDirectoryPath, String fileName) throws IOException {

   FileSystemResource processImageResource = new FileSystemResource(processDefinitionDirectoryPath + File.separator  + fileName);
   if (processImageResource.exist()) {
   InputStream inputStream = processImageResource.getInputStream();
      try {
         fileDefinition.addFile(fileName, inputStream);
      } finally {

The factory bean can then be used in the application context to load the process definition and injected into the jBPM configuration.

<bean id="someProcessDefinition" class="ca.intelliware.util.spring.modules.LocalProcessDefinitionFactoryBean">
   <property name="definitionDirectoryLocation"><value>classpath:processDefDirectory/</value></property>

<!-- helper for reading jBPM process definitions -->
<!-- jBPM configuration -->
<bean id="org.jbpm.JbpmConfiguration" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
   <property name="sessionFactory" ref="org.hibernate.SessionFactory"/>
   <property name="configuration" value="classpath:jbpm.cfg.xml"/>
   <property name="createSchema" value="false"/>
   <property name="processDefinitions">
       <ref bean="someProcessDefinition"/>

Once the process definition is loaded into the jBPM configuration, references to image and gpd.xml files are inserted in JBPM_BYTEARRAY table. Thereafter, the application can obtain these files from the fileDefintion.

FileDefinition fileDefinition = getProcessDefinition().getFileDefinition();
			gpdBytes = fileDefinition.getBytes("gpd.xml");
			imageBytes = fileDefinition.getBytes("processimage.jpg");

It's only fair to share...
Share on Facebook
Tweet about this on Twitter
Share on LinkedIn

1 thought on “Extending Spring Modules to Include Processimage.jpg and gpd.xml Files

  1. Pingback: jBPM and Spring | i-Proving –

Leave a Reply