Just solved this by having the provider have an Injector dependency for HasDependencies, and then made an @Inject void initialize(Injector inj)method that uses inj.getExistingBinding(Key), which I then could then check if it was null. Ends up not being a static binding, but that makes sense because you wouldn't know if it's available or not until the whole graph is built.
It would be nice to grab an optional provider from the binder, is that a feasible feature request? - Daniel On Thursday, May 10, 2012 5:15:42 PM UTC-4, Daniel Murphy wrote: > > Is there a way to get an optional provider from a binder (same > functionality of @Inject(optional = true))? > > I have a case where I'm given an arbitrary binding annotation (I'm given > the class), and I need to grab a provider for an optionally bound type with > that binding annotation. > > Thanks, > Daniel > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-guice/-/YaoLV-UvpssJ. 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.
