Open davidbyttow opened 7 years ago
Im facing a very similar issue. For me I have 2 implementations of the same interface - but I am getting the wrong implementation injected even though I am using the right name
No one has commented on this for 3+ months so Im a little discouraged
My providers are like this
@Provides
@Named("type a")
public RestUtility providesTypeARestUtility(TypeAConfiguration config) {
return new RestUtility(config);
}
@Provides
@Named("type b")
public RestUtility providesTypeBRestUtility(TypeBConfiguration config) {
return new RestUtility(config);
}
Then in my resource I want a type a injected, but when debugging I can see I got a type b!
@Inject
public ForwardingResource(@Named("type a")RestUtility restUtil) {
this.restUtil = restUtil;
}
Perhaps I'm missing something, but I noticed binding annotations (including @Named) don't work on providers. For example:
Both providers use the default non-scoped object provider. However, if I make these different types and remove the binding annotations (e..g, TestObject1, TestObject2), then the scopes are honored it works.
Binding annotations should apply to Providers.
Known issue or am I missing something?