Results 1 to 4 of 4

Thread: Question on AOP and ICLoneable

  1. #1
    Join Date
    Feb 2007
    Posts
    12

    Default Question on AOP and ICLoneable

    Hi,

    I've created a class with all virtual methods, then I define an aspect and set Spring.NET AOP to add the aspect to the class. When I ask to Spring.NET to create the object all works well, My class is named Customer and spring creates to me a
    [DecoratorAopProxy_56ee607448f64ab5991769f98b2d4731]
    I was able to cast this class to a Customer object since it inherits from Customer and all works as expected.
    The problem arise when I impment the ICloneable Interface on Customer object
    public class Customer : ICloneable
    {
    public virtual object Clone() {

    return new Customer(this);
    }
    Rest of the class is the same as before, now the cast to the Customer object does not work anymore because now the AOP had created a proxy not for the Customer class but for the ICloneable interface.

    This is the XML I use to set the AOP

    <objects xmlns="http://www.springframework.net"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd" >

    <object id="CustomerTarget" type="NorthwindTest.Entities.Customer, NorthwindTest" singleton="false" />

    <object id="Customer"
    type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">

    <property name="isSingleton" value="false"/>
    <property name="TargetName" value="CustomerTarget"/>
    <property name="interceptorNames">
    <list>
    <value>WsSecurityAdvice</value>
    </list>
    </property>
    </object>

    <object id="WsSecurityAdvice" type="XTest.SecurityAdvice, XTest">
    <property name="permittedRoles">
    <list>
    <value>admin</value>
    </list>
    </property>
    </object>

    <!--<object id="ProxyCreator" type="Spring.Aop.Framework.AutoProxy.DefaultAdviso rAutoProxyCreator, Spring.Aop" />



    <object id="WsSecurityAdvisor"
    type="Spring.Aop.Support.RegularExpressionMethodPo intcutAdvisor, Spring.Aop">

    <property name="advice" ref="WsSecurityAdvice" />
    <property name="patterns">
    <list>
    <value>.*Customer.*</value>
    </list>
    </property>
    </object>-->
    </objects>

    Thanks for any help.

    Alk.

  2. #2
    Join Date
    Feb 2007
    Posts
    12

    Default

    Again do not pay attention to the post, I find how to force Spring to create a proxy of the class instead of proxying only the interfaces.

    alk.

  3. #3
    Join Date
    Jun 2007
    Posts
    6

    Default

    can you send me your source code , how you get a class from the proxy. thank you , henryxuv@sina.com. or henryxuv@gmail.com

  4. #4
    Join Date
    Feb 2007
    Posts
    12

    Default

    Actually my problem is that spring proxyes all the interfaces of the object, so since the object implements icloneable the class was a decorator around ICloneable, but I need a real proxy that inherits from my class and override virtual method.

    To access the proxyed class I remember that the proxy can be cast to some interface such as IAdvice, check the documentation for further detail.

    alk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •