Class AbstractConfigurationModule
- java.lang.Object
-
- com.google.inject.AbstractModule
-
- org.somda.sdc.common.guice.AbstractConfigurationModule
-
- All Implemented Interfaces:
com.google.inject.Module
- Direct Known Subclasses:
DefaultCommonConfigModule
public abstract class AbstractConfigurationModule extends com.google.inject.AbstractModuleUtility class for other modules to allow app configuration via Google Guice.Derive any concrete configuration module in order to override default values. Use
bind(String, Class, Object)to set values.
-
-
Constructor Summary
Constructors Constructor Description AbstractConfigurationModule()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> voidbind(String name, com.google.inject.TypeLiteral<T> typeLiteral, T value)Binds a configuration key to a value from outside.<T> voidbind(String name, Class<T> dataType, T value)Binds a configuration key to a value from outside.protected voidconfigure()Processes the default configuration.protected voidcustomConfigure()Implement this method to apply some custom configuration.protected abstract voiddefaultConfigure()Implement this method to settle your default configuration.-
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
-
-
-
-
Method Detail
-
bind
public <T> void bind(String name, Class<T> dataType, @Nullable T value)
Binds a configuration key to a value from outside.This operation can only be performed once per key. All unpopulated keys are supposed to be filled with a default value once
configure()is called by Guice.- Type Parameters:
T- type that is required by the given key.- Parameters:
name- the configuration key.dataType- the data type bound by the key (should be defined in configuration class).value- the configuration value to set.
-
bind
public <T> void bind(String name, com.google.inject.TypeLiteral<T> typeLiteral, @Nullable T value)
Binds a configuration key to a value from outside.This operation can only be performed once per key. All unpopulated keys are supposed to be filled with a default value once
configure()is called by Guice.- Type Parameters:
T- type that is required by the given key.- Parameters:
name- the configuration key.typeLiteral- the data type bound by the key (should be defined in configuration class).value- the configuration value to set.
-
configure
protected final void configure()
Processes the default configuration.This method is called by Guice to apply the configuration values.
- Overrides:
configurein classcom.google.inject.AbstractModule
-
defaultConfigure
protected abstract void defaultConfigure()
Implement this method to settle your default configuration.This is only relevant to the module that provides a certain configuration!
-
customConfigure
protected void customConfigure()
Implement this method to apply some custom configuration.This method is relevant to users that want to override default configuration values. Instead of overriding this function, it is also legit to bind values from outside the instance itself by using
bind(String, Class, Object). Always to that before an instance is processed by Guice!
-
-