A quote from J2EE Design and Development without EJB:
Some people now seem to want to inject dependencies into “each and every object” of not-very-spring-friendly frameworks (e.g. struts, hibernate, jdo). While this is sometimes possible, it sometimes seems to introduce complexity into Spring and the Spring users configuration.Spring AOP - Cons
It's only possible to use configuration to advise objects obtained from a Spring IoC container, or to use the AOP framework programmatically; it's not possible to advise objects at the class loader level so that the new operator returns an advised object. As all business objects in Spring applications are obtained from the IoC container, it's possible to apply advice in a much broader range of cases than is supported by EJB. However, it would be harder to apply advice to all objects to be persisted with Hibernate, for example. Like lack of support for field interception, this partly reflects a conscious decision. Spring is not intended to encourage advising each and every object. (This may pose performance problems, for example.) Spring is designed to encourage obtaining business objects from a Spring container, which helps to structure applications. And this way there's never any doubt as to which objects are advised, and what advice applies.
So here's the question: Wouldn't a Spring class loader make general purpose dependency injection much simpler than the complexity of the AOP interceptor/proxy approach?
Simple Example: Struts integration.
Sure, its not too bad, but I have to learn about DelegatingActionProxy. I'd rather have a “normal” struts-config.xml and a simple applicationContext.xmlCode:struts-config.xml <action path="/EditItem" type="org.springframework.web.struts.DelegatingActionProxy" ... </action> action-servlet.xml <bean name="/EditItem" class="com.foo.struts.action.EditItemAction" singleton="false"> <property name="artBS"><ref bean="artBS"/></property> </bean>
A Spring aware classloader could make this work. Big deal, you may say, but look at a more complex example of the same issue.Code:struts-config.xml <action path="/EditItem" type="com.foo.struts.action.EditItemAction" ... </action> applicationContext.xml <bean name="IMHOanyPlaceHolderNameWouldDo" class="com.foo.struts.action.EditItemAction" singleton="false"> <property name="artBS"><ref bean="artBS"/></property> </bean>
A Complex Example: Full Hibernate object injection.
This very popular thread called “How Common to Spring Manage Beans Created By Hibernate? http://forum.springframework.org/viewtopic.php?t=301 comes to the conclusion that you can inject into hibernate created objects using org.springframework.orm.hibernate.support.Dependen cyInjectionInterceptorFactoryBean. It also requires some complex xml configuration that reminds me of EJB deployment descriptors (;->). Now I have to learn hibernate and some specialized Spring specific XML configuration. But aren't we just trying to a bit of simple dependency injection here?
(Yes I know, this is an advanced use of Spring/Hibernate and its non-essential to get Spring and hibernate working nicely. However many people in the thread seem very happy to have this advanced feature and Rod/others seem keen to support it. )
Couldn't a Spring aware classloader make this work without a DependencyInjectionInterceptorFactoryBean and the simplest of config in applicationContext.xml ?
Other Examples?
http://forum.springframework.org/vie... c&highlight=
I expect that I am being naïve about a Spring class loader. I'm sure that there are some very big issues with a class loader especially in an EJB application server which generally want to control classloading. However I was surprised from 10,000 feet up not see some discussion about this. I did search the forums for “class loader” but I couldn't find anybody discussing this directly.
So here's the question again with an addition in italics: Wouldn't a Spring class loader make general purpose dependency injection and its configuration much simpler than the complexity of the AOP interceptor/proxy approach from an end user perspective?


Reply With Quote