ThrowingProviders In google/guice
You must have annotatedWith
even though the actual classes (BbcFeed.class, CnnFeed.class) are bind to different providers as follows:
public static class FeedModule extends AbstractModule { protected void configure() { ThrowingProviderBinder.create(binder()) .bind(FeedProvider.class, BbcFeed.class) .annotatedWith(WorldNews.class) .to(WorldNewsFeedProvider.class) .in(HourlyScoped.class); ThrowingProviderBinder.create(binder()) .bind(FeedProvider.class, CnnFeed.class) .annotatedWith(Sports.class) .to(SportsFeedProvider.class) .in(QuarterHourlyScoped.class); } }
from ThrowingProviders · google/guice Wiki · GitHub
Because we need both FeedProvider.class
and Sports.class
for the key of the guice object management.
guice/ThrowingProviderBinder.java at master · google/guice · GitHub