Hi,

Can someone please clarify why the following code yields different
results?

1) Scopes.SINGLETON approach:

-----------
binder.bind(Key.get(PermanentRedirect.class,
Names.named("RedirectMain"))).to(PermanentRedirect.class).in(Scopes.SINGLETON);
binder.bind(Key.get(PermanentRedirect.class,
Names.named("RedirectWallpapers"))).to(PermanentRedirect.class).in(Scopes.SINGLETON);
[...]
Servlets.configure().filters().filterRegex("/main/gallery/
*").through(Key.get(PermanentRedirect.class,
Names.named("RedirectGallery")), redirectGallery);
[...]
class PermanentRedirect not marked up using @Singleton
-----------

The main point here is that I've got multiple singletons bound against
different Keys.

2) @Singleton approach:

-----------
binder.bind(Key.get(PermanentRedirect.class,
Names.named("RedirectMain"))).to(PermanentRedirect.class);
binder.bind(Key.get(PermanentRedirect.class,
Names.named("RedirectWallpapers"))).to(PermanentRedirect.class);
[...]
Servlets.configure().filters().filterRegex("/main/gallery/
*").through(Key.get(PermanentRedirect.class,
Names.named("RedirectGallery")), redirectGallery);
[...]
class Permanent is marked up using @Singleton
-----------

I am expecting both approaches to yield the same result. In actuality,
the @Singleton approach yields the same instance regardless of the
Key...

Thank you,
Gili
--~--~---------~--~----~------------~-------~--~----~
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