Hi all,
I'm using severals Aop pointcut for services of my application, to manage transactions, to add log and to throw generic exceptions (which have error messages stored into a configuration file).
My problem is the execution order of all these advices.
Here is what I wish :
_ Spring hibernate Transaction advice
_ My Service generic exception
_ Spring flex ExceptionTranslationAdvice
_ My Service logging advice
Part of my code
and...Code:<!-- The AOP logger for services --> <bean id="serviceLoggingAdvice" class="com.mycompany.services.aop.ServiceLoggingAdvice" /> <!-- The AOP exception manager for services --> <bean id="serviceExceptionAdvice" class="com.mycompany.services.aop.ServiceExceptionAdvice" init-method="initData"/> <!-- Match AOP logger and services classes with Regexp --> <bean id="loggingAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor" > <property name="advice" ref="serviceLoggingAdvice" /> <property name="pattern" value="com.mycompany.myapp.*" /> <property name="order" value="100" /> </bean> <!-- Match AOP exception manager and services classes with Regexp --> <bean id="exceptionAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice" ref="serviceExceptionAdvice" /> <property name="pattern" value="com.mycompany.myapp.*" /> <property name="order" value="20" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" order="10"/>
Code:<!-- Custom exception translator configured as a Spring bean --> <bean id="exceptionTranslator" class="com.mycompany.services.exception.ServerExceptionTranslator" /> <flex:message-broker> <flex:exception-translator ref="exceptionTranslator"/> <flex:mapping pattern="/messagebroker/*" /> <flex:secured per-client-authentication="true"> </flex:secured> </flex:message-broker>
I can modifiy the pointcut order for 3 of them, but I don't know how to modify the pointcut order of the spring-flex ExceptionTranslationAdvice.
I found the advisor initialization by xml code into the class MessageBrokerBeanDefinitionParser
How can I change the pointcut order for this advice.Code:BeanDefinitionBuilder advisorBuilder = BeanDefinitionBuilder.genericBeanDefinition(SERVICE_MESSAGE_ADVISOR_CLASS_NAME); BeanDefinitionBuilder exceptionTranslationBuilder = BeanDefinitionBuilder.genericBeanDefinition(EXCEPTION_TRANSLATION_CLASS_NAME); exceptionTranslationBuilder.addPropertyValue(EXCEPTION_TRANSLATORS_PROPERTY, translators); String exceptionTranslationId = ParsingUtils.registerInfrastructureComponent(element, parserContext, exceptionTranslationBuilder); advisorBuilder.addConstructorArgReference(exceptionTranslationId); String advisorId = ParsingUtils.registerInfrastructureComponent(element, parserContext, advisorBuilder); advisors.add(new RuntimeBeanReference(advisorId));
Thanks for your help and this great stuff


Reply With Quote
