Model API in custom BpmnParseListener

Hello again. We have registered some custom element types for our custom extension elements.

We also have a custom BpmnParseListener, but the API for there is not using the model API, so I cannot access BPMN elements in a strongly typed way (similar to this question here)

I see the answer is to use the repository service in the listener, but how can I get it? I have to construct the listener before the process engine is created when I’m setting up the configuration, and therefore do not have a reference to it.

Is there any other way to get it? I should also note that we are not using spring.


Hi @coopstah13,

I think, that using the repository service in the listener will not solve your problem, since you are currently in progress of deploying that process. As a consequence, you will not be able to retrieve that process from the repository service.

But you are still able to retrieve your custom elements by using the internal representation of the xml, for example like this

public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
  Element extentionsElement = userTaskElement.element("extensionElements");
  if (extentionsElement != null) {
    List<Element> customElements = extentionsElement.elementsNS(<your-custom-namespace>, <custom-element>);
    // do something...

What kind of custom extension elements do you have? What do you want to do with them?


Yes I’m aware I can do it this way, but it is a bit of duplicated effort. Also I cannot access them in a type-safe manner and have to instead rely on traversing the DOM using element names which I would have to then expose from my element implementation classes. I figured getting the repository service wouldn’t actually work, but I wanted to ask since that was actually suggested to someone a while back. It is too bad, because the CMMN APIs allow for operating on the model instance and not the XML representation.

We have custom elements that we use in our custom activity behavior classes, inside of those I can get access to them in a type-safe way using the element query API on the model instance. I guess I will just have to stick with that.