-
Nov 2nd, 2006, 10:57 AM
#1
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?
-
Nov 2nd, 2006, 11:35 AM
#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 at 11:40 AM.
-
Nov 2nd, 2006, 11:57 AM
#3
Ah excellent, that's a great idea 
Cheers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules