public class GuiceyBootstrap
extends java.lang.Object
GuiceBundle.Builder. Also, contains dropwizard bootstrap objects.
May register pure dropwizard bundles.
In contrast to main builder, guicey bundle can't:
GuiceyConfigurationHook
(because it's too late - all hooks were processed)| Constructor and Description |
|---|
GuiceyBootstrap(ConfigurationContext context,
java.util.List<GuiceyBundle> iterationBundles) |
| Modifier and Type | Method and Description |
|---|---|
io.dropwizard.Application |
application()
Application instance may be useful for complex (half manual) integrations where access for
injector is required.
|
<T extends io.dropwizard.Configuration> |
bootstrap()
Note: application is already in run phase, so it's too late to configure dropwizard bootstrap object.
|
GuiceyBootstrap |
bundles(GuiceyBundle... bundles)
Register other guicey bundles for installation.
|
GuiceyBootstrap |
disableExtensions(java.lang.Class<?>... extensions) |
GuiceyBootstrap |
disableInstallers(java.lang.Class<? extends FeatureInstaller>... installers) |
GuiceyBootstrap |
disableModules(java.lang.Class<? extends com.google.inject.Module>... modules)
Disable both usual and overriding guice modules.
|
GuiceyBootstrap |
dropwizardBundles(io.dropwizard.ConfiguredBundle... bundles)
Shortcut for dropwizard bundles registration (instead of
bootstrap().addBundle()), but with
duplicates detection and tracking in diagnostic reporting. |
GuiceyBootstrap |
extensions(java.lang.Class<?>... extensionClasses)
Bundle should not rely on auto-scan mechanism and so must declare all extensions manually
(this better declares bundle content and speed ups startup).
|
GuiceyBootstrap |
installers(java.lang.Class<? extends FeatureInstaller>... installers)
If bundle provides new installers then they must be declared here.
|
GuiceyBootstrap |
listen(GuiceyLifecycleListener... listeners)
Guicey broadcast a lot of events in order to indicate lifecycle phases
(GuiceyLifecycle).
|
GuiceyBootstrap |
modules(com.google.inject.Module... modules)
Register guice modules.
|
GuiceyBootstrap |
modulesOverride(com.google.inject.Module... modules)
Override modules (using guice
Modules.override(Module...)). |
<V,T extends java.lang.Enum & Option> |
option(T option)
Read option value.
|
public GuiceyBootstrap(ConfigurationContext context, java.util.List<GuiceyBundle> iterationBundles)
public <T extends io.dropwizard.Configuration> io.dropwizard.setup.Bootstrap<T> bootstrap()
T - configuration typepublic io.dropwizard.Application application()
Managed may access injector in it's start method by calling
InjectorLookup.getInjector(Application).
NOTE: it will work in this example, because injector access will be after injector creation. Directly inside bundle initialization method injector could not be obtained as it's not exists yet.
public <V,T extends java.lang.Enum & Option> V option(T option)
GuiceBundle.Builder.option(Enum, Object).
If value wasn't set there then default value will be returned. Null may return only if it was default value
and no new value were assigned.
Option access is tracked as option usage (all tracked data is available through
OptionsInfo).
V - option value typeT - helper type to define optionoption - option enummore options info,
options example,
options definitionpublic GuiceyBootstrap modules(com.google.inject.Module... modules)
Note that this registration appear under initialization phase and so neither configuration nor environment
objects are not available yet. If you need them for module, then you can wrap it with
DropwizardAwareModule or register modules in run phase
(inside GuiceyBundle.run(GuiceyEnvironment)).
modules - one or more guice modulesGuiceBundle.Builder.modules(com.google.inject.Module...),
DropwizardAwareModulepublic GuiceyBootstrap modulesOverride(com.google.inject.Module... modules)
Modules.override(Module...)).modules - overriding modulesGuiceBundle.Builder.modulesOverride(Module...)@SafeVarargs public final GuiceyBootstrap installers(java.lang.Class<? extends FeatureInstaller>... installers)
installers - feature installer classes to registerGuiceBundle.Builder.installers(Class[])public GuiceyBootstrap extensions(java.lang.Class<?>... extensionClasses)
NOTE: startup will fail if bean not recognized by installers.
NOTE: Don't register commands here: either enable auto scan, which will install commands automatically or register command directly to bootstrap object and dependencies will be injected to them after injector creation.
extensionClasses - extension bean classes to registerGuiceBundle.Builder.extensions(Class[])public GuiceyBootstrap bundles(GuiceyBundle... bundles)
Equal instances of the same type will be considered as duplicate.
bundles - guicey bundlesGuiceBundle.Builder.bundles(GuiceyBundle...)public GuiceyBootstrap dropwizardBundles(io.dropwizard.ConfiguredBundle... bundles)
bootstrap().addBundle()), but with
duplicates detection and tracking in diagnostic reporting. Dropwizard bundle is immediately initialized.bundles - dropwizard bundles to registerGuiceBundle.Builder.dropwizardBundles(ConfiguredBundle...)@SafeVarargs public final GuiceyBootstrap disableInstallers(java.lang.Class<? extends FeatureInstaller>... installers)
installers - feature installer types to disableGuiceBundle.Builder.disableInstallers(Class[])public final GuiceyBootstrap disableExtensions(java.lang.Class<?>... extensions)
extensions - extensions to disable (manually added, registered by bundles or with classpath scan)GuiceBundle.Builder.disableExtensions(Class[])@SafeVarargs public final GuiceyBootstrap disableModules(java.lang.Class<? extends com.google.inject.Module>... modules)
If bindings analysis is not disabled, could also disable inner (transitive) modules, but only inside normal modules.
modules - guice module types to disableGuiceBundle.Builder.disableModules(Class[])public GuiceyBootstrap listen(GuiceyLifecycleListener... listeners)
GuiceyLifecycle.BundlesInitialized.
Listener is not registered if equal listener was already registered (Set used as
listeners storage), so if you need to be sure that only one instance of some listener will be used
implement Object.equals(Object).
WARNING: don't register listeners implementing
GuiceyConfigurationHook - such registrations will be rejected
(it is too late - all hooks were already processed, but, as listener requires hooks support,
assuming it can't work without proper configuration).
listeners - guicey lifecycle listenersGuiceBundle.Builder.listen(GuiceyLifecycleListener...)