This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.
This is normally not possible. The bean names/ids are only used by the spring container.
The only approach I could think of is this:
The proxied bean has to implement BeanNameAware so that it knows its name. Further it has to implement another interface that defines a getter for the bean name.
A proxy can then check if the target bean implements that interface and can retrieve the bean name.
If there are further proxies in-between things would not work out so fine. Anyway, I do not find that approach very nice.
It's possible we will support this in 2.0 M3, to support a new bean() pointcut designator as part of the AspectJ Spring integration. I just committed an ExposeBeanNameAdvisor, which the autoproxying code may use in future. This is not certain, because there are some issues to resolve regarding eager pointcut evaluation, but it should certainly work in interceptors.