[jboss-user] [JBoss jBPM] - inject datasource into Action

gogoasa do-not-reply at jboss.com
Mon Jul 16 08:18:42 EDT 2007


Hello,

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">
  |   	</constructor>
  |   </bean>

... 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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4064508#4064508

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4064508



More information about the jboss-user mailing list