public final class ConfigurationContext
extends java.lang.Object
Each item is registered only once, but all registrations are tracked. Uniqueness guaranteed by type.
Support generic disabling mechanism (for items marked with DisableSupport sign). If item is disabled, but
never registered special empty item info will be created at the end of configuration.
Considered as internal api.
for details of tracked info,
for acessing collected info at runtime| Constructor and Description |
|---|
ConfigurationContext() |
| Modifier and Type | Method and Description |
|---|---|
void |
closeScope()
Clears current scope.
|
void |
disableBundle(java.lang.Class<? extends GuiceyBundle>[] bundles)
Guicey bundle manual disable registration from
GuiceBundle.Builder.disableBundles(Class[]). |
void |
disableDropwizardBundle(java.lang.Class<? extends io.dropwizard.ConfiguredBundle>[] bundles)
Guicey bundle manual disable registration from
GuiceBundle.Builder.disableBundles(Class[]). |
void |
disableExtensions(java.lang.Class<?>[] extensions)
Extension manual disable registration from
GuiceBundle.Builder.disableExtensions(Class[]). |
void |
disableInstallers(java.lang.Class<? extends FeatureInstaller>[] installers)
Installer manual disable registration from
GuiceBundle.Builder.disableInstallers(Class[])
or GuiceyBootstrap.disableInstallers(Class[]). |
void |
disableModules(java.lang.Class<? extends com.google.inject.Module>[] modules)
Guice module manual disable registration from
GuiceBundle.Builder.disableModules(Class[]). |
void |
finalizeConfiguration()
Called when context configuration is finished (but extensions installation is not finished yet).
|
io.dropwizard.setup.Bootstrap |
getBootstrap() |
io.dropwizard.setup.Bootstrap |
getBootstrapProxy()
Proxy object created on first access because of ~200ms creation overhead.
|
io.dropwizard.Configuration |
getConfiguration() |
ConfigurationTree |
getConfigurationTree() |
java.util.List<GuiceyBundle> |
getDisabledBundles()
Note: before configuration finalization this returns all actually disabled bundles and after
finalization all disables (including never registered bundles).
|
java.util.List<io.dropwizard.ConfiguredBundle> |
getDisabledDropwizardBundles() |
java.util.List<java.lang.Class<?>> |
getDisabledExtensions()
Note: before configuration finalization this returns all actually disabled extensions and after
finalization all disables (including never registered extensions).
|
java.util.List<java.lang.Class<? extends FeatureInstaller>> |
getDisabledInstallers()
Note: before configuration finalization this returns all actually disabled installers and after
finalization all disables (including never registered installers).
|
java.util.List<com.google.inject.Module> |
getDisabledModules()
Note: before configuration finalization this returns all actually disabled modules and after
finalization all disables (including never registered modules).
|
java.util.List<java.lang.Class<java.lang.Object>> |
getDisabledModuleTypes() |
java.util.List<GuiceyBundle> |
getEnabledBundles() |
java.util.List<io.dropwizard.ConfiguredBundle> |
getEnabledDropwizardBundles() |
java.util.List<java.lang.Class<?>> |
getEnabledExtensions() |
java.util.List<java.lang.Class<? extends FeatureInstaller>> |
getEnabledInstallers() |
java.util.List<com.google.inject.Module> |
getEnabledModules()
NOTE: both normal and overriding modules.
|
io.dropwizard.setup.Environment |
getEnvironment() |
ExtensionsHolder |
getExtensionsHolder() |
<T> java.util.List<T> |
getIgnoredItems(ConfigItem type) |
<T extends ItemInfoImpl> |
getInfo(java.lang.Object item) |
<T> java.util.List<T> |
getItems(ConfigItem type) |
<T> java.util.List<T> |
getItems(ConfigItem type,
java.util.function.Predicate<T> filter) |
java.util.List<com.google.inject.Module> |
getNormalModules() |
ExtensionItemInfoImpl |
getOrRegisterBindingExtension(java.lang.Class<?> extension,
java.lang.Class<? extends com.google.inject.Module> topScope)
Registration of extension detected from guice binding.
|
ExtensionItemInfoImpl |
getOrRegisterExtension(java.lang.Class<?> extension,
boolean fromScan)
Extensions classpath scan requires testing with all installers to recognize actual extensions.
|
java.util.List<com.google.inject.Module> |
getOverridingModules() |
void |
initPhaseStarted(io.dropwizard.setup.Bootstrap bootstrap) |
void |
installersResolved(java.util.List<FeatureInstaller> installers)
Called with prepared list of installers to use for extensions recognition and installation.
|
boolean |
isBundleEnabled(ItemId id)
Bundle must be disabled before it's processing, otherwise disabling will not have effect
(because bundle will be already processed and register all related items).
|
boolean |
isExtensionEnabled(java.lang.Class<?> extension) |
LifecycleSupport |
lifecycle() |
void |
openScope(ItemId scope)
Current configuration context (application, bundle or classpath scan).
|
<V,T extends java.lang.Enum & Option> |
option(T option) |
OptionsSupport |
options() |
java.util.List<GuiceyBundle> |
registerBundles(GuiceyBundle... bundles)
Usual bundle registration from
GuiceBundle.Builder.bundles(GuiceyBundle...) |
void |
registerCommands(java.util.List<java.lang.Class<io.dropwizard.cli.Command>> commands)
Register commands resolved with classpath scan.
|
void |
registerDisablePredicates(java.util.function.Predicate<ItemInfo>[] predicates)
Register disable predicates, used to disable all matched items.
|
void |
registerDropwizardBundles(io.dropwizard.ConfiguredBundle... bundles)
Direct dropwizard bundle registration from
GuiceBundle.Builder.dropwizardBundles(ConfiguredBundle...) |
void |
registerExtensions(java.lang.Class<?>... extensions)
Usual extension registration from
GuiceBundle.Builder.extensions(Class[])
or GuiceyBootstrap.extensions(Class[]). |
void |
registerInstallers(java.lang.Class<? extends FeatureInstaller>[] installers)
Usual installer registration from
GuiceBundle.Builder.installers(Class[])
or GuiceyBootstrap.installers(Class[]). |
void |
registerInstallersFromScan(java.util.List<java.lang.Class<? extends FeatureInstaller>> installers)
Register installers from classpath scan.
|
void |
registerLookupBundles(java.util.List<GuiceyBundle> bundles)
Register bundles resolved by lookup mechanism.
|
void |
registerModules(com.google.inject.Module... modules) |
void |
registerModulesOverride(com.google.inject.Module... modules) |
ItemId |
replaceContextScope(ItemId scope)
Declares possibly sub-configuration context.
|
void |
runHooks(GuiceBundle.Builder builder)
Runs all registered hooks (at the end of manual builder configuration) and fire success event.
|
void |
runPhaseStarted(io.dropwizard.Configuration configuration,
io.dropwizard.setup.Environment environment) |
void |
setDuplicatesDetector(DuplicateConfigDetector detector)
Change default duplicates detector.
|
<T extends java.lang.Enum & Option> |
setOption(T option,
java.lang.Object value) |
StatsTracker |
stat() |
public void setDuplicatesDetector(DuplicateConfigDetector detector)
detector - new policypublic void openScope(ItemId scope)
scope - scope keypublic ItemId replaceContextScope(ItemId scope)
scope - scope keypublic void closeScope()
public void registerCommands(java.util.List<java.lang.Class<io.dropwizard.cli.Command>> commands)
commands - installed commandsGuiceBundle.Builder.searchCommands()public void registerLookupBundles(java.util.List<GuiceyBundle> bundles)
GuiceyBundleLookup used as context.bundles - bundles resolved by lookup mechanismGuiceyBundleLookuppublic java.util.List<GuiceyBundle> registerBundles(GuiceyBundle... bundles)
GuiceBundle.Builder.bundles(GuiceyBundle...)
or GuiceyBootstrap.bundles(GuiceyBundle...).
Context class is set to currently processed bundle.bundles - bundles to registerpublic void disableBundle(java.lang.Class<? extends GuiceyBundle>[] bundles)
GuiceBundle.Builder.disableBundles(Class[]).bundles - modules to disablepublic java.util.List<GuiceyBundle> getEnabledBundles()
public java.util.List<GuiceyBundle> getDisabledBundles()
public boolean isBundleEnabled(ItemId id)
id - bundle idpublic void registerDropwizardBundles(io.dropwizard.ConfiguredBundle... bundles)
GuiceBundle.Builder.dropwizardBundles(ConfiguredBundle...)
or GuiceyBootstrap.dropwizardBundles(
ConfiguredBundle[]).
Context class is set to currently processed bundle.bundles - dropwizard bundlespublic void disableDropwizardBundle(java.lang.Class<? extends io.dropwizard.ConfiguredBundle>[] bundles)
GuiceBundle.Builder.disableBundles(Class[]).bundles - modules to disablepublic java.util.List<io.dropwizard.ConfiguredBundle> getEnabledDropwizardBundles()
public java.util.List<io.dropwizard.ConfiguredBundle> getDisabledDropwizardBundles()
public io.dropwizard.setup.Bootstrap getBootstrapProxy()
public void registerModules(com.google.inject.Module... modules)
modules - guice modules to registerpublic void registerModulesOverride(com.google.inject.Module... modules)
modules - overriding guice modules to registerpublic void disableModules(java.lang.Class<? extends com.google.inject.Module>[] modules)
GuiceBundle.Builder.disableModules(Class[]).modules - modules to disablepublic java.util.List<com.google.inject.Module> getEnabledModules()
public java.util.List<com.google.inject.Module> getNormalModules()
public java.util.List<com.google.inject.Module> getOverridingModules()
public java.util.List<com.google.inject.Module> getDisabledModules()
public java.util.List<java.lang.Class<java.lang.Object>> getDisabledModuleTypes()
public void registerInstallers(java.lang.Class<? extends FeatureInstaller>[] installers)
GuiceBundle.Builder.installers(Class[])
or GuiceyBootstrap.installers(Class[]).installers - installers to registerpublic void registerInstallersFromScan(java.util.List<java.lang.Class<? extends FeatureInstaller>> installers)
ClasspathScanner as context class.installers - installers found by classpath scanpublic void disableInstallers(java.lang.Class<? extends FeatureInstaller>[] installers)
GuiceBundle.Builder.disableInstallers(Class[])
or GuiceyBootstrap.disableInstallers(Class[]).installers - installers to disablepublic java.util.List<java.lang.Class<? extends FeatureInstaller>> getEnabledInstallers()
public java.util.List<java.lang.Class<? extends FeatureInstaller>> getDisabledInstallers()
public void installersResolved(java.util.List<FeatureInstaller> installers)
installers - installers to use in correct orderpublic ExtensionsHolder getExtensionsHolder()
public void registerExtensions(java.lang.Class<?>... extensions)
GuiceBundle.Builder.extensions(Class[])
or GuiceyBootstrap.extensions(Class[]).extensions - extensions to registerpublic ExtensionItemInfoImpl getOrRegisterExtension(java.lang.Class<?> extension, boolean fromScan)
extension - found extensionfromScan - true when called for extension found in classpath scan, false for manually
registered extensionpublic ExtensionItemInfoImpl getOrRegisterBindingExtension(java.lang.Class<?> extension, java.lang.Class<? extends com.google.inject.Module> topScope)
Top guice module must be used because it's the only module, known by guicey configuration model and so the only way to show it properly on configuration report. Guice report can show extensions in correct positions, if required.
extension - extension classtopScope - top module in registration modules hierarchypublic void disableExtensions(java.lang.Class<?>[] extensions)
GuiceBundle.Builder.disableExtensions(Class[]).extensions - extensions to disablepublic boolean isExtensionEnabled(java.lang.Class<?> extension)
extension - extension typepublic java.util.List<java.lang.Class<?>> getEnabledExtensions()
public java.util.List<java.lang.Class<?>> getDisabledExtensions()
public <T extends java.lang.Enum & Option> void setOption(T option, java.lang.Object value)
T - helper type to define optionoption - option enumvalue - option value (not null)public <V,T extends java.lang.Enum & Option> V option(T option)
V - value typeT - helper type to define optionoption - option enumpublic OptionsSupport options()
public void registerDisablePredicates(java.util.function.Predicate<ItemInfo>[] predicates)
After registration predicates are applied to all currently registered items to avoid registration order influence.
predicates - disable predicatespublic void runHooks(GuiceBundle.Builder builder)
builder - bundle builderpublic void initPhaseStarted(io.dropwizard.setup.Bootstrap bootstrap)
bootstrap - dropwizard bootstrap instancepublic void runPhaseStarted(io.dropwizard.Configuration configuration,
io.dropwizard.setup.Environment environment)
configuration - dropwizard configuration instanceenvironment - dropwizard environment instancepublic void finalizeConfiguration()
public <T> java.util.List<T> getItems(ConfigItem type)
T - expected items typetype - config typepublic <T> java.util.List<T> getItems(ConfigItem type, java.util.function.Predicate<T> filter)
T - expected items typetype - config typefilter - items filterpublic <T> java.util.List<T> getIgnoredItems(ConfigItem type)
T - expected items typetype - config typepublic <T extends ItemInfoImpl> T getInfo(java.lang.Object item)
T - expected container typeitem - item to get infopublic StatsTracker stat()
public LifecycleSupport lifecycle()
public io.dropwizard.setup.Bootstrap getBootstrap()
public io.dropwizard.Configuration getConfiguration()
public ConfigurationTree getConfigurationTree()
public io.dropwizard.setup.Environment getEnvironment()