Spring in Workbrain - Part 6 - Using Spring in Legacy modules

As I'm discussed before, not all of Workbrain is making use of Spring. The core product has made it really easy to make use of your custom or core services outside of Spring through the use of the BeanLocator singleton class.

Get an instance of com.workbrain2.platform.util.context.BeanLocator like below:

GloveOrderService gloveOrderService = 
    (GloveOrderService ) BeanLocator.getInstance().getBean("gloveOrderService");

This even works for code you plan to be run on the Job Scheduler. The Job Scheduler doesn't load any beans by default, but as soon as you get an instance of the BeanLocator, it will load all your beans from your service-config.xml and data-config.xml files.

This is my last post on Spring in Workbrain for a while! If you've got more questions as you are implementing your next Workbrain components, let me know.

0 comments:

Post a Comment