Announcement Announcement Module
No announcement yet.
Factory for generating multiple beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Factory for generating multiple beans

    I'm looking for a way to write something like a FactoryBean which can generate multiple beans for the application context. The reason for this is that I have a legacy component with its own configuration file, and this component exposes a collection of beans. I'd like to automatically register those beans with the spring application context, rather than individually fetch them from a vanilla FactoryBean.

    The spring ref docs don't seem to have anything that covers this pattern. Any ideas?

  • #2
    You probably would be better off implementing BeanFactoryPostProcessor than FactoryBean. A postprocessor can register new bean definitions perfectly sensibly. To register singletons (your use case) you need registerSingleton(String, Object) from DefaultSingletonBeanRegistry.
    Last edited by Dave Syer; Nov 2nd, 2006, 11:40 AM.


    • #3
      Ah excellent, that's a great idea