Announcement Announcement Module
Collapse
No announcement yet.
AOP Alliance and AspectJ Integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP Alliance and AspectJ Integration

    Hi,

    I have some packaged code that takes a org.aopalliance.intercept.MethodInvocation as an argument to a method that I want to invoke from an AspectJ joinpoint. Is there any way that I can use AspectJ and convert a org.aspectj.lang.ProceedingJoinPoint to a org.aopalliance.intercept.MethodInvocation.

    public Object checkCache(ProceedingJoinPoint joinPoint) throws Throwable {

    // want to call method below.....
    }

    public final Object invoke(MethodInvocation mi) throws Throwable {

    }

    Spring Wiring to invoke aspect:

    <aop:config>
    <aop:aspect ref="methodCacheAdvice">
    <aopointcut id="theExecutionOfSomeMethod"
    expression="execution(public * *(..))"/>
    <aop:around pointcut-ref="theExecutionOfSomeMethod" method="checkCache"/>
    </aop:aspect>
    </aop:config>

    Any help / direction appreciated.

  • #2
    Why make it so complex...

    Code:
    <aop:config>
      <aop:pointcut id="theExecutionOfSomeMethod" expression="execution(public * *(..))"/>
      <aop:advisor pointcut-ref="theExecutionOfSomeMethod" advice-ref="yourAopAllianceAdvice" />
    </aop:config>
    No need to convert one into the other...

    And please next time use [ code][/code ] tags when posting code.

    Comment


    • #3
      Thanks Marten worked a treat.

      Guess I better re-read chapter 7 of the spring reference again!

      James

      Comment


      • #4
        as with Spring Java Configuration it looks like only the AspectJ style can be used, is there an equivalent for this?
        I see a MethodInvocationAdapter in Spring Security which seems to do the job.

        Comment

        Working...
        X