Announcement Announcement Module
Collapse
No announcement yet.
How to obtain the beanFactory from a Web app Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to obtain the beanFactory from a Web app

    I am using Quartz to schedule some jobs in a web application. The class that implements the job needs a reference to an object defined in the application context (applicationContext.xml). I first tried to use the WebApplicationContextUtils class to obtain the bean factory but I don't have the ServletContext......The other possibility would be to use the SingletonBeanFactoryLocator but I don't want to load the application context again since it is already loaded. I would like to know if there is a possibility to obtain the bean factory without having the ServletContext.
    Thanks...

  • #2
    if the class is created by Spring you can implement ApplicationContextAware interface and then set a reference to the application context (setApplicationContext will be called by the bean factory when it creates this object)

    if you are using a QuartzJobBean extension created by Spring you can implement ApplicationContextAware and set a refencence in the implementing class when it the job bean creates it.

    Comment

    Working...
    X