Results 1 to 4 of 4

Thread: ExceptionTranslationAdvice Pointcut order

  1. #1
    Join Date
    Oct 2009
    Posts
    6

    Default ExceptionTranslationAdvice Pointcut order

    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
    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"/>
    and...
    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
    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));
    How can I change the pointcut order for this advice.

    Thanks for your help and this great stuff
    Last edited by sebboon; Oct 21st, 2009 at 06:59 AM. Reason: minors corrections

  2. #2
    Join Date
    Oct 2009
    Posts
    6

    Default

    After deeper debugging (into the class EndpointConfigProcessor), I found that the order is 2147483647.

    So the ExceptionTranslationAdvice is called at the end...
    ...

  3. #3
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    There's really not anyway to change the order of the pointcut at the moment, and I'm not sure it's something we even want to expose. The idea is that we are using AOP as an implementation detail to intercept a specific point in the BlazeDS call chain, and then we use that hook to make the necessary callbacks to the user-provided implementations of specific interfaces such as ExceptionTranslator and MessageInterceptor.

    What are you actually trying to accomplish? I suspect there would be a way to do it without needing to change the order of the advice.
    Jeremy Grelle

    Staff Engineer, Web Products Team
    SpringSource

  4. #4
    Join Date
    Oct 2009
    Posts
    6

    Default

    Thank you Jeremy for your reply.

    I thought that the point cut order was not as high as it is in reality.

    While I was debugging my application I saw that my point cut are not in the right order. So I searched in the spring flex documentation where is set te exceptiontranslationadvice order and above all its value. I didn't found it ...

    So I thought that its value was too low....As the order is 2147483647 (max Integer) everything is all right

    The exception translation advice is called a the end and it's better like this, I'm agree with you.

    My application's trouble was due to an unexpected eclipse package refactor which didn't update the pointcut regexp...

    This mistake allowed me to deeper understand the fundation of the spring-flex engine,

    you really made a great work thank you...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •