How to add DmnTransformListener?

Hi

I need to reassign User Tasks when the dmn rules change. So I guess its bessed to get informed when a new version of a decision is deployed. It seems like DmnTransformListener#transformDecision might be a good hook. But: how can I add DmnTransformListener to the engine configuration?

Thanks

Jan

Hi Jan,

You could write a process engine plugin which adds the DmnTransformListener to the dmn engine configuration. This could look like as follows:

plublic class MyPlugin extends AbstractProcessEnginePlugin {

  public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
    DefaultDmnEngineConfiguration dmnEngineConfiguration = processEngineConfiguration.getDmnEngineConfiguration();
    DmnTransformer transformer = dmnEngineConfiguration.getTransformer();
    transformer.transformListeners(Arrays.asList(/* List of DmnTransformListener */));
  }

}

This is the only way I see so far.

Does it help you?

Cheers,
Roman

1 Like

Hi Roman

thanks … tricky, but it works for me … I guess I will open a PR where this API is better accessible on the DmnConfig itself …

Jan

BTW: I found this to be more secure:

final DefaultDmnEngineConfiguration dmnEngineConfiguration = processEngineConfiguration.getDmnEngineConfiguration();
      final DmnTransformer transformer = dmnEngineConfiguration.getTransformer();
      transformer.getTransformListeners().add(new DmnLifecycleTransformListener(eventBus));

since it is at least possible that there are already listeners subscribed which would be removed on transformListeners(…)

Hello @jangalinski, is this the way, or a better way is available. I want to try DmnDataTypeTransformer for our spring project. Looking on how to hook this with engine. Thanks.