how to programmatically register an already setup bean to spring context
Posted
by lisak
on Stack Overflow
See other posts from Stack Overflow
or by lisak
Published on 2010-06-16T23:57:51Z
Indexed on
2010/06/17
0:02 UTC
Read the original article
Hit count: 327
Hey,
I'm wondering how one can do that. Afaik there is BeanFactoryPostProcessor interface that let us use BeanDefinitionRegistry.registerBeanDefinition() method before beans within context are initialized. That method accepts only a class / definition. But usually one needs to register a bean that is already set with properties. Otherwise the bean definition registration itself is kinda useless. I don't want to set it up additionally after I get it from context then.
When using singleton it's ok, but for prototypes I'd have to set the bean up for each getBean() .
© Stack Overflow or respective owner