On 30 Jul 2013, at 19:17, Ryan Golbeck wrote:
> At https://code.google.com/p/google-guice/wiki/Injections it says toInstance
> bindings are injected when the injector is created. In some cases I'm
> binding an instance that's already been injected or initialized in another
> manner and guice is overwriting the previous values when it sets up the
> injector.
>
> Is there anyway to prevent a toInstance binding from being injected?
There's no way to disable this for all toInstance bindings, but you can use a
provider binding with the "Providers.of" utility method to hide the instance
from Guice so it isn't automatically injected:
bind( Some.class ).toProvider( Providers.of( myInstance ) );
http://google-guice.googlecode.com/git/javadoc/com/google/inject/util/Providers.html#of(T)
> Thanks,
> -ryan
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.