title: Spring AOP Pointcut expression for custom annotation in subclass
body: <p>I am working on a logging aspect which need to intercept all the classes and methods annotated with a custom annotation.</p>
  
  <p>Below is custom annotation class which can be annotated on class and methods:</p>
  
  <pre><code>@Documented
  @Inherited
  @Retention(RetentionPolicy.RUNTIME)
  @Target({ElementType.TYPE, ElementType.METHOD})
  public @interface Loggable {
      LogLevel value();
  }
  </code></pre>
  
  <p>I am using these pointcut expressions to intercept methods and classes with annotation <code>@Loggable</code>, <strong>which is working for all the simple classes but does not work for classses which extend or implement.</strong></p>
  
  <pre><code>//Works for annotation @Loggable on class level
  @Pointcut("execution(* *(..)) &amp;&amp;  within(@com.logger.Loggable *)")
  public void classAnnotationLogger() {
  }
  
  //Working for methods annotated with @Loggable
  @Before(value = "@annotation(loggable)", argNames = "jp, loggable")
  public void logBeforeAdvice(JoinPoint jp, Loggable loggable) {
    ..
    ..
  }
  </code></pre>
  
  <p>Below is code for super class</p>
  
  <pre><code>@Component
  @Loggable(LogLevel.INFO)
  public abstract class Processor{
    public void process(){
        readProcess();
    }
  
    public abstract void readProcess();
  }
  </code></pre>
  
  <p>Below is code for subclass</p>
  
  <pre><code>@Service
  @Loggable(LogLevel.INFO)
  public class MyServiceProcessor extends Processor {
  
    @Override
    public void readProcess(){
      ...
      ...
    }
  }
  </code></pre>
  
  <p>In the application <code>readProcess()</code> is called by doing</p>
  
  <pre><code>Processor processor = applicationContext.getBean(MyServiceProcessor.class);
  processor.readProcess();
  </code></pre>
  
  <p>Even though I have <code>@Loggable</code> on <code>Processor</code> and <code>MyServiceProcessor</code>, when <code>readProcess</code> is called the advice is not being invoked.</p>
  
  <p>But advice is invoked for <code>process()</code> and not <code>readProcess</code>.</p>
  
  <p>How do I write the pointcut expression which also intercepts the call to any subclass methods, when annotation <code>@Logabble</code> is applied on any class or method?</p>