PDA

View Full Version : Suppressing attribute proxying in code



avidgoffer
07-25-2007, 09:11 PM
Hello,

I am very new to spring and was wondering if there is a way to suppress attribute proxying when doing an introduction in the code? Also are there any examples available about introductions on complex structures?

In the following code I am creating a proxy for my policy class, basically following example 6 in the quickstart, and this works fine when I comment out the GUID attribute on the Policy class.


public IPolicy GetPolicy(StateId state, int policyNumber)
{
PolicyAdapter reader = (PolicyAdapter)CreateObject(ObjectNames.PolicyAdap ter);
IPolicy policy = reader.Fetch(state, policyNumber);

ProxyFactoryObject pf = new ProxyFactoryObject();
pf.Target = policy;
pf.AddAdvisor(new ModificationAdvisor(policy.GetType()));
pf.AddIntroduction(new IsModifiedAdvisor());
pf.ProxyTargetType = true;

return (IPolicy)pf.GetObject();
}

thanks

Aaron

Bruno Baia
07-25-2007, 11:35 PM
Hi,

this is known bug (about GuidAttribute (http://forum.springframework.net/showthread.php?t=3020)) resolved since 1.1 M2.
We also introduced the ProxyTargetAttributes property to avoid target attributes to be copied (true by default) :


<object id="securedUserService" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="targetName" value="userService" />
<property name="proxyTargetAttributes" value="false" />
<property name="InterceptorNames">
<list>
<value>securityBeforeAdvisor</value>
</list>
</property>
</object>


Cheers,
Bruno