|
From: Alexandru P. <the...@gm...> - 2005-08-29 09:53:01
|
#: Steven Devijver changed the world a bit at a time by saying on 8/29/2005 10:29 AM :#
> Lilantha,
>
> After returning advice is indeed processed in the opposite order.
> Since the method invocation moves back up the advisor chain the last
> advisor is processed first, then the second to last and so on until
> all advisors have been processed.
>
> If you would chain an number of around advices (method interceptors)
> they would also be processed in the inverse order once the target
> method exits although they have been called in the expected order when
> the method invocation starts.
>
> Steven
>
This looks to me pretty unintuitive, because we are talking about after advices. The rules you are
exposing are correct, but they apply to around advice. I imagine that this is caused by the fact
that Spring doesn't have real before and after advices, but rather it is emulating them using always
around (this is true for all proxy based aop solutions).
:alex |.::the_mindstorm::.|
> On 8/29/05, Lilantha Darshana <Lil...@si...> wrote:
>>
>>
>>
>> Hi
>>
>>
>>
>> I'm trying a to invoke a joint point where I have two after returning
>> advices that I need to execute
>>
>> In the order that I have specified in the config bean. My bean definitions
>> is something like:
>>
>>
>>
>> <bean id="test"
>> class="org.springframework.aop.framework.ProxyFactoryBean">
>>
>> <property
>> name="proxyInterfaces"><value>ITarget</value></property>
>>
>> <property name="target"><ref local="testTarget"/></property>
>>
>> <property name="interceptorNames">
>>
>> <value>testAdvice1,testAdvice2</value>
>>
>> </property>
>>
>> </bean>
>>
>> <bean id="testTarget" class="Target"/>
>>
>>
>>
>> <bean id="testAdvice1"
>> class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
>>
>> <property name="advice">
>>
>> <bean class="AfterAdvice1"/>
>>
>> </property>
>>
>> <property name="patterns">
>>
>> <list>
>>
>> <value>.*foo</value>
>>
>> </list>
>>
>> </property>
>>
>> </bean>
>>
>> <bean id="testTarget" class="Target"/>
>>
>>
>>
>> <bean id="testAdvice2"
>> class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
>>
>> <property name="advice">
>>
>> <bean class="AfterAdvice2"/>
>>
>> </property>
>>
>> <property name="patterns">
>>
>> <list>
>>
>> <value>.*foo</value>
>>
>> </list>
>>
>> </property>
>>
>> </bean>
>>
>>
>>
>> My expectation is, after retuning from the join point it should execute
>> return method of each of
>>
>> these after advices in the same order as I have specified in the bean.
>>
>> i.e. testAdvice1 followed by testAdvice2.
>>
>>
>>
>> However, it's executes them in opposite order. This seems due to following
>> method of
>>
>> AfterReturningAdviceInterceptor class.
>>
>>
>>
>> public Object invoke(MethodInvocation mi) throws Throwable {
>>
>> Object retVal = mi.proceed();
>>
>> this.advice.afterReturning(retVal, mi.getMethod(),
>> mi.getArguments(), mi.getThis());
>>
>> return retVal;
>>
>> }
>>
>>
>>
>> Appriciate if you would clarify why it is execute in opposite order? Is it
>> the intended way to execute them?
>>
>>
>>
>> Thanks
>>
>> -Lilantha
>>
>> _______________
>> Siebel
>> IT'S ALL ABOUT THE CUSTOMER
>> Visit www.siebel.com
>>
>> This e-mail message is for the sole use of the intended recipient(s) and
>> contains confidential and/or privileged information belonging to Siebel
>> Systems, Inc. or its customers or partners. Any unauthorized review, use,
>> copying, disclosure or distribution of this message is strictly prohibited.
>> If you are not an intended recipient of this message, please contact the
>> sender by reply e-mail and destroy all soft and hard copies of the message
>> and any attachments. Thank you for your cooperation.
>>
>
>
|