public class GuiceFeature
extends java.lang.Object
implements javax.ws.rs.core.Feature, javax.inject.Provider<org.glassfish.hk2.api.ServiceLocator>
Guice context is created first and it doesn't depend on jersey start. First of all this allow using guice in commands and second, guice is ready in time of jersey initialization and so can provide it's own instances into jersey config.
Feature must be registered in jersey before it's start:
environment.jersey().register(new GuiceFeature())
During juice context start special jersey bindings module registered
GuiceBindingsModule
, which lazily binds jersey specifc
types to guice context. This types could be used in guice only after actual integration
(this feature activation)
HK-guice bridge is activated (not bi-directional), but it's not actually required in most cases: it was
developed for cases when bean is created by HK and only need some injections from guice, but here guice
controls almost everything and prepared instance is passed to guice. But bridge may be useful together with
HK2Managed
instances.
Feature installs ru.vyarus.dropwizard.guice.module.jersey.hk2.InstallerBinder
, which is HK module.
Just like with guice (BindingInstaller)
, it asks all JerseyInstaller
to bind extensions into
HK context.
JerseyComponentProvider
,
GuiceComponentFactory
,
LazyGuiceFactory
Constructor and Description |
---|
GuiceFeature(javax.inject.Provider<com.google.inject.Injector> provider) |
Modifier and Type | Method and Description |
---|---|
boolean |
configure(javax.ws.rs.core.FeatureContext context) |
org.glassfish.hk2.api.ServiceLocator |
get() |