0 Replies Latest reply on Jul 16, 2007 8:18 AM by Adrian Dimulescu

    inject datasource into Action

    Adrian Dimulescu Newbie


      I would like to have something like :

      public class OnStartAction implements ActionHandler {
       Datasource datasource;

      And I would like to have the "datasource" property injected by jBPM. I haven't actually found a direct solution. What I can do at this point is to add this declaration to jbpm.cfg.xml :

      <bean name="extra-datasource" class="javax.sql.Datasource" singleton="true">
       <constructor factory-class="fr.bnf.entrychain.jbpm.actions.helper.TestDatasourceFactory" method="lookupDatasource">

      ... and have the following code inside the action :

      ds = (DataSource) ctxt.getJbpmContext().getObjectFactory().createObject("extra-datasource");

      I don't like this solution because it's not very DI-compliant. Some injection may be done by mocking the whole jbmcontext.objectfactory... object graph but I would kind of bet there's a simpler solution.

      Thanks for any ideas.