customTaskInstance
This example shows how to extend the TaskInstance by adding a custom property.
To create this example in Eclipse, you should first have created a project for jbpm.3 in your workspace. Use the New -> Java Project and uncheck Use Default Location and browse to the jbpm-jpdl-{version}/examples/customTaskInstance directory and give it the project name customTaskInstance. Go to the customTaskInstance project Build Path Source tab add folders customTaskInstance/src/config, customTaskInstance/src/identity and customTaskInstance/src/jpdl Projects Tab to add jbpm.3. Use the Libraries tab and add hibernat3.jar and junti.jar from jbpm.3 lib directory. This should result in a clean compilation (no errors).
This example consists of the following files:
src/main/java/CustomTaskControllerHandler.java - extracts information from the process context and initializes the task instance variables. In this example this is the variable "customId".
src/main/java/CustomTaskInstance.java - extends TaskInstance and adds the property customId, along with its getters and setters.
src/main/java/CustomTaskInstanceFactoryImpl.java - creates instances of CustomTaskInstance.
src/main/java/CustomTaskInstance.hbm.xml - defines the Hibernate mapping for CustomTaskInstance.
src/test/java/CustomTaskInstanceTest.java - JUnit test case for CustomTaskInstance example.
src/main/config/hibernate.xml - adds the CustomTaskInstance.hbm.xml file to the standard jBPM hibernate.xml file.
src/main/config/jbpm.cfg.xml - replaces the bean name="jbpm.task.instance.factory" property values with class="com.sample.taskinstance.CustomTaskInstanceFactoryImpl". CustomTaskInstanceTest.java adds this jbpm.cfg.xml file programatically.
src/main/jpdl/* - contains the processdefinition. Notice the assignment and the CustomTaskController specified on the task.
To run the example, run the CustomTaskInstanceTest.java as a JUnit test.