Package org.glassfish.grizzly.servlet
Class ServletHandler
- java.lang.Object
-
- org.glassfish.grizzly.http.server.HttpHandler
-
- org.glassfish.grizzly.servlet.ServletHandler
-
public class ServletHandler extends org.glassfish.grizzly.http.server.HttpHandlerHttpHandler implementation that provides an entry point for processing a Servlet request.- Author:
- Jeanfrancois Arcand
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassLoaderclassLoaderprotected ExpectationHandlerexpectationHandlerprotected FilterChainFactoryfilterChainFactoryprotected booleaninitializeInitialize theServletContextprotected Map<String,Object>propertiesHolder for our configured properties.protected Class<? extends jakarta.servlet.Servlet>servletClassprotected StringservletClassNameprotected jakarta.servlet.ServletservletInstance
-
Constructor Summary
Constructors Modifier Constructor Description protectedServletHandler(ServletConfigImpl servletConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconfigureServletEnv()Configure theWebappContextandServletConfigImplvoidcustomizeErrorPage(org.glassfish.grizzly.http.server.Response response, String message, int errorCode, Throwable t)Customize the error page returned to the client.voiddestroy()Destroy this Servlet and its associatedServletContextListenerprotected voiddoServletService(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response)ClassLoadergetClassLoader()StringgetContextPath()Returns the portion of the request URI that indicates the context of the request.ExpectationHandlergetExpectationHandler()Get theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").protected FilterChainInvokergetFilterChain(org.glassfish.grizzly.http.server.Request request)StringgetName()ServletConfigImplgetServletConfig()protected WebappContextgetServletCtx()jakarta.servlet.ServletgetServletInstance()Return theServletinstance used by thisServletHandlerprotected StringgetSessionCookieName()Overrides default (JSESSIONID) session cookie name.protected org.glassfish.grizzly.http.server.SessionManagergetSessionManager(org.glassfish.grizzly.http.server.Request request)protected voidloadServlet()Load aServletinstance.protected booleansendAcknowledgment(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response)Override parent'sHttpHandler.sendAcknowledgment(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response)to letExpectationHandler(if one is registered) process the expectation.voidservice(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response)voidsetClassLoader(ClassLoader classLoader)voidsetContextPath(String contextPath)Programmatically set the context path of the Servlet.protected voidsetDispatcherHelper(org.glassfish.grizzly.http.server.util.DispatcherHelper dispatcherHelper)voidsetExpectationHandler(ExpectationHandler expectationHandler)Set theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").protected voidsetFilterChainFactory(FilterChainFactory filterChainFactory)protected voidsetPathData(org.glassfish.grizzly.http.server.Request from, HttpServletRequestImpl to)protected voidsetServletClass(Class<? extends jakarta.servlet.Servlet> servletClass)protected voidsetServletClassName(String servletClassName)protected voidsetServletInstance(jakarta.servlet.Servlet servletInstance)Set theServletinstance used by thisServletHandlerprotected voidsetSessionManager(org.glassfish.grizzly.http.server.SessionManager sessionManager)Set theSessionManagerinstance used by thisServletHandlervoidstart()-
Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler
getErrorPageGenerator, getRequestExecutorProvider, getRequestURIEncoding, isAllowCustomStatusMessage, isAllowEncodedSlash, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setRequestURIEncoding, setRequestURIEncoding, updatePaths
-
-
-
-
Field Detail
-
servletClassName
protected String servletClassName
-
servletClass
protected Class<? extends jakarta.servlet.Servlet> servletClass
-
servletInstance
protected volatile jakarta.servlet.Servlet servletInstance
-
initialize
protected boolean initialize
Initialize theServletContext
-
classLoader
protected ClassLoader classLoader
-
expectationHandler
protected ExpectationHandler expectationHandler
-
filterChainFactory
protected FilterChainFactory filterChainFactory
-
-
Constructor Detail
-
ServletHandler
protected ServletHandler(ServletConfigImpl servletConfig)
-
-
Method Detail
-
start
public void start()
- Overrides:
startin classorg.glassfish.grizzly.http.server.HttpHandler
-
sendAcknowledgment
protected boolean sendAcknowledgment(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response) throws IOExceptionOverride parent'sHttpHandler.sendAcknowledgment(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response)to letExpectationHandler(if one is registered) process the expectation.- Overrides:
sendAcknowledgmentin classorg.glassfish.grizzly.http.server.HttpHandler- Throws:
IOException
-
service
public void service(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response) throws Exception- Specified by:
servicein classorg.glassfish.grizzly.http.server.HttpHandler- Throws:
Exception
-
doServletService
protected void doServletService(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response)
-
getFilterChain
protected FilterChainInvoker getFilterChain(org.glassfish.grizzly.http.server.Request request)
-
setPathData
protected void setPathData(org.glassfish.grizzly.http.server.Request from, HttpServletRequestImpl to)
-
customizeErrorPage
public void customizeErrorPage(org.glassfish.grizzly.http.server.Response response, String message, int errorCode, Throwable t)Customize the error page returned to the client.- Parameters:
response- theResponsemessage- the HTTP error messageerrorCode- the error code.
-
loadServlet
protected void loadServlet() throws jakarta.servlet.ServletExceptionLoad aServletinstance.- Throws:
jakarta.servlet.ServletException- If failed toServlet.init(jakarta.servlet.ServletConfig).
-
configureServletEnv
protected void configureServletEnv() throws jakarta.servlet.ServletExceptionConfigure theWebappContextandServletConfigImpl- Throws:
jakarta.servlet.ServletException- Error while configuringServlet.
-
getServletInstance
public jakarta.servlet.Servlet getServletInstance()
Return theServletinstance used by thisServletHandler- Returns:
Servletinstance.
-
setServletInstance
protected void setServletInstance(jakarta.servlet.Servlet servletInstance)
Set theServletinstance used by thisServletHandler- Parameters:
servletInstance- an instance of Servlet.
-
setServletClassName
protected void setServletClassName(String servletClassName)
-
setServletClass
protected void setServletClass(Class<? extends jakarta.servlet.Servlet> servletClass)
-
setSessionManager
protected void setSessionManager(org.glassfish.grizzly.http.server.SessionManager sessionManager)
Set theSessionManagerinstance used by thisServletHandler- Parameters:
sessionManager- an implementation of SessionManager.
-
getContextPath
public String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.It is possible that a servlet container may match a context by more than one context path. In such cases this method will return the actual context path used by the request and it may differ from the path returned by the
ServletContext.getContextPath()method. The context path returned byServletContext.getContextPath()should be considered as the prime or preferred context path of the application.- Returns:
- a
Stringspecifying the portion of the request URI that indicates the context of the request - See Also:
ServletContext.getContextPath()
-
setContextPath
public void setContextPath(String contextPath)
Programmatically set the context path of the Servlet.- Parameters:
contextPath- Context path.
-
destroy
public void destroy()
Destroy this Servlet and its associatedServletContextListener- Overrides:
destroyin classorg.glassfish.grizzly.http.server.HttpHandler
-
getServletCtx
protected WebappContext getServletCtx()
-
getClassLoader
public ClassLoader getClassLoader()
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
-
getServletConfig
public ServletConfigImpl getServletConfig()
-
getName
public String getName()
- Overrides:
getNamein classorg.glassfish.grizzly.http.server.HttpHandler
-
getExpectationHandler
public ExpectationHandler getExpectationHandler()
Get theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").- Returns:
- the
ExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").
-
setExpectationHandler
public void setExpectationHandler(ExpectationHandler expectationHandler)
Set theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").- Parameters:
expectationHandler- theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").
-
setDispatcherHelper
protected void setDispatcherHelper(org.glassfish.grizzly.http.server.util.DispatcherHelper dispatcherHelper)
- Overrides:
setDispatcherHelperin classorg.glassfish.grizzly.http.server.HttpHandler
-
setFilterChainFactory
protected void setFilterChainFactory(FilterChainFactory filterChainFactory)
-
getSessionCookieName
protected String getSessionCookieName()
Overrides default (JSESSIONID) session cookie name.- Overrides:
getSessionCookieNamein classorg.glassfish.grizzly.http.server.HttpHandler- Returns:
- the session cookie name
-
getSessionManager
protected org.glassfish.grizzly.http.server.SessionManager getSessionManager(org.glassfish.grizzly.http.server.Request request)
- Overrides:
getSessionManagerin classorg.glassfish.grizzly.http.server.HttpHandler- Returns:
- Servlet-aware
SessionManager
-
-