Class GuiceyRunner

java.lang.Object
ru.vyarus.dropwizard.guice.module.GuiceyRunner

public class GuiceyRunner extends Object
Guicey run logic performed under dropwizard run phase.
Since:
05.08.2019
  • Constructor Details

    • GuiceyRunner

      public GuiceyRunner(ConfigurationContext context, io.dropwizard.core.Configuration configuration, io.dropwizard.core.setup.Environment environment)
      Create runner.
      Parameters:
      context - configuration context
      configuration - configuration
      environment - environment
  • Method Details

    • runBundles

      public void runBundles() throws Exception
      Process run phase for guicey bundles. Note: dropwizard bundles registered after GuiceBundle (or within it) will be processed after that point (because they will be registered after guice bundle and so dropwizard will call their run methods after guice bundle's run).
      Throws:
      Exception - if something goes wrong
    • registerExtensions

      public void registerExtensions()
      Extensions could be registered in run phase too. Auto scan was performed under configuration phase, but without registration (only recognition) - now register all extensions.
    • prepareModules

      public void prepareModules()
      Prepare guice modules for injector creation.
    • analyzeAndRepackageBindings

      public Iterable<com.google.inject.Module> analyzeAndRepackageBindings()
      If configuration from guice bindings is enabled, configured guice modules will be repackaged in order to resolve all configured bindings (and filter disabled bindings to simulate common extensions disable behaviour).

      Note that analysis step use guice elements SPI, which guice will use in any case. And to avoid duplicate work on injector creation, analyzed elements are packaged into synthetic guice module and passed to injector instead of original modules.

      After bindings analysis all extensions are finally registered and entire configuration info is finalized.

      When bindings configuration is disabled (with GuiceyOptions.AnalyzeGuiceModules), no modules repackaging is applied (exact legacy guicey behavior). It may also be useful to disable feature to check for side effects.

      Returns:
      modules to use
    • createInjector

      public void createInjector(InjectorFactory injectorFactory, Iterable<com.google.inject.Module> modules)
      Parameters:
      injectorFactory - configured injector factory
      modules - guice modules to use for injector
    • installExtensions

      public void installExtensions()
      Execute extensions installation (by type and instance).
    • injectApplication

      public void injectApplication()
      Inject application fields (to use in run method).
    • injectCommands

      public void injectCommands()
      Inject fields in registered commands. This step is actually required only if currently executed dropwizard command require such injections.
    • runFinished

      public void runFinished()
      Run lifecycle end.