AnsweredAssumed Answered

Accessing Spring Beans from a ServiceTask

Question asked by frank41 on Apr 28, 2012
Latest reply on Jan 19, 2017 by itsmevkrishna@gmail.com
Hi all !
I'd need to access Spring beans from a Java Service Task. I have tried with field injection:

public class SpringServiceTask implements JavaDelegate {
  
    private DataSource ds;
  
    public void setDataSource(DataSource ds) {
         this.ds= ds;
  
    }
    public void execute(DelegateExecution execution) throws Exception {
       System.out.println("DataSource "+ds); // NULL!
    }
}
However the injection does not happens and this the execute method prints null.
Even if I've added the datasource reference in the applicationContext.xml, nothing is injected:
<bean id="reviewApproved" class="com.sample.ReviewApproved">
        <property name="ds" ref="dataSource"/>
</bean>
Any help ?
Thanks a lot
Frank

Outcomes