cancel
Showing results for 
Search instead for 
Did you mean: 

Custom BpmnParseHandler to modify expressions

jsalmon
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to find a way of modifying certain task expressions at deploy time. I figured I could define expressions with a custom syntax in my BPMN and then modify them at deploy time to "wrap" them in a proper expression. I guess it would be a kind of poor-man's way of making custom remote service calls.

For example, I'd like to be able to transform this (representative syntax only):


<serviceTask expression="http://endpoint" />


into this:


<serviceTask expression="${delegator.invoke('endpoint')}" />


where
delegator
is a regular Spring bean.

I tried to modify expressions with a custom
BpmnParseHandler
, but it didn't work. Here's the code I tried:


public static class CustomServiceTaskHandler extends AbstractBpmnParseHandler<ServiceTask> {

    @Override
    protected Class<? extends BaseElement> getHandledType() {
      return ServiceTask.class;
    }

    @Override
    protected void executeParse(BpmnParse bpmnParse, ServiceTask element) {
      element.setImplementation("${nonexistentBeanName}");
    }


I would expect this to trigger an error at runtime, but the task expression doesn't actually seem to be really modified. The original, unmodified expression is still there in the deployed process. I suppose I'm either too late or too early in the parse process, or I completely got the wrong idea.

Is there a way I can get this to work? Or do you think there's an entirely different/better way I can implement this kind of thing?

A bit of background on my setup: I run an Activiti engine as a service, and my clients deploy their processes remotely from their own applications, implemented as microservices. I would like my clients to be able to specify REST URLs directly inside their expressions, as they cannot import Spring beans directly into my JVM.
1 REPLY 1

trademak
Star Contributor
Star Contributor
Hi,

Did you configure the parse handler with a preBpmnParseHandlers or postBpmnParseHandlers property?

http://activiti.org/userguide/index.html#_hooking_into_process_parsing

Best regards,
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.