AOP discreto com Spring.Net
Estou tentando adicionarexploração madeireir paramethods decorados com um atributo usando Spring.Net para AOP.
Etapa 1: Referência 'Spring.Core', 'Spring.Aop', 'Common.Logging'
Etapa 2: Crie um conselho:
using AopAlliance.Intercept;
namespace MyApp.Aspects
{
public class LoggingAdvice : IMethodInterceptor
{
public object Invoke(IMethodInvocation invocation)
{
//todo: log started
object rval = invocation.Proceed();
return rval;
//todo: log finished
}
}
}
Etapa 3: Crie um atributo:
using System;
namespace MyApp.Aspects
{
public class LoggingAttribute : Attribute
{
}
}
Etapa 4: Editar web.config
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springfrmework.net">
<object id="loggingAdvice" type="MyApp.Aspects.LoggingAdvice, MyApp"></object>
<object id="loggingAdvisor" type="Spring.Aop.Support.DefaultPointcutAdvisor, Spring.Aop">
<property name="Advice" ref="loggingAdvice" />
</object>
<object type="Spring.Aop.Framework.AutoProxy.AttributeAutoProxyCreator, Spring.Aop">
<property name="AttributeTypes" value="MyApp.Aspects.LoggingAttribute"/>
<property name="InterceptorNames" value="loggingAdvisor"/>
</object>
</objects>
</spring>
</configuration>
Etapa 5: Decore um método com o atributo:
using System.Web.Mvc;
namespace MyApp.Controllers
{
public class MyController : Controller
{
[Logging]
public ActionResult DoStuff()
{
//todo: implement
}
}
}
Oadend énunca acionado. O que estou perdendo