Hi, i did an example solution to prove what im talking about,
the link to the solution is at the end of this post, unfortunately, due to size limits, i had to exclude spring's dlls so, just open the solution and re-add the references.
I did 3 runs
1.- Open app, and execute programatic creation 5 times, close app

2.- Open app, and execute creation with applicationcontext 5 times, close app

3.- 1.- Open app, and execute 3 programatic and 2 with applicationcontext, close app
http://forum.springframework.net/att...1&d=1149204470
The targetObject is a simple class with 2 fields (1 is string, the other is an int)
Here is an extraction from the code that creates programatically:
Code:
for(int i = 0; i<1000; i++)
{
targetObject = new TargetObject();
sampleAfterAdvice = new SampleAfterAdvice();
sampleBeforeAdvice = new SampleBeforeAdvice();
proxyFactory = new ProxyFactory(targetObject);
proxyFactory.AddAdvice(sampleAfterAdvice);
proxyFactory.AddAdvice(sampleBeforeAdvice);
targetObject = (ITargetObject)proxyFactory.GetProxy();
}
Here is an extraction from the code that uses applicationcontext:
Code:
for(int i = 0; i<1000; i++)
{
targetObject = (ITargetObject) applicationContext.GetObject("ProxyObject");
}
Here is the object configuration
Code:
<objects xmlns="http://www.springframework.net">
<object id="SampleAfterAdvice"
type="SpringSample.SampleAfterAdvice, SpringSample" singleton="false"/>
<object id="SampleBeforeAdvice"
type="SpringSample.SampleBeforeAdvice, SpringSample" singleton="false"/>
<object id="TargetObject"
type="SpringSample.TargetObject, SpringSample" singleton="false"/>
<object id="ProxyObject" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="isSingleton" value="false"/>
<property name="targetName" value="TargetObject" />
<property name="interceptorNames">
<list>
<value>SampleAfterAdvice</value>
<value>SampleBeforeAdvice</value>
</list>
</property>
</object>
</objects>
And here are the main methods of the Before and After Advices
Code:
public void AfterReturning
(object returnValue, MethodInfo method, object[] args, object target)
{
//I commented this line so it wont interfere with this test,
//but it can be uncommented to show the advices actually works
//Console.WriteLine("I'm the after advice");
}
Code:
public void Before
(MethodInfo method, object[] args, object target)
{
//I commented this line so it wont interfere with this test,
//but it can be uncommented to show the advices actually works
//Console.WriteLine("I'm the before advice");
}
Download the Solution (zip file)