public class JerseyProviderInstaller extends java.lang.Object implements FeatureInstaller<java.lang.Object>, BindingInstaller, JerseyInstaller<java.lang.Object>
@javax.ws.rs.ext.Provider and register bindings in HK context.
If provider is annotated with HK2Managed 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 HK2Managed
HK2Managed,
LazyBinding| Constructor and Description |
|---|
JerseyProviderInstaller() |
| Modifier and Type | Method and Description |
|---|---|
void |
install(org.glassfish.hk2.utilities.binding.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 |
install(com.google.inject.Binder binder,
java.lang.Class<? extends T> type,
boolean lazy)
Called to apply custom binding for installed feature.
|
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 <T> void install(com.google.inject.Binder binder,
java.lang.Class<? extends T> type,
boolean lazy)
BindingInstallerbinder.install(type) by default, so
implement it only if some custom binding required.install in interface BindingInstallerT - plugin type (used just to define strict hierarchy and simplify binding)binder - guice bindertype - extension classlazy - true if extension is annotated with @LazyBindingpublic void install(org.glassfish.hk2.utilities.binding.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,
HK2Managedpublic void report()
FeatureInstallerReporter to simplify reporting.
Method may do nothing if reporting not required
report in interface FeatureInstaller<java.lang.Object>