View Full Version : Method Injection
10-26-2006, 01:09 PM
Is method-injection for Spring.Web implemented? If not, would someone know when it is going to be?
10-27-2006, 12:48 AM
You mean method-injection in Spring.Web.UI.Page instances ?
Have you tried do use method injection (http://www.springframework.net/doc/reference/html/objects.html#objects-method-injection) yet ?
10-27-2006, 01:33 PM
No, I was talking about the method injection in normal objects in a Spring.Web context. When we tried, we got an exception stating that the method injection is not implemented. We're using the 22nd of Sep build.
In a web context, for every object the Instantiate() method of the WebInstationStrategy class is executed. If the object is not a page, the base class is used to instantiate (SimpleInstantiationStrategy). And in SimpleInstantiationStrategy class, the method InstantiateWithMethodInjection is not implemented:
protected virtual object InstantiateWithMethodInjection(
RootObjectDefinition definition, string objectName, IObjectFactory factory)
throw new NotImplementedException();
10-27-2006, 07:16 PM
Thanks for the detail, it's clear now.
If I'm right, initial web support has been implemented before Method injection support.
I don't have time to test, so can you try to make WebInstantiationStrategy (Spring.Web/Core/Objects/Factory/Support) inherit from MethodInjectingInstantiationStrategy instead of SimpleInstantiationStrategy.
10-30-2006, 08:35 AM
The missing support for method injection appears to be an oversight. There certainly is no technical reason blocking such support being added in the near future. I am loathe to commit such a change myself because it has been such a long time since I have committed on Spring.NET (coming on a year now); Bruno or one of the other current core committers will address this.
If I can ask, what is the use case that might require you needing method injection? On the Spring.Java side, I have never used it, preferring the ServiceLocatorFactoryBean (http://www.springframework.org/docs/api/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.html) strategy myself (less magical, easier to test).
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.