In some cases, a MutableProvider is pretty useful.  Not so much for
singletons, but more for provided variables.  Our specific use-case is
settings.  Consider a binding "@Named("downloadThrottleSpeed")
Provider<Integer>".  The core of the program injects it as a provider & gets
the current throttle setting.  The UI injects it as a
MutableProvider<Integer> and can set it.  Reuses the infrastructure of
providers and nicely solves the ability to inject specific settings that can
change over time.

Sam

On Fri, Jun 5, 2009 at 2:26 PM, Kevin Bourrillion <[email protected]>wrote:

> On Sun, May 24, 2009 at 10:20 AM, [email protected] <
> [email protected]> wrote:
>
>>
>> Thanks for the answer!
>>
>> I have real Singletons depending on objects that would be scoped as
>> reloadable.
>
>
> Just put them in the reloadable scope too!
>
> This scope is a sub-scope of Singleton and a super-scope of Session and
> Request, so you can't inject a reloadable-scope object into a Singleton or a
> session-scope object into a reloadable-scope one.  It's lamentable that
> Guice still won't explicitly flag that as an error; it was one of the things
> I most wished we could have made it do from the very beginning.  The scope
> containment hierarchy must be obeyed.  Of course, Provider-injection can be
> used for the pesky backward dependencies, but it's better to try to avoid
> those.
>
> I don't see how you could end up with two objects from different
> "instances" of a reloadable scope (or "configuration scope") injected into
> the same target.
>
> I strongly recommend running far away from the ideas of mutable or
> "resettable" singletons or providers.
>
>
> >
>

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