久々に、 Google guice でコードを書いていて、うっかりしていることに気がついた。
インターセプタの Matchers.annotatedWith で、@Named に対する 指定をする時、
com.google.inject.name.Names の named メソッドを使うのだが、
インターセプタではなく、普通のフィールドへのバインド定義では、、
binder().bind(String.class).annotatedWith()
の中に、、、
binder().bind(String.class).annotatedWith( Names.named("A") ).toInstacne("a");
のように書くのは、アノテーションを付与する方で
com.google.inject.name.Named であろうが、javax.inject.Named であろうが、
動いている。
しかし、インターセプタの定義、
binder().bindInterceptor(Matchers.any(), Matchers.annotatedWith(Names.named("key")
インターセプトとして動かすインスタンス );
を書く場合は、@Named("key") の使用は、com.google.inject.name.Named
でなければならない。。。