Class ConfigurationHooksSupport

java.lang.Object
ru.vyarus.dropwizard.guice.hook.ConfigurationHooksSupport

public final class ConfigurationHooksSupport extends 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:
  • Field Details

  • Method Details

    • 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(String alias, 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 name
      hook - hook class
    • getSystemHookAliases

      public static Map<String,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 Set<GuiceyConfigurationHook> run(GuiceBundle.Builder builder, StatsTracker stat)
      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
      stat - stats tracker
      Returns:
      used hooks
    • count

      public static int count()
      Returns:
      count of hooks registered in current thread