Interface BindingInstaller
-
- All Known Implementing Classes:
EagerSingletonInstaller
,JerseyProviderInstaller
,PluginInstaller
,ResourceInstaller
public interface BindingInstaller
Marker interface must be used together withFeatureInstaller
. Used for installers which requires custom bindings for extension. Note:binder.bind(type)
is not called by default for binding installer, assuming installer will specify proper binding itself.bind(Binder, Class, boolean)
called for extensions not manually bound in guicemanualBinding(Binder, Class, Binding)
called for extensions, resolved from manual guice bindingextensionBound(Stage, Class)
(Binder, Class)} is always called after one of install methods above in order to apply actions common for both registration types (usually reporting).
Install methods may be also used to restrict extension declaration only as class or bindings.
If extension is annotated with
LazyBinding
boolean hint is passed and installer must decide what to do with it (preferably support or fail, not ignore). Bindings extensions (resolved from guice modules) may not be declared as lazy (this will be detected automatically).Installer may be called multiple times if guice bindings or aop report is enabled. If required, report execution may be detected by used stage:
binder.currentStage() == Stage.TOOL
.- Since:
- 09.10.2014
- See Also:
PluginInstaller
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
bind(com.google.inject.Binder binder, java.lang.Class<?> type, boolean lazy)
Called to apply custom binding for installed feature.default void
extensionBound(com.google.inject.Stage stage, java.lang.Class<?> type)
Called after execution of one of above methods.default <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).
-
-
-
Method Detail
-
bind
void bind(com.google.inject.Binder binder, java.lang.Class<?> type, boolean lazy)
Called 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.
- Parameters:
binder
- guice bindertype
- extension classlazy
- true if extension is annotated withLazyBinding
-
manualBinding
default <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). 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()
).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.
- 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:
for errors reporting
-
extensionBound
default void extensionBound(com.google.inject.Stage stage, java.lang.Class<?> type)
Called after execution of one of above methods. Useful for reporting.Binder
is not provided here to avoid confusion withbind(Binder, Class, boolean)
.WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.
- Parameters:
stage
- stage (useful for differentiation between normal run (Stage.PRODUCTION
) and report rendering (Stage.TOOL
)type
- extension class
-
-