I am using Guice 3.0. I have used Names.bindProperties() to bind a property file key and values. However, my requirement is that, at run time if i change the property value for a Named key, it should be bound automatically through a Scheduler or some job which is running at pre-defined interval. Is that possible? I could not find any post for the same. Any help is appreciated.
Asked
Active
Viewed 52 times
0
-
2I have used Provider to achieve this. But looking at any other option available to do this. – PlanetSaro Jan 02 '15 at 09:59
-
Not 100% sure I understand without some sample code to illustrate the problem. However, if you have some runtime dependency that affects the objects you should get from Guice, sounds like maybe an assisted injection factory would work well. The factory could be called with the current runtime parameter. – The111 Jan 05 '15 at 05:10
-
I think the Provider approach is your best bet, with a default scope. Guice is designed to construct a static object graph, not a dynamic graph. But I can see there are situations where you would want dynamic properties (properties from JNDI, for example). This would, of course, be prone to errors as developers are likely to cache these properties in long living instances. – Isaiah van der Elst Jan 10 '15 at 00:01