Hello.

I'd say JMX would be a good way to handle changing settings at
runtime.  If the default JVM platform mbean server [1] isn't good
enough, you can use jboss, weblogic, or something.  However, the
default one is pretty painless to use and jconsole [2] will detect if
it is running.

Logging:

If you are using java.util.logging, there is already a platform mbean
to do this in the standard JVM [3].  If using another service, you can
register your logmanager with guice-jmx [4].

Uris:
For changing the urls, this is fairly straightforward.  You can create
a class that has an @Provides method [5] that serves your URI (don't
make this @Singleton).  You can then register that with guice-jmx [4].
 If you use a Provider<URI> in your code to access the url, it calls
that Provides method each request.  In this case, it will pickup any
changes you may have made via JMX.

I hope this helps!
-Adrian
jclouds

[1] http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html
[2] http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html
[3] 
http://java.sun.com/j2se/1.5.0/docs/guide/management/overview.html#loggingmxbean
[4] 
http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/tools/jmx/Manager.html
[5] http://code.google.com/p/google-guice/wiki/ProvidesMethods

On Fri, Jul 24, 2009 at 11:43 PM, tforcram<tforc...@gmail.com> wrote:
>
> How could I use guice to change configuration dynamically at runtime?
>
> As an example, we currently use spring to change varying config params
> while the system is running.  For instance if we have a dependency on
> a server at address a.example.com (which was loaded initially through
> a property file), and we need to change that address to b.example.com
> (because there was a power outage or something) we update the
> properties file and within 5 minutes we have a thread that refreshes
> the spring context from disk (which reloads the address from the
> properties file) and everything dynamically switches.
>
> Another example would be dynamically adjusting a logger setting to
> output debug settings for a few minutes without having to restart the
> server.
>
> I understand that this introduces a lot of risk in terms of screwing
> something up, but is something like this even possible with guice?  If
> so, what would it look like or are there any examples?
>
> Thanks.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to