AnsweredAssumed Answered

Support for declaring DataObjects in BPMN XML with default values

Question asked by rhafner on Sep 19, 2013
Latest reply on Nov 8, 2013 by lsmall
This is a follow up regarding an earlier discussion that took place in the following thread and JIRA issue.

We are in the initial phases of evaluating the possibility of migrating our existing (non-bpmn) workflow engine to Activiti. One of the issues that we are running into is the lack of support for declaring DataObjects in the BPMN XML since our current engine provides supports for it. Based upon ACT-620 it appears there is no plan to add support to Activiti for this feature at this time. Leaving us with extending Activiti as the only option of to meet our requirements.

I spent some time evaluating what extensions are needed to support declared DataObjects in the Activiti engine. Here is a list of steps I came up with as well as a patch file.

1) New Constant for "dataObject" element (which would normally reside in org.activiti.bpmn.constants.BpmnXMLConstants).
2) New model class "DataObject" (which would normally reside in org.activiti.bpmn.model).
3) New Converter "DataObjectXmlConverter" (which would normally reside in org.activiti.bpmn.converter).
4) Add DataObjectXmlConverter to static initializer block in org.activiti.bpmn.converter.BpmnXMLConverter.
5) New ParseHandler: DataObjectParseHandler (which would normally reside in org.activiti.engine.impl.bpmn.parser.handler).
6) Add DataObjectParseHandler to the ProcessEngineConfiguration as a postBpmnParseHandler (which I have done via spring).

All of the items listed can be done without modifying the Activiti source code which is a big plus since we are hoping to consume activiti as a third party jar without modifying the source. However, step 4 does require us to extend the org.activiti.bpmn.converter.BpmnXMLConverter with a custom class so that we can access the static maps (convertersToBpmnMap,convertersToBpmnMap) to add the DataObjectXmlConverter. Not ideal but still workable. For example:

public class BpmnXMLConverter extends org.activiti.bpmn.converter.BpmnXMLConverter {
   public BpmnXMLConverter() {
      addConverter(DataObjectXmlConverter.getXMLType(), DataObjectXmlConverter.getBpmnElementType(), DataObjectXmlConverter.class);
   public void addConverter(String elementName, Class<? extends BaseElement> elementClass,  Class<? extends BaseBpmnXMLConverter> converter) {         
      convertersToBpmnMap.put(elementName, converter);
      convertersToXMLMap.put(elementClass, converter);

Some questions:
1) Is this the best approach to add support for declared DataObjects in the engine?
2) Should the addConverter method in org.activiti.bpmn.converter.BpmnXMLConverter class be declared public instead of private so that new converters can be added from outside the BpmnXMLConverter without having to extend the class?
3) Does it make sense to consider adding the classes in the patch file to the Activiti codebase so that extending Activiti to support declared DataObjects in the BPMN XML is done in a standardized way going forward?