Results 1 to 4 of 4

Thread: AOP Alliance and AspectJ Integration

  1. #1
    Join Date
    Feb 2007
    Location
    Dublin, Ireland
    Posts
    4

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Feb 2007
    Location
    Dublin, Ireland
    Posts
    4

    Thumbs up

    Thanks Marten worked a treat.

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

    James

  4. #4
    Join Date
    Sep 2009
    Location
    Milan, Italy
    Posts
    4

    Default

    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.

Posting Permissions

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