public class ResourceInstaller extends AbstractJerseyInstaller<java.lang.Object> implements BindingInstaller, TypeInstaller<java.lang.Object>
Path or implementing interfaces annotated with Path
(only directly implemented). Directly register instance in jersey context to force singleton.
If we register it by type, then we could use prototype beans (resource instance created on each request),
which will lead to performance overhead. To ovoid misuse, singleton resources are forced, but
not for beans having explicit scope annotation.
See InstallersOptions.ForceSingletonForJerseyExtensions.
Prototype annotation may be used to force prototype
scope on guice beans (prevent forced singleton). This may be useful to avoid providers usage and directly
inject request, response and other request specific beans. Note that jersey managed resources may use direct
injections even in singletons (as jersey will use proxies instead of direct dependencies - implicit providers).
logger| Constructor and Description |
|---|
ResourceInstaller() |
| Modifier and Type | Method and Description |
|---|---|
void |
bindExtension(com.google.inject.Binder binder,
java.lang.Class<?> type,
boolean lazyMarker)
Called to apply custom binding for installed feature.
|
<T> void |
checkBinding(com.google.inject.Binder binder,
java.lang.Class<T> type,
com.google.inject.Binding<T> manualBinding)
Called for extensions, resolved from guice bindings (in user modules).
|
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.
|
void |
install(io.dropwizard.setup.Environment environment,
java.lang.Class<java.lang.Object> type) |
void |
installBinding(com.google.inject.Binder binder,
java.lang.Class<?> type)
Called after execution of one of above methods.
|
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 FeatureInstaller<java.lang.Object>type - type to checkpublic void bindExtension(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.
bindExtension in interface BindingInstallerbinder - guice bindertype - extension classlazyMarker - true if extension is annotated with LazyBindingpublic <T> void checkBinding(com.google.inject.Binder binder,
java.lang.Class<T> type,
com.google.inject.Binding<T> manualBinding)
BindingInstaller
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.
checkBinding in interface BindingInstallerT - extension type, used to connect extension class with bindingbinder - guice bindertype - extension classmanualBinding - binding declaration from guice modulefor errors reportingpublic void installBinding(com.google.inject.Binder binder,
java.lang.Class<?> type)
BindingInstallerWARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.
installBinding in interface BindingInstallerbinder - guice bindertype - extension classpublic void install(io.dropwizard.setup.Environment environment,
java.lang.Class<java.lang.Object> type)
install in interface TypeInstaller<java.lang.Object>environment - environment objecttype - extension typepublic 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<java.lang.Object>