Class GuiceyRunner
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.GuiceyRunner
-
public class GuiceyRunner extends java.lang.Object
Guicey run logic performed under dropwizard run phase.- Since:
- 05.08.2019
-
-
Constructor Summary
Constructors Constructor Description GuiceyRunner(ConfigurationContext context, io.dropwizard.core.Configuration configuration, io.dropwizard.core.setup.Environment environment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.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).void
createInjector(InjectorFactory injectorFactory, java.lang.Iterable<com.google.inject.Module> modules)
void
injectCommands()
Inject fields in registered commands.void
installExtensions()
Execute extensions installation (by type and instance).void
prepareModules()
Prepare guice modules for injector creation.void
runBundles()
Process run phase for guicey bundles.void
runFinished()
Run lifecycle end.
-
-
-
Constructor Detail
-
GuiceyRunner
public GuiceyRunner(ConfigurationContext context, io.dropwizard.core.Configuration configuration, io.dropwizard.core.setup.Environment environment)
-
-
Method Detail
-
runBundles
public void runBundles() throws java.lang.Exception
Process run phase for guicey bundles. Note: dropwizard bundles registered afterGuiceBundle
(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:
java.lang.Exception
- if something goes wrong
-
prepareModules
public void prepareModules()
Prepare guice modules for injector creation.
-
analyzeAndRepackageBindings
public java.lang.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, java.lang.Iterable<com.google.inject.Module> modules)
- Parameters:
injectorFactory
- configured injector factorymodules
- guice modules to use for injector
-
installExtensions
public void installExtensions()
Execute extensions installation (by type and instance).
-
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.
-
-