PDA

View Full Version : InjectionPoint in Spring



xlukas
Jan 10th, 2009, 03:28 AM
WebBeans specification defines InjectionPoint (http://docs.jboss.org/webbeans/reference/1.0.0.ALPHA1/en/html/injection.html#d0e1537). Using this, bean factory can obtain information about place where the instance it is creating will be injected. Please take a look to the documentation (http://docs.jboss.org/webbeans/reference/1.0.0.ALPHA1/en/html/injection.html#d0e1537) for detailed information.
I just wonder if it would be useful to have something similar in Spring. On one hand, it is against Spring philosophy. Beans in Spring are not aware of place where they will be injected. On the other hand, it might be useful.
I have written an ugly enhancement of AutowiredAnnotationBeanPostProcessor that stores DependencyDescriptor in ThreadLocal (source (https://java-crumbs.svn.sourceforge.net/svnroot/java-crumbs/trunk/injection-point/)). Bean factory then can extract this information. But I was able to make it work only for field injection and I do not like the solution at all. To make it work I would have to change Spring source code.
My question is if you think that it would be useful to have something similar in Spring? If so, I have some spare time right now, so I can try to write some proof of concept implementation.

ceefour
Jan 7th, 2010, 11:53 AM
WebBeans specification defines InjectionPoint (http://docs.jboss.org/webbeans/reference/1.0.0.ALPHA1/en/html/injection.html#d0e1537). Using this, bean factory can obtain information about place where the instance it is creating will be injected. Please take a look to the documentation (http://docs.jboss.org/webbeans/reference/1.0.0.ALPHA1/en/html/injection.html#d0e1537) for detailed information.
I just wonder if it would be useful to have something similar in Spring. On one hand, it is against Spring philosophy. Beans in Spring are not aware of place where they will be injected. On the other hand, it might be useful.
I have written an ugly enhancement of AutowiredAnnotationBeanPostProcessor that stores DependencyDescriptor in ThreadLocal (source (https://java-crumbs.svn.sourceforge.net/svnroot/java-crumbs/trunk/injection-point/)). Bean factory then can extract this information. But I was able to make it work only for field injection and I do not like the solution at all. To make it work I would have to change Spring source code.
My question is if you think that it would be useful to have something similar in Spring? If so, I have some spare time right now, so I can try to write some proof of concept implementation.
+1 for this. I definitely support Spring implementing JSR-299 aka WebBeans aka CDI even if just a subset.