Tijs,
using ServiceTasks basically works.
But I have problems with custom data types which are required in our enterprise scenario.
This is my process:
<process id='businessProcess' name='Business process'>
<startEvent id='start' />
<sequenceFlow id='flow1' sourceRef='start' targetRef='serviceTask1'/>
<serviceTask id='serviceTask1' activiti:delegateExpression='${taskBean1}'/>
<sequenceFlow id='flow2' sourceRef='serviceTask1' targetRef='serviceTask2'/>
<serviceTask id='serviceTask2' activiti:delegateExpression='${taskBean2}'/>
<sequenceFlow id='flow3' sourceRef='serviceTask2' targetRef='end'/>
<endEvent id='end'/>
</process>
In taskbean1 I create a custom object like this:
public void execute(ActivityExecution execution) throws Exception {
Customer customer = new Customer();
customer.setName("Max");
execution.setVariable("customer", customer);
}
In taskbean 2 I try to read the custom object like this:
public void execute(ActivityExecution execution) throws Exception {
Customer customer = (Customer) execution.getVariable("customer");
System.out.println("Customer name is " + customer.getName());
}
The taskbeans reside in a task bundle as shown in your Example.
When I run this process I get an exception from Activiti saying that the Customer object is unknown.
org.activiti.engine.ActivitiException: couldn't find type for org.mytypes.Customer@c6d2a0
at org.activiti.engine.impl.variable.DefaultVariableTypes.findVariableType(DefaultVariableTypes.java:62)
at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.createVariableLocal(VariableScopeImpl.java:212)
at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.setVariable(VariableScopeImpl.java:164)
at net.pleus.sbp.process.code.JavaTask.execute(JavaTask.java:14)
Actually that is what I expected, cause the Customer type is only visible in the bundle containing the tasks not in the Activiti bundle.
A solution would be to use only standard types (int, string, etc.). But this would be a great limitation as typical enterprise applications need to use custom complex datatypes.
Another option might be to add a dynamic import to the Activiti-OSGi-bundle.
What do you think? What would be the best way to go?