public class EagerSingletonInstaller extends java.lang.Object implements FeatureInstaller<java.lang.Object>, BindingInstaller
@EagerSingleton annotation and register them in guice context.
This may be useful for outstanding classes (not injected by other beans and so not registered with guice.
Normally such classes must be manually registered, but using @EagerSingleton annotation allows
to register them automatically.
Moreover, even in DEVELOPMENT stage instance will be requested, which makes class suitable
for initialization logic.| Constructor and Description |
|---|
EagerSingletonInstaller() |
| Modifier and Type | Method and Description |
|---|---|
void |
bindExtension(com.google.inject.Binder binder,
java.lang.Class<?> type,
boolean lazy)
Called to apply custom binding for installed feature.
|
<T> void |
checkBinding(com.google.inject.Binder binder,
java.lang.Class<T> type,
com.google.inject.Binding<T> manualBinding)
Called for extensions, resolved from guice bindings (in user modules).
|
void |
installBinding(com.google.inject.Binder binder,
java.lang.Class<?> type)
Called after execution of one of above methods.
|
boolean |
matches(java.lang.Class<?> type)
NOTE: consider using
ru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils to simplify checks
(for example, types most likely must be checks to be not abstract). |
void |
report()
Called to log registered endpoints in dropwizard log fashion.
|
public boolean matches(java.lang.Class<?> type)
FeatureInstallerru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils to simplify checks
(for example, types most likely must be checks to be not abstract).
When type accepted by any extension it's registered in guice module.
matches in interface FeatureInstaller<java.lang.Object>type - type to checkpublic void bindExtension(com.google.inject.Binder binder,
java.lang.Class<?> type,
boolean lazy)
BindingInstallerbinder.bind(type). This method will be called
instead of default registration.
Called only for non binding extensions (extensions that are not already bound in guice module.
WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.
bindExtension in interface BindingInstallerbinder - guice bindertype - extension classlazy - true if extension is annotated with LazyBindingpublic <T> void checkBinding(com.google.inject.Binder binder,
java.lang.Class<T> type,
com.google.inject.Binding<T> manualBinding)
BindingInstaller
LazyBinding flag is not used here because guicey will automatically throw an error if existing binding
is annotated as lazy binding (which don't makes any sense).
WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.
checkBinding in interface BindingInstallerT - extension type, used to connect extension class with bindingbinder - guice bindertype - extension classmanualBinding - binding declaration from guice modulefor errors reportingpublic void installBinding(com.google.inject.Binder binder,
java.lang.Class<?> type)
BindingInstallerWARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.
installBinding in interface BindingInstallerbinder - guice bindertype - extension classpublic void report()
FeatureInstallerReporter to simplify reporting.
Method may do nothing if reporting not required
report in interface FeatureInstaller<java.lang.Object>