@FunctionalInterface
public interface GuiceyConfigurationHook
GuiceyHooksRule (junit) and
UseGuiceyHooks (spock).
Hook could be registered with register() method call.
Also, could be used with GuiceyLifecycleListener (listener,
implementing hook interface is recognized and registered automatically).
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 enabling
GuiceBundle.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 DiagnosticHook could
enable guicey diagnostic reports (enabled during development with print* methods on GuiceBundle) with
system property: -Dguicey.hooks=diagnostic.
GuiceyHooksRule,
UseGuiceyHooks| Modifier and Type | Method and Description |
|---|---|
void |
configure(GuiceBundle.Builder builder)
Configuration is applied just after manual configuration (through bundle's builder in application class).
|
default void |
register()
Register hook.
|
void configure(GuiceBundle.Builder builder)
GuiceBundle.Builder contains special methods for test support:
GuiceBundle.Builder#disable(java.util.function.Predicate[])
GuiceBundle.Builder#disableExtensions(Class[])GuiceBundle.Builder#modulesOverride(com.google.inject.Module...)GuiceBundle.Builder#option(Enum, Object)).
All configuration items, registered with hook will be scoped as GuiceyConfigurationHook
instead of Application and so will be clearly distinguishable in configuration logs
(GuiceBundle.Builder#printDiagnosticInfo()).
builder - just created bundle's builderfor more informationdefault void register()