tags:

views:

21

answers:

1

Say I have a class, "FQN.AuthorizeAllOfMe", with a series of methods, say X(), Y(), and Z(). Then let's say I have the following advice already:

public class AuthorizationAdvice: IMethodBeforeAdvice
{
    public void Before(MethodInfo method, object[] args, object target)
    {
    }
}

In an ASP.NET application, how do I configure spring.net in web.config to apply the advice to X(), Y(), and Z(). I would prefer to be able to apply it to all methods within AuthorizeAllOfMe, but I will accept individual applications of the advice to the three methods if that is not possible.

I am looking for the specific configuration needed given the class and method names above and using the "Before" advice, not a general description of how to apply aspects to methods.

+1  A: 

See 13.2.3.1.1 in the Spring.NET Reference docs here http://www.springframework.net/doc-latest/reference/html/aop.html#aop-convenience-impls for instructions on how to use the Spring.Aop.Support.SdkRegularExpressionMethodPointcut class, which supports what you seem to be looking for. That section shows the following example, which you can easily adapt for your specific needs:

<object id="settersAndAbsquatulatePointcut" 
    type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut, Spring.Aop">
    <property name="patterns">
        <list>
            <value>.*set.*</value>
            <value>.*absquatulate</value>
        </list>
    </property>
</object>
sbohlen
I stated in my answer "I am looking for the specific configuration...not a general description". I am quite capable of looking through the documentation myself and, in fact, had already done so. I posted to stackoverflow looking for extra help beyond the documentation.
CuriousCoder
As mentioned in the referenced documentation section, if you can construct a regular expression that matches the methods to which you wish to apply the advice, then the example pointed to in the docs should be sufficient on its face to demonstrate how to do what you are asking. Can you help me understand what "extra help" you are seeking? If the docs can be improved in some way, we'd certainly be interested in doing so for others to benefit from.
sbohlen