public class PluginInstaller extends java.lang.Object implements FeatureInstaller, BindingInstaller
Plugin annotation into set multibinding by base class
defined in annotation.
Registered set may be later injected in code as Set<BaseType> plugins.
To use Map<String, BaseType> create new annotation, annotated with @Plugin.
Use new annotation to define plugins. It's value attribute will be used as key (this way you can use
different enums for different plugin types and not need to always write plugin interface.
| Constructor and Description |
|---|
PluginInstaller() |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(com.google.inject.Binder binder,
java.lang.Class<?> type,
boolean lazy)
Called to apply custom binding for installed feature.
|
<T> void |
manualBinding(com.google.inject.Binder binder,
java.lang.Class<T> type,
com.google.inject.Binding<T> binding)
Called for extensions, resolved from guice bindings (in user modules).
|
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 |
registerPlugin(com.google.inject.Binder binder,
java.lang.Class<?> type) |
void |
report()
Called to log registered endpoints in dropwizard log fashion.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitextensionBoundpublic 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 FeatureInstallertype - type to checkpublic void bind(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.
bind in interface BindingInstallerbinder - guice bindertype - extension classlazy - true if extension is annotated with LazyBindingpublic <T> void manualBinding(com.google.inject.Binder binder,
java.lang.Class<T> type,
com.google.inject.Binding<T> binding)
BindingInstallerBinding.getKey(), but linked bindings (LinkedKeyBinding) are
also checked for target key (LinkedKeyBinding.getLinkedKey()).
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.
manualBinding in interface BindingInstallerT - extension type, used to connect extension class with bindingbinder - guice bindertype - extension classbinding - binding declaration from guice modulefor errors reportingpublic void registerPlugin(com.google.inject.Binder binder,
java.lang.Class<?> type)
public void report()
FeatureInstallerReporter to simplify reporting.
Method may do nothing if reporting not required
report in interface FeatureInstaller