public final class GuiceBundle
extends java.lang.Object
implements io.dropwizard.ConfiguredBundle<io.dropwizard.Configuration>
ConfigurationAwareModule).
You can use auto scan to automatically install features. To enable auto scan you must configure package (or
packages) to search in. To know all supported features look
FeatureInstaller implementations. Installers are
extendable mechanism: they are resolved by scanning classpath, so you can add new installers in your code and
classpath scanning will find them and activate. Also, installers could be disabled (for example, if you want to
replace existing installer, you will disable it in builder and implement your own - auto scan will find it and
activate).
Any class may be hidden from auto scanning with @InvisibleForScanner annotation.
Commands may use injection too, but only fields injection. You can register command manually and their fields will be injected or you can activate auto scan for commands in builder (disabled by default). If auto scan for commands enabled, they will be instantiated with default no-arg constructor.
Resources are registered using jersey integration module. GuiceFilter is registered for both contexts to provide request and session scopes support.
Lifecycle:
GuiceyBundle lookup with registered GuiceyBundleLookupProject was originally inspired by dropwizard-guice project. And because of this, project name was changed to dropwizard-guicey.
for configuratio diagnostic| Modifier and Type | Class and Description |
|---|---|
static class |
GuiceBundle.Builder
Builder encapsulates bundle configuration options.
|
| Modifier and Type | Method and Description |
|---|---|
static GuiceBundle.Builder |
builder() |
com.google.inject.Injector |
getInjector()
Note that injector could be accessed statically anywhere with
InjectorLookup.getInjector(io.dropwizard.Application). |
void |
initialize(io.dropwizard.setup.Bootstrap bootstrap) |
void |
run(io.dropwizard.Configuration configuration,
io.dropwizard.setup.Environment environment) |
public void initialize(io.dropwizard.setup.Bootstrap bootstrap)
initialize in interface io.dropwizard.ConfiguredBundle<io.dropwizard.Configuration>public void run(io.dropwizard.Configuration configuration,
io.dropwizard.setup.Environment environment)
throws java.lang.Exception
run in interface io.dropwizard.ConfiguredBundle<io.dropwizard.Configuration>java.lang.Exceptionpublic com.google.inject.Injector getInjector()
InjectorLookup.getInjector(io.dropwizard.Application).java.lang.IllegalStateException - if injector is not yet createdpublic static GuiceBundle.Builder builder()