Package ru.vyarus.dropwizard.guice.hook
Class ConfigurationHooksSupport
java.lang.Object
ru.vyarus.dropwizard.guice.hook.ConfigurationHooksSupport
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:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intcount()Registered aliases may be used instead of full hook class name in property value.static voidLoad hooks from "guicey.hooks" system property.static voidLog registered hook aliases.static voidRegister hook for current thread.static voidregisterSystemHookAlias(String alias, Class<?> hook) Register alias hor hook, loaded from system property.static voidreset()May be called to remove improperly registered hooks (registered after context start).static Set<GuiceyConfigurationHook>run(GuiceBundle.Builder builder, StatsTracker stat) Called just after manual application configuration (in application class).
-
Field Details
-
HOOKS_PROPERTY
Guiey hooks list system property.- See Also:
-
-
Method Details
-
register
Register hook for current thread. Must be called before application initialization, otherwise will not be used at all.- Parameters:
hook- hook to register
-
registerSystemHookAlias
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
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
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 builderstat- stats tracker- Returns:
- used hooks
-
count
public static int count()- Returns:
- count of hooks registered in current thread
-