Open GoogleCodeExporter opened 9 years ago
Oh, and related, it would be nice to have an Injector.canProvide(Key) method so
you
wouldn't have to try/catch. Can we add methods to this interface, or are we
actually
concerned about breaking the code of people who may, for whatever unfathomable
reason, be implementing the Injector interface themselves?
Original comment by kevin...@gmail.com
on 15 Mar 2007 at 4:42
NoSuchProviderException, ProviderNotFoundException?
Original comment by dha...@gmail.com
on 15 Mar 2007 at 6:21
Original comment by kevin...@gmail.com
on 19 Mar 2007 at 6:33
+1. How about InjectorException?
Original comment by bslesinsky
on 28 Jun 2007 at 4:53
CreateException or somthing straightforward like that. Can't create the thing,
simple. I'd reflect what could happen not how it happens, users can read that
in the
exception message.
Original comment by robbie.v...@gmail.com
on 13 Aug 2007 at 7:33
Original comment by limpbizkit
on 30 May 2008 at 6:54
Jersey (JAX-RS implementation) needs Injector.canProvide(Key) because it tries
using
Guice on its own classes and expects it to return null if it cannot inject them.
Original comment by gili.tza...@gmail.com
on 2 Oct 2008 at 2:59
Guice 2.0 will provide this using Injector.getBinding(Key<T>), which returns
null, if
there is no binding. Otherwise you can invoke Binding.<T>getProvider().get() to
retrieve an instance.
Original comment by sven.lin...@gmail.com
on 3 Oct 2008 at 11:47
ConfigurationException is now a public RuntimeException.
Aside...
The best way to test if a Key is bound is via
Injector.getBindings().containsKey(Key).
The getBinding API has changed since Guice 1.0 to not return null. I just
updated the Javadocs. It hasn't
actually returned null for quite some time (probably right after the 1.0
snapshot was cut). This is also
documented on the Guice2 wiki: http://code.google.com/p/google-guice/wiki/Guice2
Original comment by limpbizkit
on 2 Nov 2008 at 5:21
Original issue reported on code.google.com by
kevin...@gmail.com
on 15 Mar 2007 at 4:41