Class GuiceFeature

  • All Implemented Interfaces:
    javax.inject.Provider<org.glassfish.jersey.internal.inject.InjectionManager>, javax.ws.rs.core.Feature

    public class GuiceFeature
    extends java.lang.Object
    implements javax.ws.rs.core.Feature, javax.inject.Provider<org.glassfish.jersey.internal.inject.InjectionManager>
    Feature activates guice integration.

    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 guice context start special jersey bindings module registered GuiceBindingsModule, which lazily binds jersey specific types to guice context. This types could be used in guice only after actual integration (this feature activation)

    HK2-guice bridge is activated when GuiceyOptions.UseHkBridge option enabled (not bi-directional). By default, it's disabled because most cases does not require it: it was developed for cases when bean is created by HK2 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 JerseyManaged instances.

    Feature installs ru.vyarus.dropwizard.guice.module.jersey.hk2.InstallerBinder, which is HK2 module. Just like with guice (BindingInstaller), it asks all JerseyInstaller to bind extensions into HK2 context.

    Since:
    21.11.2014
    See Also:
    JerseyComponentProvider, GuiceComponentFactory, LazyGuiceFactory
    • Constructor Summary

      Constructors 
      Constructor Description
      GuiceFeature​(javax.inject.Provider<com.google.inject.Injector> provider, StatsTracker tracker, LifecycleSupport lifecycle, boolean enableBridge)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean configure​(javax.ws.rs.core.FeatureContext context)  
      org.glassfish.jersey.internal.inject.InjectionManager get()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GuiceFeature

        public GuiceFeature​(javax.inject.Provider<com.google.inject.Injector> provider,
                            StatsTracker tracker,
                            LifecycleSupport lifecycle,
                            boolean enableBridge)
    • Method Detail

      • configure

        public boolean configure​(javax.ws.rs.core.FeatureContext context)
        Specified by:
        configure in interface javax.ws.rs.core.Feature
      • get

        public org.glassfish.jersey.internal.inject.InjectionManager get()
        Specified by:
        get in interface javax.inject.Provider<org.glassfish.jersey.internal.inject.InjectionManager>