Let me try and rephrase this. This is certainly not a common case. It
is actually more complicated than sketched in my original post.
We have a multi-threaded application. Each thread runs a job, which
has its own configuration. A job may even change configuration items
at runtime. The configuration object itself is bound in a custom
thread scope. This must happen in a provider method. Static binding in
the configure method is not possible, so I cannot do something like
Names.bindProperties() either. Also, each config item would have to be
bound such that it uses the configuration object's provider in order
to get the value using the right scope.
What I can do is bind certain properties explicitly, but I just want
to have this dynamic.
@Provides
@Named("myProp")
String getMyProp(final Provider<Configuration> configuration) {
return configuration.get().get("myProp");
}
I want to be able to inject a value using e. g. @Named("myProp") and
tell Guice that it should be looked up using the configuration
object's provider without having to write a provider method for each
config item. Would it be possible to implement something that does
that? Any pointers are appreciated.
Thanks,
Reinhard