Announcement Announcement Module
Collapse
No announcement yet.
Pointcut on a class annotation whith determined value Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pointcut on a class annotation whith determined value

    I need to define a pointcut on a class annotation with determined value.
    such a thing:
    Code:
    @LogMe(LogginLevel.INFO)
    class foo{
    
    void bar()
    ...
    }
    This works for such a pointcut but on method annotation:
    Code:
    execution(@com.tosan.LogMe(com.tosan.LoggingLevel.INFO) * *(..))
    And these work for a class annotation but without any value:
    Code:
    execution(* *(..)) && within(@com.tosan.LogMe *)
    execution(* *(..)) && @within(com.tosan.LogMe)
    And these combined expressions fail:
    Code:
    execution(* *(..)) && within(@com.tosan.LogMe(com.tosan.LoggingLevel.INFO) *)
    execution(* *(..)) && within(@com.tosan.LogMe(com.tosan.LoggingLevel.INFO) ..*)
    
    execution(* *(..)) && @within(com.tosan.LogMe(com.tosan.LoggingLevel.INFO) *)
    execution(* *(..)) && @within(com.tosan.LogMe(com.tosan.LoggingLevel.INFO) ..*)
    Last edited by mjafari; Feb 5th, 2012, 10:05 AM.

  • #2
    Use if to match on annotation values:

    .. && @target(logMe) && if(logMe.value() == LogginLevel.INFO)

    but you need to use AspectJ, Spring AOP don't support the 'if' poincut designator.

    Cheers
    Last edited by chelu; Feb 7th, 2012, 04:54 AM.

    Comment

    Working...
    X