I'd use a provider method and make sure you don't cache the value anywhere.

Bob

On Fri, Mar 12, 2010 at 1:49 AM, lahnsurfer <[email protected]> wrote:

> Hello Guice users,
>
> I would like to know if there's a way to update any bindings at
> runtime. I would like to do this because i am currently using guice to
> configure a mail module i have written. The mail module reads some
> settings from a property file (like host, username, password, etc) and
> the mail module binds these settings so they can be injected. Here's
> some code:
>
> String mailHost = configuration.getString(MAIL_HOST);
>
> bind(String.class).annotatedWith(Names.named(MAIL_HOST)).toInstance(mailHost);
>
> Now i want the user to be able to change these settings at runtime
> through a preferences dialog.
>
> After the user has updated the settings i want to update the bindings
> so that all of the objects which received the settings are called with
> the new setting. Is this possible? Or do you have another idea how to
> solve this problem. Sure i could also inject the configuration itself,
> but then i am coupled to this kind of configuration.
>
> Thanks for you help!
>
> Greetings
> Tim
>
> --
> 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]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

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