次のクラスが定義されているとします。
public interface A {}
public class A1 implements A {}
public class A2 implements A {}
public class XServlet<T extends A> extends HttpServlet {
public XServlet(T delegate){}
}
さらに、Guice モジュールの 1 つに、愚かなバインディングがあります。
bind(A.class).annotatedWith(Names.named("a1")).to(A1.class);
bind(A.class).annotatedWith(Names.named("a2")).to(A2.class);
ここで、「XServlet」の 2 つのインスタンスを異なる引数で定義する ServletModule を作成する必要があります。「/x」パターンでは、「a1」で注釈が付けられた A.class にバインドされているものを使用し、「/y」パターンでは、A.class にバインドされ、「a2」で注釈が付けられているものを使用します。何かのようなもの:
serve("/x").with(???);
serve("/y").with(???);
「???」の代わりに何が必要ですか? それはまったく可能ですか?