Service bean call inside a script task

Hello!

Right now, we using flowable engine for BPM, so this is more easy to do

  1. Define Spring Bean in spring boot app:

    @Component("BaseBean")
    public class baseBean {
        public String doSomething() {
            System.out.println("do something");
            return "Do something";
        }
    }
    
  2. Use this bean inside script task. Bean name has to be matched with its name in spring context:

    res = BaseBean.doSomething();
    execution.setVariable("doSomething", res);
    

  3. Run process

  4. Proof of work:

Conclusion

I recommend using a Spring Bean type of service task if you only need to call a method from a service, rather than relying on a script task worker. However, if you are developing the process during runtime, using a script task worker is acceptable.

Regards,
Dmitry

1 Like