Class BaseBuilder<C extends io.dropwizard.core.Configuration,T extends BaseBuilder<C,T>>
- Type Parameters:
C- configuration typeT- builder type
- Direct Known Subclasses:
CommandRunBuilder,TestSupportBuilder
- Since:
- 20.11.2023
-
Field Summary
FieldsModifier and TypeFieldDescriptionApplication class.protected CConfiguration instance (instead of file).Configuration overrides.protected StringConfiguration file path.protected io.dropwizard.configuration.ConfigurationSourceProviderConfiguration source provider.protected final List<ConfigModifier<C>>Configuration modifiers.protected StringConfiguration overrides property prefix.protected StringRest context mapping. -
Constructor Summary
ConstructorsConstructorDescriptionBaseBuilder(Class<? extends io.dropwizard.core.Application<C>> app) Create builder. -
Method Summary
Modifier and TypeMethodDescriptionUse configuration instance instead of configuration parsing from yaml file.Must not be used ifconfig(io.dropwizard.core.Configuration)used.final TconfigModifiers(Class<? extends ConfigModifier<? extends io.dropwizard.core.Configuration>>... modifiers) Configuration modifier is an alternative for configuration override, which is limited for simple property types (for example, a collection could not be overridden).final TconfigModifiers(ConfigModifier<C>... modifiers) Configuration modifier is an alternative for configuration override, which is limited for simple property types (for example, a collection could not be overridden).configOverride(String override) Must not be used ifconfig(io.dropwizard.core.Configuration)used.configOverride(String key, String value) Must not be used ifconfig(io.dropwizard.core.Configuration)used.configOverride(String key, Supplier<String> value) Must not be used ifconfig(io.dropwizard.core.Configuration)used.configOverrides(String... overrides) Must not be used ifconfig(io.dropwizard.core.Configuration)used.configSourceProvider(io.dropwizard.configuration.ConfigurationSourceProvider provider) Must not be used ifconfig(io.dropwizard.core.Configuration)used.final Thooks(Class<? extends GuiceyConfigurationHook>... hooks) Shortcut for hooks registration (method simply immediately registers provided hooks).hooks(GuiceyConfigurationHook... hooks) Shortcut for hooks registration (method simply immediately registers provided hooks).protected io.dropwizard.testing.ConfigOverride[]prepareOverrides(String prefix) Collect configuration overrides objects.propertyPrefix(String prefix) Dropwizard stored all provided configuration overriding values as system properties with provided prefix (or "dw." by default).restMapping(String restMapping) Specifies rest mapping path.
-
Field Details
-
app
protected final Class<? extends io.dropwizard.core.Application<C extends io.dropwizard.core.Configuration>> appApplication class. -
configPath
Configuration file path. -
configSourceProvider
protected io.dropwizard.configuration.ConfigurationSourceProvider configSourceProviderConfiguration source provider. -
configOverrides
Configuration overrides. -
modifiers
Configuration modifiers. -
configObject
Configuration instance (instead of file). -
propertyPrefix
Configuration overrides property prefix. -
restMapping
Rest context mapping.
-
-
Constructor Details
-
BaseBuilder
Create builder.- Parameters:
app- application class
-
-
Method Details
-
config
Must not be used ifconfig(io.dropwizard.core.Configuration)used.- Parameters:
path- configuration file path- Returns:
- builder instance for chained calls
-
config
Use configuration instance instead of configuration parsing from yaml file. When this is used, other configuration options must not be used (they can't be used, and an error would be thrown indicating incorrect usage).- Parameters:
config- pre-initialized configuration object- Returns:
- builder instance for chained calls
-
configSourceProvider
public T configSourceProvider(@Nullable io.dropwizard.configuration.ConfigurationSourceProvider provider) Must not be used ifconfig(io.dropwizard.core.Configuration)used.- Parameters:
provider- configuration source provider- Returns:
- builder instance for chained calls
-
configOverrides
Must not be used ifconfig(io.dropwizard.core.Configuration)used.- Parameters:
overrides- config override values (in format "path: value")- Returns:
- builder instance for chained calls
- See Also:
-
configOverride
Must not be used ifconfig(io.dropwizard.core.Configuration)used.- Parameters:
override- config override value (in format "path: value")- Returns:
- builder instance for chained calls
- See Also:
-
configOverride
Must not be used ifconfig(io.dropwizard.core.Configuration)used.- Parameters:
key- configuration pathvalue- overriding value- Returns:
- builder instance for chained calls
- See Also:
-
configOverride
Must not be used ifconfig(io.dropwizard.core.Configuration)used.- Parameters:
key- configuration pathvalue- overriding value provider- Returns:
- builder instance for chained calls
-
configModifiers
Configuration modifier is an alternative for configuration override, which is limited for simple property types (for example, a collection could not be overridden).Modifier is called before application run phase. Only logger configuration is applied at this moment (and so you can't change it). Modifier would work with both yaml (
config(String)) and instance (config(io.dropwizard.core.Configuration)) based configurations.Method supposed to be used with lambdas and so limited for application configuration class. For generic configurations (based on configuration subclass or raw
Configuration) useconfigModifiers(Class[]).- Parameters:
modifiers- configuration modifiers- Returns:
- builder instance for chained calls
-
configModifiers
@SafeVarargs public final T configModifiers(Class<? extends ConfigModifier<? extends io.dropwizard.core.Configuration>>... modifiers) Configuration modifier is an alternative for configuration override, which is limited for simple property types (for example, a collection could not be overridden).Modifier is called before application run phase. Only logger configuration is applied at this moment (and so you can't change it). Modifier would work with both yaml (
config(String)) and instance (config(io.dropwizard.core.Configuration)) based configurations.Method is useful for generic modifiers (based on configuration subclass or raw
Configuration).- Parameters:
modifiers- configuration modifiers- Returns:
- builder instance for chained calls
-
propertyPrefix
Dropwizard stored all provided configuration overriding values as system properties with provided prefix (or "dw." by default). If multiple tests run concurrently, they would collide on using the same system properties. It is preferred to specify test-unique prefix.- Parameters:
prefix- configuration override properties prefix- Returns:
- builder instance for chained calls
-
hooks
Shortcut for hooks registration (method simply immediately registers provided hooks).- Parameters:
hooks- hook classes to install (nulls not allowed)- Returns:
- builder instance for chained calls
-
hooks
Shortcut for hooks registration (method simply immediately registers provided hooks).- Parameters:
hooks- hooks to install (nulls allowed)- Returns:
- builder instance for chained calls
-
prepareOverrides
Collect configuration overrides objects.- Parameters:
prefix- custom configuration overrides prefix- Returns:
- configuration overrides
-
restMapping
Specifies rest mapping path. This is the same as specifying direct config override"server.rootMapping: /something/*". Specified value would be prefixed with "/" and, if required "/*" applied at the end. So it would be correct to specifyrestMapping = "api"(actually set value would be "/api/*").This option is only intended to simplify cases when custom configuration file is not yet used in tests (usually early PoC phase). It allows you to map servlet into application root in test (because rest is no more resided in root). When used with existing configuration file, this parameter will override file definition.
- Parameters:
restMapping- rest mapping path- Returns:
- builder instance for chained calls
-