This may be a bizzare question.

Threre aren't many examples of custom scopes, so I've looked at the
Guice implementation of ServletScopes.REQUEST and friends, and noticed
that they all use static class access to GuiceFilter to obtain the
object which implements the scope storage (request attributes, session
attributes, etc.)

I'm trying to write a scope that keeps track of injected objects by
Locale, where Locale is determined by my existing Guice modules, which
collude to be able to inject a Locale.

I'd like to let my LocaleScope implement its own locale-keyed scope
storage, and in its Provider's get() method, use a Provider<Locale> to
determine which locale-keyed scope storage to use.

To this end, I find myself wanting to do this:

  public static final Scope LOCALE = new Scope() {
      private Map<Locale, Map<String, Object>> cache = new
HashMap<Locale, Map<String, Object>>();
      @Inject Provider<Locale> localeProvider;

      public <T> Provider<T> scope(Key<T> key, final Provider<T>
creator) {
        final String name = key.toString();
        return new Provider<T>() {

          public T get() {
            Locale locale = getLocale();
            ....

It doesn't appear to be possible due to bootstrap issues to inject the
Locale Provider into the LOCALE scope, even though this would
eliminate one static reference that appears even in the Guice
implementation.

Does anybody have suggestions about how I can let my LOCALE Scope
object use the Guice modules to obtain a Locale Provider?

Thank you,
Leigh.

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