bike part reward : setting bean ID property automatically
Tom Zeller
tzeller at dragonacea.biz
Thu Feb 6 20:46:28 EST 2014
> I'll offer bike parts from my bike part bin if someone can figure out
> how we can set an IdentifiableComponent's ID via Spring without
> setting the 'id' property in addition to the 'id' attribute.
>
>
> I think that's done pretty easily automagically with a BeanPostProcessor
> that does something like:
>
> Object postProcessBeforeInitialization(Object bean, String beanName) throws
> BeansException {
> if (bean instanceof IdentifiableComponent) {
> ((IdentifiableComponent)bean).setID(beanName);
> }
> }
Nice !
More information about the dev
mailing list