title: AOP with Grails
body: <p>I want to create a custom logging annotation in my Grails project.</p>
  
  <p>My code:</p>
  
  <pre><code>class MyService{
      @AuditLog
      def method1() {
          println "method1 called"
          method2()
      }
      @AuditLog
      def method2() {
          println "method2 called"
      }
  }
  </code></pre>
  
  <p>Interceptor:</p>
  
  <pre><code>class AuditLogInterceptor implements MethodInterceptor {
      @Override
      Object invoke(MethodInvocation methodInvocation) throws Throwable {
          println "${methodInvocation.method}"
          return methodInvocation.proceed();
      }
  }
  </code></pre>
  
  <p>Spring config:</p>
  
  <pre><code>aop {
      config("proxy-target-class": true) {
          pointcut(id: "auditLogInterceptorPointcut", expression: "@annotation(xxx.log.AuditLog)")
          advisor('pointcut-ref': "auditLogInterceptorPointcut", 'advice-ref': "auditLogInterceptor")
      }
  }
  
  auditLogInterceptor(AuditLogInterceptor) {}
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>public java.lang.Object xxx.MyService.method1()
  method1 called
  method2 called
  </code></pre>
  
  <p>I would like to see the annotation fire for method 2 as well. What am I missing?</p>