org.glassfish.grizzly.http.server
Class HttpHandlerChain

java.lang.Object
  extended by org.glassfish.grizzly.http.server.HttpHandler
      extended by org.glassfish.grizzly.http.server.HttpHandlerChain
All Implemented Interfaces:
JmxEventListener

public class HttpHandlerChain
extends HttpHandler
implements JmxEventListener

The HttpHandlerChain class allows the invocation of multiple HttpHandlers every time a new HTTP request is ready to be handled. Requests are mapped to their associated HttpHandler at runtime using the mapping information configured when invoking the (org.glassfish.grizzly.http.server.HttpHandler, java.lang.String[]) Note: This class is NOT thread-safe, so make sure synchronization is performed when dynamically adding and removing HttpHandler

Author:
Jeanfrancois Arcand

Constructor Summary
HttpHandlerChain(HttpServer httpServer)
           
 
Method Summary
 void addHandler(HttpHandler httpHandler, String[] mappings)
          Add a HttpHandler and its associated array of mapping.
 void destroy()
          Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks.
 void jmxDisabled()
          Invoked when JMX has been disabled.
 void jmxEnabled()
          Invoked when JMX has been enabled.
 void removeAllHttpHandlers()
           
 boolean removeHttpHandler(HttpHandler httpHandler)
          Remove a HttpHandler
protected  boolean sendAcknowledgment(Request request, Response response)
          Skip 100-Continue processing in HttpHandlerChain.
 void service(Request request, Response response)
          Map the Request to the proper HttpHandler
 void start()
          Called when the HttpHandler's container is started by invoking HttpServer.start().
 
Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler
customizedErrorPage, doHandle, getName, getRequestURIEncoding, isAllowCustomStatusMessage, isAllowEncodedSlash, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, updatePaths
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpHandlerChain

public HttpHandlerChain(HttpServer httpServer)
Method Detail

jmxEnabled

public void jmxEnabled()
Description copied from interface: JmxEventListener
Invoked when JMX has been enabled.

Specified by:
jmxEnabled in interface JmxEventListener
See Also:
ServerConfiguration.setJmxEnabled(boolean)

jmxDisabled

public void jmxDisabled()
Description copied from interface: JmxEventListener
Invoked when JMX has been disabled.

Specified by:
jmxDisabled in interface JmxEventListener
See Also:
ServerConfiguration.setJmxEnabled(boolean)

sendAcknowledgment

protected boolean sendAcknowledgment(Request request,
                                     Response response)
                              throws IOException
Skip 100-Continue processing in HttpHandlerChain. It's going to be delegated to one of the children HttpHandler.

Overrides:
sendAcknowledgment in class HttpHandler
Parameters:
request - the Request.
response - the Response.
Returns:
true if request processing should continue after acknowledgment of the expectation, otherwise return false.
Throws:
IOException - if an error occurs sending the acknowledgment.

start

public void start()
Description copied from class: HttpHandler
Called when the HttpHandler's container is started by invoking HttpServer.start(). By default, it does nothing.

Overrides:
start in class HttpHandler

service

public void service(Request request,
                    Response response)
             throws Exception
Map the Request to the proper HttpHandler

Specified by:
service in class HttpHandler
Parameters:
request - The Request
response - The Response
Throws:
Exception

addHandler

public void addHandler(HttpHandler httpHandler,
                       String[] mappings)
Add a HttpHandler and its associated array of mapping. The mapping data will be used to map incoming request to its associated HttpHandler.

Parameters:
httpHandler - HttpHandler instance
mappings - an array of mapping.

removeHttpHandler

public boolean removeHttpHandler(HttpHandler httpHandler)
Remove a HttpHandler

Returns:
true if removed

removeAllHttpHandlers

public void removeAllHttpHandlers()

destroy

public void destroy()
Description copied from class: HttpHandler
Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks. By default, this method does nothing.

Overrides:
destroy in class HttpHandler


Copyright © 2012 Oracle Corporation. All Rights Reserved.