kevwil
11-17-2006, 09:31 PM
I am trying to use a proxied object (AOP) as a constructor-arg dependency. When I request my final object from the app context, my intent is that it's dependency is resolved from the proxy factory and has the AOP advice applied. Here's my config:
<object id="debug.interceptor" type="Spring.Aop.Advice.DebugAdvice,Spring.Aop"/>
<object id="auth.service.target" type="TestSiteSpring.CustomAuthService,TestSiteSpring" singleton="false"/>
<object id="auth.service" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="target" value="auth.service.target"/>
<property name="proxyInterfaces">
<list>
<value>TestSiteSpring.IAuthService</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>debug.interceptor</value>
</list>
</property>
</object>
<object id="complex.controller" type="TestSiteSpring.Controllers.ComplexController, TestSiteSpring" singleton="false">
<constructor-arg name="logger" ref="log4net.wrapper"/>
<constructor-arg name="authService" ref="auth.service" type="TestSiteSpring.IAuthService, TestSiteSpring"/>
</object>
The following unit test fails:
IApplicationContext context = ContextRegistry.GetContext();
Assert.IsNotNull( context );
object svc = context[ "auth.service" ];
Assert.IsInstanceOfType( typeof( IAuthService ), svc );
With the above config, I get an ArgumentException "Interface not found". If I leave out the 'proxyInterfaces' property, I get this UnsatisfiedDependencyException:
Error creating object with name 'complex.controller' defined in 'config [objects]' : Unsatisfied dependency expressed through constructor argument with index 1 of type [TestSiteSpring.IAuthService] : Could not convert constructor argument value [auth.service.target] to required type [TestSiteSpring.IAuthService] : Cannot convert property value of type [Spring.Aop.DynamicProxy.Proxy_c81fe12774194a828326 6675eaf64b60] to required type [TestSiteSpring.IAuthService] for property ''.
I'm new to Spring.NET, so I'm sure I'm doing something wrong. Can anyone find it?
Edit: I forgot to mention this is version 1.0.2 in a .NET 2.0 app.
<object id="debug.interceptor" type="Spring.Aop.Advice.DebugAdvice,Spring.Aop"/>
<object id="auth.service.target" type="TestSiteSpring.CustomAuthService,TestSiteSpring" singleton="false"/>
<object id="auth.service" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="target" value="auth.service.target"/>
<property name="proxyInterfaces">
<list>
<value>TestSiteSpring.IAuthService</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>debug.interceptor</value>
</list>
</property>
</object>
<object id="complex.controller" type="TestSiteSpring.Controllers.ComplexController, TestSiteSpring" singleton="false">
<constructor-arg name="logger" ref="log4net.wrapper"/>
<constructor-arg name="authService" ref="auth.service" type="TestSiteSpring.IAuthService, TestSiteSpring"/>
</object>
The following unit test fails:
IApplicationContext context = ContextRegistry.GetContext();
Assert.IsNotNull( context );
object svc = context[ "auth.service" ];
Assert.IsInstanceOfType( typeof( IAuthService ), svc );
With the above config, I get an ArgumentException "Interface not found". If I leave out the 'proxyInterfaces' property, I get this UnsatisfiedDependencyException:
Error creating object with name 'complex.controller' defined in 'config [objects]' : Unsatisfied dependency expressed through constructor argument with index 1 of type [TestSiteSpring.IAuthService] : Could not convert constructor argument value [auth.service.target] to required type [TestSiteSpring.IAuthService] : Cannot convert property value of type [Spring.Aop.DynamicProxy.Proxy_c81fe12774194a828326 6675eaf64b60] to required type [TestSiteSpring.IAuthService] for property ''.
I'm new to Spring.NET, so I'm sure I'm doing something wrong. Can anyone find it?
Edit: I forgot to mention this is version 1.0.2 in a .NET 2.0 app.