bike part reward : setting bean ID property automatically
Ian Young
ian at iay.org.uk
Fri Feb 7 06:53:36 EST 2014
On 7 Feb 2014, at 01:41, Brent Putman <putmanb at georgetown.edu> wrote:
> 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);
> }
> }
This would presumably get called for all beans instantiated in the container; what would happen if the bean was an anonymous bean? #setId includes:
> id = Constraint.isNotNull(StringSupport.trimOrNull(componentId), "Component ID can not be null or empty");
Serious question, I don't know how beans without names are represented to this API and the documentation I've found doesn't seem to say.
I really hate having to duplicate this information in the common case, so some way to avoid it would be peachy. I'm guessing we could just avoid setting the name under the following circumstances:
* it has already been set
* new bean name is whatever anonymous beans are set to
Also, "return bean" needed somewhere?
-- Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20140207/97d3556c/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5943 bytes
Desc: not available
Url : http://shibboleth.net/pipermail/dev/attachments/20140207/97d3556c/attachment-0001.bin
More information about the dev
mailing list