I have an interface: InterfaceA.
I have a class: ConcreteA.
I also have two annotations: @AnnotA and @AnnotB.
I have done the following bindings:
bind(InterfaceA).annotatedWith(AnnotA).to(ConcreteA);
bind(InterfaceA).annotatedWith(AnnotB).to(ConcreteA);
Next, class ConcreteA has a constructor that takes a String
argument called hostName.
class ConcreteA
{
@Inject
public ConcreteA(@Named("hostName") hostName) {
}
... <rest of class>
}
I need code to describe the following:
If ConcretaA is using @AnnotA then bind hostName with String value of 'localhost'
If ConcreteA is using @AnnotB then bind hostName with String value of 'externalhost'
Any ideas of a solution for this?