C - configuration typepublic abstract class DropwizardAwareModule<C extends io.dropwizard.Configuration> extends com.google.inject.AbstractModule implements EnvironmentAwareModule, BootstrapAwareModule<C>, ConfigurationAwareModule<C>, ConfigurationTreeAwareModule, OptionsAwareModule
| Constructor and Description |
|---|
DropwizardAwareModule() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
appPackage() |
protected io.dropwizard.setup.Bootstrap<C> |
bootstrap() |
protected C |
configuration() |
<T,K extends T> |
configuration(java.lang.Class<T> type)
May be used to access unique sub configuration object.
|
<T> T |
configuration(java.lang.String yamlPath)
May be used to access current configuration value by exact path.
|
<T> java.util.List<? extends T> |
configurations(java.lang.Class<T> type)
IMPORTANT: method semantic is different from
configuration(Class), which use direct class
declaration match, whereas this method searches by all assignable types. |
protected ConfigurationTree |
configurationTree()
Raw configuration introspection info.
|
protected io.dropwizard.setup.Environment |
environment() |
protected Options |
options() |
void |
setBootstrap(io.dropwizard.setup.Bootstrap<C> bootstrap)
Method will be called just before injector initialization.
|
void |
setConfiguration(C configuration)
Method will be called just before injector initialization.
|
void |
setConfigurationTree(ConfigurationTree configurationTree)
Mathod will be called just before injector initialization.
|
void |
setEnvironment(io.dropwizard.setup.Environment environment)
Method will be called just before injector initialization.
|
void |
setOptions(Options options)
Method will be called just before injector initialization.
|
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBindingpublic void setConfiguration(C configuration)
ConfigurationAwareModulesetConfiguration in interface ConfigurationAwareModule<C extends io.dropwizard.Configuration>configuration - configuration objectpublic void setBootstrap(io.dropwizard.setup.Bootstrap<C> bootstrap)
BootstrapAwareModulesetBootstrap in interface BootstrapAwareModule<C extends io.dropwizard.Configuration>bootstrap - bootstrap objectpublic void setEnvironment(io.dropwizard.setup.Environment environment)
EnvironmentAwareModulesetEnvironment in interface EnvironmentAwareModuleenvironment - environment objectpublic void setOptions(Options options)
OptionsAwareModulesetOptions in interface OptionsAwareModuleoptions - options objectpublic void setConfigurationTree(ConfigurationTree configurationTree)
ConfigurationTreeAwareModulesetConfigurationTree in interface ConfigurationTreeAwareModuleconfigurationTree - introspected configuration objectprotected io.dropwizard.setup.Bootstrap<C> bootstrap()
protected C configuration()
public <T> T configuration(java.lang.String yamlPath)
new X("sub.config.path").T - value typeyamlPath - target value yaml pathfor custom configuration searchespublic <T,K extends T> K configuration(java.lang.Class<T> type)
configuration(XConf.class) == <instance of XConf or null>.
Note that uniqueness is checked by declaration class:
class Config extends Configuration {
Sub sub;
SubExt ext; // SubExt extends Sub
}
are unique declarations (declaration of the same type never appears in configuration on any level).
configuration(Sub.class) == sub and configuration(SubExt.class) == ext.
Example of accessing server config from dropwizard configuration:
configuration(ServerFactory.class) == <DefaultServerFactory> (or SimpleServerFactory)
(see dropwizard Configuration class).
T - declaration typeK - required value type (may be the same or extending type)type - target configuration declaration typefor custom configuration searchespublic <T> java.util.List<? extends T> configurations(java.lang.Class<T> type)
configuration(Class), which use direct class
declaration match, whereas this method searches by all assignable types.
class Config extends Configuration {
Sub sub;
SubExt ext; // SubExt extends Sub
}
configurations(Sub.class) == [sub, ext], but configurations(SubExt.class) == [ext].
Useful when multiple sub configuration objects could be used and all of them are required in some universal module.
Note: only custom types may be used (sub configuration objects), not Integer, Boolean, List, etc.
T - value typetype - target configuration typefor custom configuration searchesprotected ConfigurationTree configurationTree()
Note that configuration is analyzed using jackson serialization api, so not all configured properties could be visible (when property getter is not exists or field not annotated).
Returned object contains all resolved configuration paths. Any path element could be traversed like a tree. See find* and value* methods as an examples of how stored paths could be traversed.
for configuration introspection details,
for available guice configuration bindingsprotected io.dropwizard.setup.Environment environment()
protected java.lang.String appPackage()
protected Options options()