JBoss Community

Re: Jbpm 5 - call to spring beans

created by malabalu in jBPM - View the full discussion

Thanks Esteban for your reply. As I originally mentioned in my post, I have read that in jbpm4, it is possible to call the spring beans from the process.

 

http://www.inze.be/andries/2009/06/28/documentation-spring-jbpm-integration/

 

Please look under configuration.I am new to jbpm and did not understand the whole configuration in the above one . May be it is something that was possible in jbpm4 but not in jbpm5.

 

 

Also currently in our jbpm3 project, we are using a singleton class to look up beans in Spring context .I have pasted some of the code snippets .Since this has the hard coding of  the bean names in the codebase, we want to see if there are other ways.

 

 

 

ServiceInstance serviceInstance = ServiceInstance.getInstance();

 

return (PaymentService) serviceInstance.getBean("paymentServiceBean");

 

where ServiceInstance is a class that implements implements org.springframework.context.ApplicationContextAware and has a property of

org.springframework.context.ApplicationContext ...so the getBean will lookup the beans with name and return them.

 

 



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

public class ServiceInstance implements

 

ApplicationContextAware {

 

private static ServiceInstance staticServiceInstance = new

ServiceInstance();

 

private static ApplicationContext ac;

 

 

public static

ServiceInstance getInstance() {

 

return staticServiceInstance

;

}

 

 

 

 

@Override

 

 

public void

setApplicationContext(ApplicationContext applicationContext)

 

throws

BeansException {

 

if (ac == null) {

 

ac

ac = applicationContext;

}

}

 

 

 

 

 

public Object getBean(String beanId) {

 

return ac.getBean(beanId);

}

Reply to this message by going to Community

Start a new discussion in jBPM at Community