Flowable 6.5 migration - engineServices Property removed from ExecutionEntity

Hi

We are migrating from activiti 5.15 to flowable 6.5 - and I see a serious issue given org.activiti.engine.impl.persistence.entity.ExecutionEntity#getEngineServices property has been removed. This was a convenience method used in activiti 5, and our legacy process definitions does use it to fetch flowable core services runtime/identity.

public EngineServices getEngineServices() {
return Context.getProcessEngineConfiguration();
}

We are running our legacy process on a V5 engine as instructed in migration guide but I doubt this is good enough because I don’t see any reference to getEngineServices() at all in ExecutionEntity class and I am not sure how to get around this.

Please advise - thanks!

@joram @martin.grofcik
Basically all these reference in legacy processes are within scripttask -

ex.
def identityService = execution.engineServices.identityService;

Not sure if DynamicBPMNServices can be used to correct this on fly?

Hey @binishprab,

In the script you have access to the beans of the engine configuration. So if you are using Spring you can access the services by using identityServiceBean.

Yes you can use the DynamicBPMNService#changeScriptTaskScript to change the script task of a service.

You have some other options though:

  • Change the scripts in all your models and then deploy them again. Use the SetProcessDefinitionVersionCmd to migrate your process instances to the new version
  • Add your own ScriptTaskParseHandler and register it as a preBpmnParseHandler.

e.g. Your custom parse handler

public class CustomScriptTaskParseHandler extends AbstractActivityBpmnParseHandler<ScriptTask> {

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

    @Override
    protected void executeParse(BpmnParse bpmnParse, ScriptTask scriptTask) {

        String script = scriptTask.getScript();
        if (script != null) {
            scriptTask.setScript(script.replaceAll("execution\\.engineServices\\.identityService", "identityServiceBean"));
        }

    }

}

With the last option, you will be changing the script before the activity is created, during the conversion of the XML into the Java Model

Thanks @filiphr - this is great help! Last option to parse and change on the fly works great!

Also, have a look at the section in the migration guide wrt to removal of getEngineServices(): https://flowable.com/open-source/docs/migration/#engineservices-removed

@filiphr - if we have multiple different script values to replace, one option is to use regex but that might get ugly soon, any other alternative to substitute multiple different strings…?

Hi @filiphr @joram - even regex won’t be good enough here…suppose you have multiple different scripts to replace, only way I can think of is looking for scriptid and doing a replace but that would be very specific, and won’t handle dynamic replacement for all the scripts - any better ideas?

Hey @binishprab,

You can do multiple replaceAll.

e.g.

scriptTask.setScript(
    script.replaceAll("execution\\.engineServices\\.identityService", "identityServiceBean")
                .replaceAll("execution\\.engineService\\.runtimeService", "runtimeServiceBean")
);

ok let me try - thanks!