Maybe overriding modules can help you. The default level can be configured using the module AppLevel
:
public class AppModule extends AbstractModule {
@Override
public void configure() {
bind(Level.class).toInstance(Level.NORMAL);
}
}
and a specific one can be configured in a small override module:
public class FancyLevelModule extends AbstractModule {
@Override
public void configure() {
bind(Level.class).toInstance(Level.FANCY);
}
}
, AppModule
Level
config:
public static void main(String[] args) {
Injector injector =
Guice.createInjector(
Modules.override(new AppModule()).with(new FancyLevelModule())
);
System.out.println("level = " + injector.getInstance(Level.class));
}
UPDATE
. , Level
:
class Some
{
@Injected(optional = true)
private Level level = Level.NORMAL;
}
Some
. - Guice - , .