Class PluginInstaller
- All Implemented Interfaces:
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.
- Since:
- 08.10.2014
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled to apply custom binding for installed feature.Method used by extensions help report (GuiceBundle.Builder.printExtensionsHelp()) to show what signs this exact installer recognize so user could better understand extensions support specifics.<T> voidmanualBinding(com.google.inject.Binder binder, Class<T> type, com.google.inject.Binding<T> binding) Called for extensions, resolved from guice bindings (in user modules).booleanNOTE: consider usingru.vyarus.dropwizard.guice.module.installer.util.FeatureUtilsto simplify checks (for example, types most likely must be checks to be not abstract).voidregisterPlugin(com.google.inject.Binder binder, Class<?> type) Plugin registration.voidreport()Called to log registered endpoints in dropwizard log fashion.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ru.vyarus.dropwizard.guice.module.installer.install.binding.BindingInstaller
extensionBound
-
Constructor Details
-
PluginInstaller
public PluginInstaller()
-
-
Method Details
-
matches
Description copied from interface:FeatureInstallerNOTE: consider usingru.vyarus.dropwizard.guice.module.installer.util.FeatureUtilsto 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.
- Specified by:
matchesin interfaceFeatureInstaller- Parameters:
type- type to check- Returns:
- true if extension recognized, false otherwise
-
bind
Description copied from interface:BindingInstallerCalled to apply custom binding for installed feature. By default, all found extensions are installed asbinder.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.
- Specified by:
bindin interfaceBindingInstaller- Parameters:
binder- guice bindertype- extension classlazy- true if extension is annotated withLazyBinding
-
manualBinding
public <T> void manualBinding(com.google.inject.Binder binder, Class<T> type, com.google.inject.Binding<T> binding) Description copied from interface:BindingInstallerCalled for extensions, resolved from guice bindings (in user modules). May be used to validate binding or do some additional bindings with existing binding. Binding is detected primarily by main keyBinding.getKey(), but linked bindings (LinkedKeyBinding) are also checked for target key (LinkedKeyBinding.getLinkedKey()).LazyBindingflag 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.
- Specified by:
manualBindingin interfaceBindingInstaller- Type Parameters:
T- extension type, used to connect extension class with binding- Parameters:
binder- guice bindertype- extension classbinding- binding declaration from guice module- See Also:
-
registerPlugin
Plugin registration.- Parameters:
binder- bindertype- plugin type
-
report
public void report()Description copied from interface:FeatureInstallerCalled to log registered endpoints in dropwizard log fashion. It's important to naturally show all dynamically resolved classes to easily catch errors. UseReporterto simplify reporting.Method may do nothing if reporting not required
- Specified by:
reportin interfaceFeatureInstaller
-
getRecognizableSigns
Description copied from interface:FeatureInstallerMethod used by extensions help report (GuiceBundle.Builder.printExtensionsHelp()) to show what signs this exact installer recognize so user could better understand extensions support specifics.- Specified by:
getRecognizableSignsin interfaceFeatureInstaller- Returns:
- list of extension signs installer recognize
-