AbstractBpmnParseHandler in version 6 Beta
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2015 02:32 PM
New to Activiti and was tasked with upgrading from 5.18 to 6.0. After pulling in the new jars, I noticed that AbstractBpmnParseHandler.findActivity(BpmnParse, UserTask) method no longer exists in the Abstract class. Without really understanding the codebase, I've been trying to find a way to reimplement the following code:
@Override
protected void executeParse(BpmnParse bpmnParse, UserTask element)
{
ActivityImpl activity = findActivity(element.getId()); // This method is the problem
ActivityBehavior behavior = activity.getActivityBehavior();
if (behavior instanceof UserTaskActivityBehavior)
{
addListeners((UserTaskActivityBehavior) behavior);
}
else if(behavior instanceof MultiInstanceActivityBehavior)
{
MultiInstanceActivityBehavior multiInstance = (MultiInstanceActivityBehavior) behavior;
behavior = multiInstance.getInnerActivityBehavior();
if(behavior instanceof UserTaskActivityBehavior)
{
addListeners((UserTaskActivityBehavior) behavior);
}
}
}
Thanks in advance for any help on this!
-Chad
@Override
protected void executeParse(BpmnParse bpmnParse, UserTask element)
{
ActivityImpl activity = findActivity(element.getId()); // This method is the problem
ActivityBehavior behavior = activity.getActivityBehavior();
if (behavior instanceof UserTaskActivityBehavior)
{
addListeners((UserTaskActivityBehavior) behavior);
}
else if(behavior instanceof MultiInstanceActivityBehavior)
{
MultiInstanceActivityBehavior multiInstance = (MultiInstanceActivityBehavior) behavior;
behavior = multiInstance.getInnerActivityBehavior();
if(behavior instanceof UserTaskActivityBehavior)
{
addListeners((UserTaskActivityBehavior) behavior);
}
}
}
Thanks in advance for any help on this!
-Chad
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2015 04:57 PM
The signature is wrong in the example above, I have findActivity(bpmnParse, element.getId());
But this is still a problem. I tried looking at method calls for the BpmnParse to get an ActivityImpl, and I saw an ActivityBehaviorFactory method, thinking I could get the ActivityBehavior directly from the BpmnParse, but was unsuccessful.
The body of the findActivity method is just
{
return bpmnParse.getCurrentScope().findActivity(id);
}
however, those methods do not seem to do exist for the bpmnParse object anymore either. I see getCurrentProcess() but that doesn't seem like the same thing.
But this is still a problem. I tried looking at method calls for the BpmnParse to get an ActivityImpl, and I saw an ActivityBehaviorFactory method, thinking I could get the ActivityBehavior directly from the BpmnParse, but was unsuccessful.
The body of the findActivity method is just
{
return bpmnParse.getCurrentScope().findActivity(id);
}
however, those methods do not seem to do exist for the bpmnParse object anymore either. I see getCurrentProcess() but that doesn't seem like the same thing.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 04:39 AM
Hi,
You should be able to listeners directly on the UserTask element instead of the old ActivityImpl object. We removed the whole ActivityImpl structure and are now using the BpmnModel objects like UserTask directly for execution.
Best regards,
You should be able to listeners directly on the UserTask element instead of the old ActivityImpl object. We removed the whole ActivityImpl structure and are now using the BpmnModel objects like UserTask directly for execution.
Best regards,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 09:51 AM
Thanks Tijs,
I do not see any related to adding a listener as a method of the UserTask. Can you tell me if I'm missing a step?
In my code, I would get the ActivityImpl, then the ActivityBehavior, then the TaskDefinition. I would then loop through each listener and add it to the TaskDefinition.
Are you saying I can skip all of that and add the listeners directly to the Usertask? Can you provide an example or explain to me how I can add those directly (Since I do not see it as a method)?
Thanks again!
I do not see any related to adding a listener as a method of the UserTask. Can you tell me if I'm missing a step?
In my code, I would get the ActivityImpl, then the ActivityBehavior, then the TaskDefinition. I would then loop through each listener and add it to the TaskDefinition.
Are you saying I can skip all of that and add the listeners directly to the Usertask? Can you provide an example or explain to me how I can add those directly (Since I do not see it as a method)?
Thanks again!

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 03:06 PM
Hi,
There is a setTaskListeners method in the UserTask class. You can create instances of ActivitiListener to define the listener.
Best regards,
There is a setTaskListeners method in the UserTask class. You can create instances of ActivitiListener to define the listener.
Best regards,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 03:49 PM
Thanks again Tijs - you've been a huge help so far.
One last obstacle… It seems that the setTaskListeners only takes an ActivitiListener, and I have an existing collection of TaskListeners. Without seeing the javadoc, I'm not sure what the differences are, only that they are not cross compatible. Is there an easy way to convert these objects, or will I need to figure out where the TaskListeners collection is created and switch it to ActivitiListener?
Snippet:
private List<TaskListener> taskListeners;
@Override
protected void executeParse(BpmnParse bpmnParse, UserTask userTask)
{
userTask.setTaskListeners(taskListeners);
}
One last obstacle… It seems that the setTaskListeners only takes an ActivitiListener, and I have an existing collection of TaskListeners. Without seeing the javadoc, I'm not sure what the differences are, only that they are not cross compatible. Is there an easy way to convert these objects, or will I need to figure out where the TaskListeners collection is created and switch it to ActivitiListener?
Snippet:
private List<TaskListener> taskListeners;
@Override
protected void executeParse(BpmnParse bpmnParse, UserTask userTask)
{
userTask.setTaskListeners(taskListeners);
}

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2015 02:58 PM
The ActivitListener is an abstract Object to represent the model for an execution and task listener in Activiti. So, on an Activiti listener you can define the class, expression and delegate expression text value in the implementation attribute. So in case you are using a Java class task listener you just set the implementation value to fully qualified class name.
Best regards,
Best regards,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2015 03:44 AM
Or, there is another way which is probably easier: the ActivitiListener has an 'instance' you can set. Put your TaskListener instance on it and it should work as before.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2015 10:19 AM
Perfect, thank you both. This seems to have solved the issue. Cheers!
