Using @Component Annotation for JavaDelegate Implementations

I have a Spring Bean which I want to AutoWire in a JavaDelegate Implementation.
If I just add the bean with @Autowired annotation then it throws NullPointerException.

Adding @Component Annotation on the JavaDelegate Implementation class works fine.
Is that ok to use @Component Annotation for JavaDelegate Implementations?

I have read somewhere that the instantiation of these JavaDelegate Implementations happens at the time of Task execution and if 2 tasks are attached to the same JavaDelegate then both will get different instances of the class. Is creating a bean @Component Annotation will be a problem here?

This is perfectly ok. You just have to use “delegate expression” (not “java class”) as the implementation of the service task.

What will be the value in the case of “delegate expression”?

Will it still be similar to Java Class?

It will be the name of the spring bean. E.g. ${myDelegateBean}.

2 Likes