Suppose I have the following classes defined:
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){}
}
Additionally in one of my Guice modules I have the foollowing bindings:
bind(A.class).annotatedWith(Names.named("a1")).to(A1.class);
bind(A.class).annotatedWith(Names.named("a2")).to(A2.class);
Now I need to create a ServletModule that defines two instances of "XServlet" with different arguments. For "/x" pattern I want it to use whatever is bound to A.class annotated with "a1", and for "/y" pattern whatever is bound to A.class and annotated with "a2". Something like:
serve("/x").with(???);
serve("/y").with(???);
What should be there instead of '???'? Is it possible at all?