PDA

View Full Version : Problem with PrototypeTargetSource


alkampfer
07-03-2007, 07:57 AM
I was new to Spring AOP, I'm trying to make a little example of aop but I've problem with the lifecycle of the objects. I have a object called Order, and I want to apply an After Returning Advice, all works with this configuration file, but the object is handled as singleton even if I put Singleton="false".
After reading documentation I found that I need to use PrototypeTargetSource, but this does not work because It creates a different object at each method invocation.
I wish to have a proxy that for every call

IApplicationContext ac = ContextRegistry.GetContext();
CurrentOrder = (Order) ac.GetObject("Order");

Give me a proxy for a new order object. Actually I can obtain a single Order for each call, or a proxy that creates another order at each method call, how can I solve my problem?

Alk.

alkampfer
07-03-2007, 08:26 AM
Please ignore that question, I read again the pdf with much attenction and I find a solution. I now use this mapping

<object id="Order" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="isSingleton" value="false"/>
<property name="TargetName" value="OrderTarget"/>
...