Injecting beans into Camunda Platform Runtime

Hi,

I am using the Camunda Platform Runtime as it allows me to start the Process Engine with minimal effort.

However, when I want to use Script Task, I find it a hassle to always have to use full namespace to refer to my classes, therefore I tried to use @Bean annotation and place my jar in the userlib folder, but it doesn't seem to work.

How do I inject beans into the Camunda Platform Runtime for the scripts to access? In addition, will I be able to use this to similarly simplify the Java Class naming for Java Delegates?

Thanks.

Regards,
Kok Hoor

Hi @kokhoor ,

I’m not really sure if that is what you are asking, but to be able to refer a Spring Bean from a service task you just need to provide an expression like ${MyClass}. That also requires You to set Implementation Type to Delegate Expression.

Then your code should look like the folowing:

public class MyClass implements JavaDelegate {
  public void execute(DelegateExecution delegate) {
    System.out.println("This is MyClass");
  }
}

Last thing to do would be to just register this Bean in application context i.e

@Bean
public MyClass invokeMyClass() {
    return new MyClass();
}

Upon re-deploy you should see the changes. This way You don’t have to provide the “full namespace name”.

Also, please have a look at this artcile