org.glassfish.grizzly.servlet
Class ServletHandler

java.lang.Object
  extended by org.glassfish.grizzly.http.server.HttpHandler
      extended by org.glassfish.grizzly.servlet.ServletHandler

public class ServletHandler
extends HttpHandler

HttpHandler implementation that provides an entry point for processing a Servlet request.

Author:
Jeanfrancois Arcand

Field Summary
protected  ClassLoader classLoader
           
protected  ExpectationHandler expectationHandler
           
protected  boolean initialize
          Initialize the ServletContext
protected  Map<String,Object> properties
          Holder for our configured properties.
protected  Class<? extends javax.servlet.Servlet> servletClass
           
protected  String servletClassName
           
protected  javax.servlet.Servlet servletInstance
           
 
Constructor Summary
protected ServletHandler(ServletConfigImpl servletConfig)
           
 
Method Summary
protected  void configureClassLoader(String applicationPath)
          Create a URLClassLoader which has the capability of loading classes jar under an exploded war application.
protected  void configureServletEnv()
          Configure the WebappContext and ServletConfigImpl
 void customizeErrorPage(Response response, String message, int errorCode)
          Customize the error page returned to the client.
 void destroy()
          Destroy this Servlet and its associated ServletContextListener
protected  void doServletService(Request request, Response response)
           
 ClassLoader getClassLoader()
           
 String getContextPath()
          Returns the portion of the request URI that indicates the context of the request.
 ExpectationHandler getExpectationHandler()
          Get the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").
protected  FilterChainInvoker getFilterChain(Request request)
           
 String getName()
           
 ServletConfigImpl getServletConfig()
           
protected  WebappContext getServletCtx()
           
 javax.servlet.Servlet getServletInstance()
          Return the Servlet instance used by this ServletHandler
protected  void loadServlet()
          Load a Servlet instance.
protected  boolean sendAcknowledgment(Request request, Response response)
          Override parent's HttpHandler.sendAcknowledgment(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response) to let ExpectationHandler (if one is registered) process the expectation.
 void service(Request request, Response response)
          
 void setClassLoader(ClassLoader classLoader)
           
 void setContextPath(String contextPath)
          Programmatically set the context path of the Servlet.
protected  void setDispatcherHelper(DispatcherHelper dispatcherHelper)
           
 void setExpectationHandler(ExpectationHandler expectationHandler)
          Set the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").
protected  void setFilterChainFactory(FilterChainFactory filterChainFactory)
           
protected  void setPathData(Request from, HttpServletRequestImpl to)
           
protected  void setServletClass(Class<? extends javax.servlet.Servlet> servletClass)
           
protected  void setServletClassName(String servletClassName)
           
protected  void setServletInstance(javax.servlet.Servlet servletInstance)
          Set the Servlet instance used by this ServletHandler
 void start()
          
 
Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler
customizedErrorPage, doHandle, getRequestURIEncoding, isAllowCustomStatusMessage, isAllowEncodedSlash, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setRequestURIEncoding, setRequestURIEncoding, updatePaths
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servletClassName

protected String servletClassName

servletClass

protected Class<? extends javax.servlet.Servlet> servletClass

servletInstance

protected volatile javax.servlet.Servlet servletInstance

properties

protected final Map<String,Object> properties
Holder for our configured properties.


initialize

protected boolean initialize
Initialize the ServletContext


classLoader

protected ClassLoader classLoader

expectationHandler

protected ExpectationHandler expectationHandler
Constructor Detail

ServletHandler

protected ServletHandler(ServletConfigImpl servletConfig)
Method Detail

start

public void start()

Overrides:
start in class HttpHandler

configureClassLoader

protected void configureClassLoader(String applicationPath)
                             throws IOException
Create a URLClassLoader which has the capability of loading classes jar under an exploded war application.

Parameters:
applicationPath - Application class path.
Throws:
IOException - I/O error.

sendAcknowledgment

protected boolean sendAcknowledgment(Request request,
                                     Response response)
                              throws IOException
Override parent's HttpHandler.sendAcknowledgment(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response) to let ExpectationHandler (if one is registered) process the expectation.

Overrides:
sendAcknowledgment in class HttpHandler
Throws:
IOException

service

public void service(Request request,
                    Response response)
             throws Exception

Specified by:
service in class HttpHandler
Throws:
Exception

doServletService

protected void doServletService(Request request,
                                Response response)

getFilterChain

protected FilterChainInvoker getFilterChain(Request request)

setPathData

protected void setPathData(Request from,
                           HttpServletRequestImpl to)

customizeErrorPage

public void customizeErrorPage(Response response,
                               String message,
                               int errorCode)
Customize the error page returned to the client.

Parameters:
response - the Response
message - the HTTP error message
errorCode - the error code.

loadServlet

protected void loadServlet()
                    throws javax.servlet.ServletException
Load a Servlet instance.

Throws:
javax.servlet.ServletException - If failed to Servlet.init(javax.servlet.ServletConfig).

configureServletEnv

protected void configureServletEnv()
                            throws javax.servlet.ServletException
Configure the WebappContext and ServletConfigImpl

Throws:
javax.servlet.ServletException - Error while configuring Servlet.

getServletInstance

public javax.servlet.Servlet getServletInstance()
Return the Servlet instance used by this ServletHandler

Returns:
Servlet instance.

setServletInstance

protected void setServletInstance(javax.servlet.Servlet servletInstance)
Set the Servlet instance used by this ServletHandler

Parameters:
servletInstance - an instance of Servlet.

setServletClassName

protected void setServletClassName(String servletClassName)

setServletClass

protected void setServletClass(Class<? extends javax.servlet.Servlet> servletClass)

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 by ServletContext.getContextPath() should be considered as the prime or preferred context path of the application.

Returns:
a String specifying 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 associated ServletContextListener

Overrides:
destroy in class HttpHandler

getServletCtx

protected WebappContext getServletCtx()

getClassLoader

public ClassLoader getClassLoader()

setClassLoader

public void setClassLoader(ClassLoader classLoader)

getServletConfig

public ServletConfigImpl getServletConfig()

getName

public String getName()
Overrides:
getName in class HttpHandler

getExpectationHandler

public ExpectationHandler getExpectationHandler()
Get the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

Returns:
the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

setExpectationHandler

public void setExpectationHandler(ExpectationHandler expectationHandler)
Set the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

Parameters:
expectationHandler - the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

setDispatcherHelper

protected void setDispatcherHelper(DispatcherHelper dispatcherHelper)
Overrides:
setDispatcherHelper in class HttpHandler

setFilterChainFactory

protected void setFilterChainFactory(FilterChainFactory filterChainFactory)


Copyright © 2012 Oracle Corporation. All Rights Reserved.