views:

198

answers:

2

Hi there guys,

I'm trying to create interceptors for specific methods but I'm having a hard time. I can't bind an aspect to a specific method. I create the faicilities most of examples show but it still doesn't work. Can anyone give me an example of how to do this? I prefer xml conifguration, if possible.

Another question, I have this code:

<component id="SampleAspect"
           service="WindsorSample.Aspect.SampleAspect, WindsorSample" 
           type="WindsorSample.Aspect.SampleAspect, WindsorSample">
</component>

<component id="HtmlTitleRetriever"
           type="WindsorSample.DummyObject, WindsorSample">
  <parameters>
    <interceptors>
      <interceptor>${SampleAspect}</interceptor>
    </interceptors>
  </parameters>
</component>

Then...

IWindsorContainer container = new WindsorContainer(new XmlInterpreter());
IDummyObject retriever = container.Resolve<DummyObject>();
retriever.SomeMethod();

This aspect is not executed. Am I missing something? Am I using the wrong approach for aop?

Thanks

A: 

You can only intercept virtual method, you know that, right?

Krzysztof Koźmic
A: 

Yes. I realized the method was not virtual after I posted. Anyway, I still can't bind an aspect to an specif method. I tried use custom attributes (decorating the methods I want) but the aspect gets binded to the class not to the method I want.

The cofiguration (xml above) is not working as well.

Allan
I think you're misunderstanding DynamicProxy. It's not really an AOP framework, it's a proxying library. I recommend this tutorial: http://kozmic.pl/archive/2009/04/27/castle-dynamic-proxy-tutorial.aspx
Mauricio Scheffer