On Sun, Apr 26, 2009 at 2:09 PM, charlesbos73 <[email protected]> wrote:

> I decided to give Guice a look and one of the very first sentence
> I find is this:
>
> "@Singleton indicates that the class is intended to be threadsafe"
>
> Now this is the most confusing sentence I've read in a while.
>
> Should it read:
>
> "@Singleton indicates that the class is intended to be instantiated
> only once and that this instance shall be re-used (re-injected)"
>

The Javadocs for @Singleton read, "Apply this to implementation classes when
you want only one instance (per
Injector<http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Injector.html>)
to be reused for all injections for that binding."

You pulled that sentence from, "Guice uses annotations to identify scopes.
Specify the scope for a type by applying the scope annotation to the
implementation class. As well as being functional, this annotation also
serves as documentation. For example, @Singleton indicates that the class is
intended to be threadsafe." (
http://code.google.com/p/google-guice/wiki/Scopes)

The comment makes sense in that someone who looks at the class and sees the
@Singleton annotation will consider the concurrency implications of the
scope whereas they may fail to consider them if the scope is specified
externally.

Because, really, singletons have nothing to do with thread-safety.
> Heck, there are languages that aren't multi-threaded that can
> have singletons.
>

Guice only works in Java.


> Is Guice using the term "singleton" to mean something different
> than the definition that everyone came to agree on?


No.

Bob

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to