Announcement Announcement Module
Collapse
No announcement yet.
Ordering Prox Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ordering Prox

    Fellow SpringSorcerers,

    We have 2 point cuts. One that targets all of the services in our application and perform logging ( See below).

    Code:
    <aop:config>
        <aop:aspect ref="TraceLogger" order="2">
       
            <aop:pointcut id="theExecutionOfServiceMethod"
              expression="execution(* org.cc.project.*.service.*Impl.*(..))"/>
            <aop:around pointcut-ref="theExecutionOfServiceMethod"
             method="log"/>
     
        </aop:aspect>
    </aop:config>
    The other targets a subset of these services and serializes the method call on that service to a queue to be executed asynchronously (below). As you can see the point cut advisor below is applied to beans named in a particular way (ie: ending with _AsyncService).

    Code:
    <bean id="beanNameProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
     <property name="order" value="0"/>
     <property name="beanNames">
      <list>
       <value>*_AsyncService</value>
      </list>
     </property>
     <property name="interceptorNames">
      <list>
       <value>delegatorAdvice</value>
      </list>
     </property>
    </bean>
    Both are supplying the order parameter to specify which should be executed first.

    However, when the code reaches the "delegatorAdvice" which should be executed fist (per lower order number), the class name of the target is something like "$Proxy..." (since it is already proxied out by Spring), which creates an issue for us as we depend on being able to retrieve the appropriate class name of the target. If we disable the first pointcut mentiond ( TraceLogger ) everything works fine.

    Thank you.

  • #2
    The easy solution, don't mix proxy solutions either use aop:config or use the autoproxy stuff not both. Both proxy solutions are processed one by one instead of in one big go.

    Comment


    • #3
      Confirming that changing everything to "aop:config" solution solved the problem.

      Thank you Marten.

      Comment

      Working...
      X