> that. So it is very strange for me that Guice's default scope is
> "new".

Imho this is a good default because it is the safest one. Being
explicit about whether something is a singleton forces developers to
think about the consequences. It may also be more efficient for
objects that are cheap to construct.

If you want everything to be bound as a singleton but without much
pre-registration, how about using classpath scanning? There's a nice
utility class in sitebricks
(http://www.google.com/codesearch/p?hl=en#iHNmFuHrx4M/trunk/sitebricks/src/main/java/com/google/sitebricks/Classes.java&q=classes%20package:http://google-sitebricks%5C.googlecode%5C.com&sa=N&cd=1&ct=rc)
that makes this easy to do, and if your services follow a naming
pattern or implement a certain interface you could scan on that and
bind everything you find as a singleton. Quite possibly this is
horrible to Guice's developers, but it works and is easy to implement.

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