Class GuiceContainer

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Filter, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class GuiceContainer
    extends com.sun.jersey.spi.container.servlet.ServletContainer
    A Servlet or Filter for deploying root resource classes with Guice integration.

    This class must be registered using com.google.inject.servlet.ServletModule.

    This class extends ServletContainer and initiates the WebApplication with a Guice-based IoCComponentProviderFactory, GuiceComponentProviderFactory, such that instances of resource and provider classes declared and managed by Guice can be obtained.

    Guice-bound classes will be automatically registered if such classes are root resource classes or provider classes. It is not necessary to provide initialization parameters for declaring classes in the web.xml unless a mixture of Guice-bound and Jersey-managed classes is required.

    Author:
    Gili Tzabari, Paul Sandoz
    See Also:
    ServletModule, Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  GuiceContainer.ServletGuiceComponentProviderFactory  
      • Nested classes/interfaces inherited from class com.sun.jersey.spi.container.servlet.ServletContainer

        com.sun.jersey.spi.container.servlet.ServletContainer.ContextInjectableProvider<T extends java.lang.Object>
    • Field Summary

      • Fields inherited from class com.sun.jersey.spi.container.servlet.ServletContainer

        APPLICATION_CONFIG_CLASS, FEATURE_ALLOW_RAW_MANAGED_BEANS, FEATURE_FILTER_FORWARD_ON_404, GLASSFISH_DEFAULT_ERROR_PAGE_RESPONSE, JSP_TEMPLATES_BASE_PATH, PROPERTY_FILTER_CONTEXT_PATH, PROPERTY_WEB_PAGE_CONTENT_REGEX, RESOURCE_CONFIG_CLASS
    • Constructor Summary

      Constructors 
      Constructor Description
      GuiceContainer​(com.google.inject.Injector injector)
      Creates a new Injector.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.sun.jersey.api.core.ResourceConfig getDefaultResourceConfig​(java.util.Map<java.lang.String,​java.lang.Object> props, com.sun.jersey.spi.container.servlet.WebConfig webConfig)  
      com.sun.jersey.spi.container.WebApplication getWebApplication()  
      protected void initiate​(com.sun.jersey.api.core.ResourceConfig config, com.sun.jersey.spi.container.WebApplication webapp)  
      • Methods inherited from class com.sun.jersey.spi.container.servlet.ServletContainer

        configure, configure, configure, create, destroy, doFilter, doFilter, getDefaultResourceConfig, getServletContext, getStaticContentPattern, getWebConfig, init, init, init, load, reload, service, service
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
      • Methods inherited from class javax.servlet.GenericServlet

        getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, getServletName, init, log, log
      • Methods inherited from class java.lang.Object

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

      • GuiceContainer

        @Inject
        public GuiceContainer​(com.google.inject.Injector injector)
        Creates a new Injector.
        Parameters:
        injector - the Guice injector
    • Method Detail

      • getDefaultResourceConfig

        protected com.sun.jersey.api.core.ResourceConfig getDefaultResourceConfig​(java.util.Map<java.lang.String,​java.lang.Object> props,
                                                                                  com.sun.jersey.spi.container.servlet.WebConfig webConfig)
                                                                           throws javax.servlet.ServletException
        Overrides:
        getDefaultResourceConfig in class com.sun.jersey.spi.container.servlet.ServletContainer
        Throws:
        javax.servlet.ServletException
      • initiate

        protected void initiate​(com.sun.jersey.api.core.ResourceConfig config,
                                com.sun.jersey.spi.container.WebApplication webapp)
        Overrides:
        initiate in class com.sun.jersey.spi.container.servlet.ServletContainer
      • getWebApplication

        public com.sun.jersey.spi.container.WebApplication getWebApplication()