Guice FAQでは、アノテーション(種類)を使用して複数のインスタンスを区別することについて説明しています。
私の質問:注釈なしでImplをインターフェイスにバインドし、注釈付きで同じインターフェイスに別のImplをバインドできますか?基本的に、私の最初のimplは、他のimplのコンテナとして機能します。
bind(SecurityAuthorizer.class).to(CompositeSecurityAuthorizer.class);
bind(SecurityAuthorizer.class)
.annotatedWith(Names.named(ComponentAuthorizer.class.getSimpleName()))
.to(ComponentAuthorizer.class).in(Singleton.class);
ボーナスの質問ですが、Names.named(..)の使用は悪い形式と見なされますか?大量のアノテーションクラスの作成を避けようとしているだけで、リファクタリングできるという利点が必要でした。