The difference is who instantiates the class.
@Singleton will be guice instantiated (and therefore can participate in AOP
for example), toInstance() expects an instance which is already created,
AOP is not possible for this type of binding.

--
L

On Fri, Apr 8, 2016 at 9:34 AM, Aleksey Matsarski <[email protected]>
wrote:

> What is the difference between bind.toInstance() and @Singleton? Will be
> the result - singleton for both?
>
> --
> 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 https://groups.google.com/group/google-guice.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-guice/d7ad8464-afd0-40d0-ba55-0b84afcff2c9%40googlegroups.com
> <https://groups.google.com/d/msgid/google-guice/d7ad8464-afd0-40d0-ba55-0b84afcff2c9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/CAD-udUDHCd_3%3D-mGoQRw3sbkKO0RBATSPjNy_uamXeddvz8R9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to