Results 1 to 3 of 3

Thread: Advice not executed when method is invoked within same interface

  1. #1

    Default Advice not executed when method is invoked within same interface

    I have implemented an aspect that advices a an interface implementation method. Method is adviced as expected when it it is invoked from another service but it is not when it is directly called from another method declared in the same interface.

    Aspect is declared with the following advice rule:

    @Around("execution(* package.interface.method(..)) && args(parameter,..)")

    If I invoke interface.method from another interface, the advice is executed. If I invoke interface.method from interface.method2, then it is not.

    I've tried enabling CGLIB2 proxys getting the same behaviour.

    Is anything wrong with the pointcut expressiong I've declared?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I have implemented an aspect that advices a an interface implementation method. Method is adviced as expected when it it is invoked from another service but it is not when it is directly called from another method declared in the same interface.
    Which is as expected. Spring uses proxies so only method calls into the object can be intercepted. If you want more use loadtime or compile time weaving.
    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

    Red face

    Thank you very much. It was obvious...

Posting Permissions

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