A {@link javax.servlet.Servlet} or {@link Filter} for deploying root resource classes.
The following sections make reference to initialization parameters. Unless otherwise specified the initialization parameters apply to both server and filter initialization parameters.
The servlet or filter may be configured to have an initialization parameter {@value ServletProperties#JAXRS_APPLICATION_CLASS}(see {@link org.glassfish.jersey.servlet.ServletProperties#JAXRS_APPLICATION_CLASS}) and whose value is a fully qualified name of a class that implements {@link javax.ws.rs.core.Application}. The class is instantiated as a singleton component managed by the runtime, and injection may be performed (the artifacts that may be injected are limited to injectable providers registered when the servlet or filter is configured).
If the initialization parameter {@value ServletProperties#JAXRS_APPLICATION_CLASS}is not present and a initialization parameter {@value org.glassfish.jersey.server.ServerProperties#PROVIDER_PACKAGES}is present (see {@link ServerProperties#PROVIDER_PACKAGES}) a new instance of {@link ResourceConfig} with this configuration is created. The initialization parameter{@value org.glassfish.jersey.server.ServerProperties#PROVIDER_PACKAGES} MUST be set to provide one ormore package names. Each package name MUST be separated by ';'.
If none of the above resource configuration related initialization parameters are present a new instance of {@link ResourceConfig} with {@link WebAppResourcesScanner}is created. The initialization parameter {@value org.glassfish.jersey.server.ServerProperties#PROVIDER_CLASSPATH}is present (see {@link ServerProperties#PROVIDER_CLASSPATH}) MAY be set to provide one or more resource paths. Each path MUST be separated by ';'. If the initialization parameter is not present then the following resource paths are utilized: {@code "/WEB-INF/lib"} and {@code "/WEB-INF/classes"}.
All initialization parameters are added as properties of the created {@link ResourceConfig}.
A new {@link org.glassfish.jersey.server.ApplicationHandler} instance will be created and configured suchthat the following classes may be injected onto a root resource, provider and {@link javax.ws.rs.core.Application} classes using {@link javax.ws.rs.core.Context @Context} annotation:{@link HttpServletRequest}, {@link HttpServletResponse}, {@link ServletContext}, {@link javax.servlet.ServletConfig} and {@link WebConfig}. If this class is used as a Servlet then the {@link javax.servlet.ServletConfig} class maybe injected. If this class is used as a servlet filter then the {@link FilterConfig}class may be injected. {@link WebConfig} may be injected to abstractservlet or filter deployment.
Persistence units that may be injected must be configured in web.xml in the normal way plus an additional servlet parameter to enable the Jersey servlet to locate them in JNDI. E.g. with the following persistence unit configuration:
{@code persistence/widget WidgetPU }
the Jersey servlet requires an additional servlet parameter as follows:
{@code unit:WidgetPU persistence/widget }
Given the above, Jersey will inject the {@link javax.persistence.EntityManagerFactory EntityManagerFactory} foundat {@code java:comp/env/persistence/widget} in JNDI when encountering afield or parameter annotated with {@code @PersistenceUnit(unitName="WidgetPU")}.
@author Paul Sandoz
@author Pavel Bucek (pavel.bucek at oracle.com)
@author Michal Gajdos (michal.gajdos at oracle.com)
@author Libor Kramolis (libor.kramolis at oracle.com)