title: Spring AOP for interface and for annotated methods within it
body: <p>I have service code like this:</p>
  
  <pre><code>@Component
  public class MyService implements com.xyz.WithSession {
  
      public void someMethodWhichDoesNotNeedAutorization() {
          // code S1
      }
  
      @com.xyz.WithAuthorization
      public void someMethodWhichNeedAutorization() {
          // code S2
      }
  }
  </code></pre>
  
  <p>and aspect like this:</p>
  
  <pre><code>@Aspect
  public class MyAspect {
  
      @Before("target(com.xyz.WithSession)")
      public void adviceBeforeEveryMethodFromClassImplementingWithSession() {
          // code A1
      }
  
      @Before("target(com.xyz.WithSession) &amp;&amp; @annotation(com.xyz.WithAuthorization)")
      public void adviceBeforeWithAuthorizationMethodFromClassImplementingWithSession() {
          // code A2
      }
  </code></pre>
  
  <p>Annotation looks like:</p>
  
  <pre><code>@Retention(RetentionPolicy.RUNTIME)
  @Target(ElementType.METHOD)
  public @interface WithAuthorization{
  }
  </code></pre>
  
  <ul>
  <li>code A1 is called before code S1 -- OK</li>
  <li>code A1 is called before code S2 -- OK</li>
  <li>code A2 isn't called before code S2 -- NOT OK</li>
  </ul>
  
  <p><strong>What am I doing wrong?</strong></p>
  
  <p>Code is written in Java 7 with Spring 3.1.3.</p>
  
  <h1>Update</h1>
  
  <p>I've tried another way. I use 'Around' advice instead of 'Before' and 'After' to have access to ProceedingJoinPoint. In this advice I check with reflection whether method has annotation 'com.xyz.WithAuthorization' or not:</p>
  
  <pre><code>private boolean isAnnotated(ProceedingJoinPoint proceedingJoinPoint) {
      MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature();
      return signature.getMethod().isAnnotationPresent(com.xyz.WithAuthorization);
  }
  </code></pre>
  
  <p>My annotation has '@Retention(RetentionPolicy.RUNTIME)' but I see in debugger that annotation is missing on runtime in the method signature. So the problem still exists.</p>