public class JerseyProviderInstaller extends AbstractJerseyInstaller<java.lang.Object> implements BindingInstaller
Provider and register bindings in HK context.
If provider is annotated with JerseyManaged it's instance will be created by HK2, not guice.
This is important when extensions directly depends on HK beans (no way to wrap with Provider
or if it's eager extension, which instantiated by HK immediately (when hk-guice contexts not linked yet).
In some cases LazyBinding could
be an alternative to JerseyManaged
Force singleton scope for extensions, but not for beans having explicit scope annotation.
See InstallersOptions.ForceSingletonForJerseyExtensions.
Prototype annotation may be used on guice beans
to declare bean in prototype scope (prevent forced singleton).
JerseyManaged,
GuiceManaged,
LazyBindinglogger| Constructor and Description |
|---|
JerseyProviderInstaller() |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(com.google.inject.Binder binder,
java.lang.Class<?> type,
boolean lazyMarker)
Called to apply custom binding for installed feature.
|
void |
extensionBound(com.google.inject.Stage stage,
java.lang.Class<?> type)
Called after execution of one of above methods.
|
void |
install(org.glassfish.jersey.internal.inject.AbstractBinder binder,
com.google.inject.Injector injector,
java.lang.Class<java.lang.Object> type)
Called on jersey start to inject extensions into HK context.
|
<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 |
report()
Called to log registered endpoints in dropwizard log fashion.
|
bindInGuice, isForceSingleton, isJerseyExtension, isLazyoption, setOptionspublic 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 lazyMarker)
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 classlazyMarker - 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 extensionBound(com.google.inject.Stage stage,
java.lang.Class<?> type)
BindingInstallerBinder is not provided
here to avoid confusion with BindingInstaller.bind(Binder, Class, boolean).
WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.
extensionBound in interface BindingInstallerstage - stage (useful for differentiation between normal run (Stage.PRODUCTION) and report
rendering (Stage.TOOL)type - extension classpublic void install(org.glassfish.jersey.internal.inject.AbstractBinder binder,
com.google.inject.Injector injector,
java.lang.Class<java.lang.Object> type)
JerseyInstallerJerseyBinding utility for proper types binding:
it provide utilities for various jersey extensions and use special "bridges" for registration to
respect guice scopes (most of the time we not register ready instance, but factory which delegates
creation to guice).install in interface JerseyInstaller<java.lang.Object>binder - hk binderinjector - guice injectortype - extension type to registerJerseyBinding,
JerseyManagedpublic void report()
FeatureInstallerReporter to simplify reporting.
Method may do nothing if reporting not required
report in interface FeatureInstaller