Interface GuiceyConfigurationHook
-
- All Known Implementing Classes:
DiagnosticHook
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface GuiceyConfigurationHookGuicey configuration hook used to amend application configuration. Primarily intended to be used in tests withTestGuiceyAppandTestDropwizardApp(junit 5 or spock 2).Hook could be registered with
register()method call.Hooks are thread-scoped: it is assumed that registration thread is the same thread where application will start.
Hooks could be enabled with a system property "guicey.hooks". Property value must contain comma-separated list of complete hook class names. Each hook in list must have default no-args constructor. Example:
-Dguicey.hooks=com.foo.MyHook1,com.foo.MyHook2. Aliases may be assigned to simplify hooks enablingGuiceBundle.Builder.hookAlias(String, Class).Enabling hooks from system property may be used for enabling reporting or additional tooling on already compiled applications. For example, bundled
DiagnosticHookcould enable guicey diagnostic reports (enabled during development with print* methods onGuiceBundle) with system property:-Dguicey.hooks=diagnostic.- Since:
- 11.04.2018
- See Also:
TestGuiceyApp,TestDropwizardApp
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidconfigure(GuiceBundle.Builder builder)Configuration is applied just after manual configuration (through bundle's builder in application class).default voidregister()Register hook.
-
-
-
Method Detail
-
configure
void configure(GuiceBundle.Builder builder)
Configuration is applied just after manual configuration (through bundle's builder in application class).GuiceBundle.Buildercontains special methods for test support:- Generic disable:
GuiceBundle.Builder.disable(java.util.function.Predicate[]) - Direct disable* method, for example
GuiceBundle.Builder.disableExtensions(Class[]) - Guice bindings override:
GuiceBundle.Builder.modulesOverride(com.google.inject.Module...)
GuiceBundle.Builder.option(Enum, Object)).All configuration items, registered with hook will be scoped as
GuiceyConfigurationHookinstead ofApplicationand so will be clearly distinguishable in configuration logs (GuiceBundle.Builder.printDiagnosticInfo()).- Parameters:
builder- just created bundle's builder
- Generic disable:
-
register
default void register()
Register hook. Note that it must be called before guicey bundle creation, otherwise will never be called.
-
-