Announcement Announcement Module
Collapse
No announcement yet.
Custom pointcut isn't checked for classes with @Transactional annotated methods Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom pointcut isn't checked for classes with @Transactional annotated methods

    I have a custom PointcutAdvisor (extends StaticMethodMatcherPointcutAdvisor) which implements that implements it' matches() method to match all methods that implement a custom annotation (@Audited).

    My pointcut was not being triggered for certain methods that I had annotated with the @Audited method and mu debugging led me to print out all the Classes/methods that were being passed to my pointcut matches() method.

    looking at the results, i quickly saw that all of my classes which had @Transactional annotation on at least one method were not being passed to the pointcut matches() method for matching.

    I feels like it must be something to do with the proxying of the @Transactional classes, but certainly unexpected behaviour.

    Any ideas?

    Thanks

  • #2
    You get the proxied instance, instead of the actual underlying instance. Use the class utilities provided by spring to check if a certain annotation is present.

    Comment


    • #3
      Thanks for the response.

      Which utility classes are you referring to. AopUtils/ClassUtils?

      But the
      Code:
      matches(Method method, Class<?> clazz)
      executes at load time and thus doesn't take an instance of the class being checked for the advice.

      It seems like the spring context loader should retrieve the pro xy target class an pass that to the matches() method.

      Comment

      Working...
      X