alkampfer
07-05-2007, 08:04 AM
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.DefaultAdvisorAutoP roxyCreator, Spring.Aop" />
<object id="WsSecurityAdvisor"
type="Spring.Aop.Support.RegularExpressionMethodPointcut Advisor, Spring.Aop">
<property name="advice" ref="WsSecurityAdvice" />
<property name="patterns">
<list>
<value>.*Customer.*</value>
</list>
</property>
</object>-->
</objects>
Thanks for any help.
Alk.
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.DefaultAdvisorAutoP roxyCreator, Spring.Aop" />
<object id="WsSecurityAdvisor"
type="Spring.Aop.Support.RegularExpressionMethodPointcut Advisor, Spring.Aop">
<property name="advice" ref="WsSecurityAdvice" />
<property name="patterns">
<list>
<value>.*Customer.*</value>
</list>
</property>
</object>-->
</objects>
Thanks for any help.
Alk.