title: Guice Method Interceptor Not Working
body: <p>Annotation</p>
  
  <pre><code>@Retention(RetentionPolicy.RUNTIME)
  @Target({ ElementType.METHOD})
  public @interface PublishMetric {
  }
  </code></pre>
  
  <p>Interceptor</p>
  
  <pre><code>public class PublishMetricInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
      System.out.println("invoked");
      return methodInvocation.proceed();
    }
  }
  </code></pre>
  
  <p>Guice Module</p>
  
  <pre><code>public class MetricsModule extends AbstractModule {
    @Override
    protected void configure() {
      bindInterceptor(any(), annotatedWith(PublishMetric.class), new PublishMetricInterceptor());
    }
  
    @Provides
    @Singleton
    public Dummy getDummy(Client client) {
      return new Dummy(client);
    }
  }
  </code></pre>
  
  <p>Usage</p>
  
  <pre><code>public class Dummy {
    private final Client client;
  
    @Inject
    public Dummy(final Client client) {
      this.client = client;
    }
  
    @PublishMetric
    public String something() {
      System.out.println("something");
    }
  }
  </code></pre>
  
  <p>I am not sure why this interceptor is not working.
  Guice AOP Wiki states that</p>
  
  <blockquote>
    <p>Instances must be created by Guice by an @Inject-annotated or no-argument constructor It is not possible to use method interception on instances that aren't constructed by Guice.</p>
  </blockquote>
  
  <p>Does using @Provides annotation to create new Object considered an instance created by Guice?</p>