Package ru.vyarus.dropwizard.guice.hook
Class ConfigurationHooksSupport
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.hook.ConfigurationHooksSupport
-
public final class ConfigurationHooksSupport extends java.lang.Object
Extra configuration mechanism to apply external configuration to bundle builder after manual configuration in application class.Supposed to be used for integration tests.
- Since:
- 11.04.2018
- See Also:
GuiceyConfigurationHook
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HOOKS_PROPERTY
Guiey hooks list system property.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
count()
static java.util.Map<java.lang.String,java.lang.String>
getSystemHookAliases()
Registered aliases may be used instead of full hook class name in property value.static void
loadSystemHooks()
Load hooks from "guicey.hooks" system property.static void
logRegisteredAliases()
Log registered hook aliases.static void
register(GuiceyConfigurationHook hook)
Register hook for current thread.static void
registerSystemHookAlias(java.lang.String alias, java.lang.Class<?> hook)
Register alias hor hook, loaded from system property.static void
reset()
May be called to remove improperly registered hooks (registered after context start).static java.util.Set<GuiceyConfigurationHook>
run(GuiceBundle.Builder builder)
Called just after manual application configuration (in application class).
-
-
-
Field Detail
-
HOOKS_PROPERTY
public static final java.lang.String HOOKS_PROPERTY
Guiey hooks list system property.- See Also:
- Constant Field Values
-
-
Method Detail
-
register
public static void register(GuiceyConfigurationHook hook)
Register hook for current thread. Must be called before application initialization, otherwise will not be used at all.- Parameters:
hook
- hook to register
-
registerSystemHookAlias
public static void registerSystemHookAlias(java.lang.String alias, java.lang.Class<?> hook)
Register alias hor hook, loaded from system property. After registration, alias may be used in system property value as shortcut: -Dguicey.hooks=alias,alias2,com.foo.HookFullName.- Parameters:
alias
- hook alias namehook
- hook class
-
getSystemHookAliases
public static java.util.Map<java.lang.String,java.lang.String> getSystemHookAliases()
Registered aliases may be used instead of full hook class name in property value.- Returns:
- registered system hook aliases or empty map
-
logRegisteredAliases
public static void logRegisteredAliases()
Log registered hook aliases.
-
loadSystemHooks
public static void loadSystemHooks()
Load hooks from "guicey.hooks" system property.
-
reset
public static void reset()
May be called to remove improperly registered hooks (registered after context start).
-
run
public static java.util.Set<GuiceyConfigurationHook> run(GuiceBundle.Builder builder)
Called just after manual application configuration (in application class). Could be used in tests to disable configuration items and (probably) replace them.- Parameters:
builder
- just created builder- Returns:
- used hooks
-
count
public static int count()
- Returns:
- count of hooks registered in current thread
-
-