public class ServletContainer extends FiberHttpServlet implements Filter, org.glassfish.jersey.server.spi.Container
A Servlet for deploying root resource classes that assign a fiber per request.
ServletContainer
,
Serialized FormPROP_DEBUG_BYPASS_TO_REGULAR_FJP, PROP_DISABLE_JETTY_ASYNC_FIXES, PROP_DISABLE_SYNC_EXCEPTIONS, PROP_DISABLE_SYNC_FORWARD, PROP_DISABLE_TOMCAT_ASYNC_FIXES
Constructor and Description |
---|
ServletContainer()
Create Jersey Servlet container.
|
ServletContainer(org.glassfish.jersey.server.ResourceConfig resourceConfig)
Create Jersey Servlet container.
|
ServletContainer(org.glassfish.jersey.servlet.ServletContainer sc)
Wraps a Jerset Servlet container.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called by the servlet container to indicate to a servlet that the
servlet is being taken out of service.
|
void |
doFilter(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain) |
void |
doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain filterChain)
The
doFilter method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain. |
boolean |
equals(Object obj) |
org.glassfish.jersey.server.ApplicationHandler |
getApplicationHandler() |
org.glassfish.jersey.server.ResourceConfig |
getConfiguration() |
String |
getInitParameter(String name)
Returns a
String containing the value of the named
initialization parameter, or null if the parameter does
not exist. |
Enumeration<String> |
getInitParameterNames()
Returns the names of the servlet's initialization parameters
as an
Enumeration of String objects,
or an empty Enumeration if the servlet has no
initialization parameters. |
ServletContext |
getServletContext()
Get the servlet context for the servlet or filter, depending on how this class is registered.
|
String |
getServletInfo()
Returns information about the servlet, such as
author, version, and copyright.
|
String |
getServletName()
Returns the name of this servlet instance.
|
int |
hashCode() |
void |
init()
A convenience method which can be overridden so that there's no need
to call
super.init(config) . |
void |
init(FilterConfig filterConfig)
Called by the web container to indicate to a filter that it is
being placed into service.
|
void |
init(ServletConfig config)
Called by the servlet container to indicate to a servlet that the
servlet is being placed into service.
|
void |
log(String msg)
Writes the specified message to a servlet log file, prepended by the
servlet's name.
|
void |
log(String message,
Throwable t)
Writes an explanatory message and a stack trace
for a given
Throwable exception
to the servlet log file, prepended by the servlet's name. |
void |
reload() |
void |
reload(org.glassfish.jersey.server.ResourceConfig configuration) |
protected void |
service(HttpServletRequest req,
HttpServletResponse res)
Receives standard HTTP requests from the public
service method and dispatches
them to the do XXX methods defined in
this class. |
org.glassfish.jersey.internal.util.collection.Value<Integer> |
service(URI baseUri,
URI requestUri,
HttpServletRequest request,
HttpServletResponse response)
Dispatch client requests to a resource class.
|
String |
toString() |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getStackSize, service, setStackSize
getLastModified
getServletConfig
public ServletContainer()
Create Jersey Servlet container.
public ServletContainer(org.glassfish.jersey.server.ResourceConfig resourceConfig)
Create Jersey Servlet container.
resourceConfig
- container configuration.public ServletContainer(org.glassfish.jersey.servlet.ServletContainer sc)
Wraps a Jerset Servlet container.
sc
- the servlet containerpublic void init(ServletConfig config) throws ServletException
javax.servlet.GenericServlet
Servlet.init(javax.servlet.ServletConfig)
.
This implementation stores the ServletConfig
object it receives from the servlet container for later use.
When overriding this form of the method, call
super.init(config)
.
init
in interface Servlet
init
in class FiberHttpServlet
config
- the ServletConfig
object
that contains configutation
information for this servletServletException
- if an exception occurs that
interrupts the servlet's normal
operationUnavailableException
public ServletContext getServletContext()
Get the servlet context for the servlet or filter, depending on how this class is registered.
getServletContext
in interface ServletConfig
getServletContext
in class FiberHttpServlet
ServletContext
@Suspendable protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
javax.servlet.http.HttpServlet
service
method and dispatches
them to the do
XXX methods defined in
this class. This method is an HTTP-specific version of the
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
method. There's no
need to override this method.service
in class FiberHttpServlet
req
- the HttpServletRequest
object that
contains the request the client made of
the servletres
- the HttpServletResponse
object that
contains the response the servlet returns
to the clientServletException
- if the HTTP request
cannot be handledIOException
- if an input or output error occurs
while the servlet is handling the
HTTP requestServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
public void destroy()
javax.servlet.GenericServlet
Servlet.destroy()
.public void init() throws ServletException
javax.servlet.GenericServlet
super.init(config)
.
Instead of overriding GenericServlet.init(ServletConfig)
, simply override
this method and it will be called by
GenericServlet.init(ServletConfig config)
.
The ServletConfig
object can still be retrieved via GenericServlet.getServletConfig()
.
init
in class GenericServlet
ServletException
- if an exception occurs that
interrupts the servlet's
normal operationpublic org.glassfish.jersey.internal.util.collection.Value<Integer> service(URI baseUri, URI requestUri, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
Dispatch client requests to a resource class.
baseUri
- the base URI of the request.requestUri
- the URI of the request.request
- the HttpServletRequest
object that contains the request the client made to the Web component.response
- the HttpServletResponse
object that contains the response the Web component returns to the client.value provider
.IOException
- if an input or output error occurs while the Web component is handling the HTTP request.ServletException
- if the HTTP request cannot be handled.public void init(FilterConfig filterConfig) throws ServletException
javax.servlet.Filter
The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work.
The web container cannot place the filter into service if the init method either
init
in interface Filter
ServletException
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
javax.servlet.Filter
doFilter
method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain.
The FilterChain passed in to this method allows the Filter to pass
on the request and response to the next entity in the chain.
A typical implementation of this method would follow the following pattern:
chain.doFilter()
),
doFilter
in interface Filter
IOException
ServletException
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException
IOException
ServletException
public org.glassfish.jersey.server.ResourceConfig getConfiguration()
getConfiguration
in interface org.glassfish.jersey.server.spi.Container
public void reload()
reload
in interface org.glassfish.jersey.server.spi.Container
public void reload(org.glassfish.jersey.server.ResourceConfig configuration)
reload
in interface org.glassfish.jersey.server.spi.Container
public String getInitParameter(String name)
javax.servlet.GenericServlet
String
containing the value of the named
initialization parameter, or null
if the parameter does
not exist. See ServletConfig.getInitParameter(java.lang.String)
.
This method is supplied for convenience. It gets the
value of the named parameter from the servlet's
ServletConfig
object.
getInitParameter
in interface ServletConfig
getInitParameter
in class GenericServlet
name
- a String
specifying the name
of the initialization parameterString
containing the value
of the initialization parameterpublic Enumeration<String> getInitParameterNames()
javax.servlet.GenericServlet
Enumeration
of String
objects,
or an empty Enumeration
if the servlet has no
initialization parameters. See ServletConfig.getInitParameterNames()
.
This method is supplied for convenience. It gets the
parameter names from the servlet's ServletConfig
object.
getInitParameterNames
in interface ServletConfig
getInitParameterNames
in class GenericServlet
String
objects containing the names of
the servlet's initialization parameterspublic String getServletInfo()
javax.servlet.GenericServlet
Servlet.getServletInfo()
.getServletInfo
in interface Servlet
getServletInfo
in class GenericServlet
public void log(String msg)
javax.servlet.GenericServlet
ServletContext.log(String)
.log
in class GenericServlet
msg
- a String
specifying
the message to be written to the log filepublic void log(String message, Throwable t)
javax.servlet.GenericServlet
Throwable
exception
to the servlet log file, prepended by the servlet's name.
See ServletContext.log(String, Throwable)
.log
in class GenericServlet
message
- a String
that describes
the error or exceptiont
- the java.lang.Throwable
error
or exceptionpublic String getServletName()
javax.servlet.GenericServlet
ServletConfig.getServletName()
.getServletName
in interface ServletConfig
getServletName
in class GenericServlet
public org.glassfish.jersey.server.ApplicationHandler getApplicationHandler()
getApplicationHandler
in interface org.glassfish.jersey.server.spi.Container