See http://code.google.com/p/google-guice/wiki/ThrowingProviders#Using_@_CheckedProvides__(new_in_Guice_3.0) and add an @Expose annotation to the method.
sam On Mon, Jan 31, 2011 at 3:57 PM, f a v <[email protected]> wrote: > Is there a way to expose a ThrowingProvider from a PrivateModule? (or, > what am I doing wrong?) > > If I try this: > > public static class FeedModule extends PrivateModule { > protected void configure() { > ThrowingProviderBinder.create(binder()) > .bind(FeedProvider.class, BbcFeed.class) > .to(WorldNewsFeedProvider.class); > > expose(new > TypeLiteral<FeedProvider<BbcFeed>>(){}).annotatedWith(WorldNews.class); > } > } > > I receive: > > 1) Could not expose() FeedProvider<BbcFeed> annotated with @WorldNews, > it must be explicitly bound. > at FeedModule.configure(FeedModule.java:37) > > But I can see the key bound in Injector.toString(): > > ProviderInstanceBinding[key=Key[type=FeedProvider<BbcFeed>, > annotation=[none]], > > source=com.google.inject.throwingproviders.ThrowingProviderBinder$SecondaryBinder.to(ThrowingProviderBinder.java:110), > scope=Scopes.NO_SCOPE, > > provider=com.google.inject.throwingproviders.ThrowingProviderBinder$SecondaryBinder$1@d18d189 > ] > > I also tried using TypeLiteral.get(...), and I get the same error. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
