Announcement Announcement Module
No announcement yet.
Standard Java App & Spring Integration Pattern Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Standard Java App & Spring Integration Pattern

    I was just wondering if there is a recommended approach to integrating Spring into a legacy application. Assume I have a main class that can initialize the ApplicationContext, how then do you make this reference available within the legacy code so that spring controlled beans can are accessible?

    Throwing ideas around ...
    Would you wrap the ApplicationContext in a standard old school singleton and then do something like MySingleton.getInstance().getApplicationContext() (or just MySingleton.getApplicationContext()? Or would you just create a bean that implements ApplicationContextAware to assume this role? Is there something in the Spring APIs more appropriate or that would be considered more elegant?

  • #2
    Should it be BeanFactory

    Thinking about the above, could you also help me understand if I should use the BeanFactory instead of the ApplicationContext in this context?


    • #3
      You might want to have a look at the SingletonBeanFactoryLocator and ContextSingletonBeanFactoryLocator. The JavaDoc is very thorough: