com.sun.grizzly.tcp.http11
Class GrizzlyAdapter

java.lang.Object
  extended by com.sun.grizzly.tcp.StaticResourcesAdapter
      extended by com.sun.grizzly.tcp.http11.GrizzlyAdapter
All Implemented Interfaces:
Adapter
Direct Known Subclasses:
ServletAdapter

public abstract class GrizzlyAdapter
extends StaticResourcesAdapter

Base class to use when GrizzlyRequest/Response/InputStream/OutputStream are needed to implement a customized HTTP container/extendion to the http module.

Author:
Jeanfrancois Arcand

Field Summary
static int ADAPTER_NOTES
           
protected static boolean ALLOW_BACKSLASH
           
 
Fields inherited from class com.sun.grizzly.tcp.StaticResourcesAdapter
commitErrorResponse, logger
 
Fields inherited from interface com.sun.grizzly.tcp.Adapter
CONNECTION_PROCESSING_COMPLETED, CONNECTION_PROCESSING_STARTED, REQUEST_PROCESSING_COMPLETED, REQUEST_PROCESSING_STARTED
 
Constructor Summary
GrizzlyAdapter()
           
GrizzlyAdapter(String publicDirectory)
           
 
Method Summary
abstract  void afterService(GrizzlyRequest request, GrizzlyResponse response)
          This method should contains the logic for any http extension to the Grizzly HTTP Webserver.
 void afterService(Request req, Response res)
          Finish the response and recycle the request/response tokens.
protected  void convertMB(MessageBytes mb)
          Character conversion of the a US-ASCII MessageBytes.
protected  void convertURI(MessageBytes uri, GrizzlyRequest request)
           
protected static void copyBytes(byte[] b, int dest, int src, int len)
          Copy an array of bytes to a different position.
 boolean isHandleStaticResources()
          Return true if this class should handle static resources.
protected  void log(String message)
          Log a message on the Logger associated with our Container (if any)
protected  void log(String message, Throwable throwable)
          Log a message on the Logger associated with our Container (if any)
static boolean normalize(MessageBytes uriMB)
          Normalize URI.
abstract  void service(GrizzlyRequest request, GrizzlyResponse response)
          This method should contains the logic for any http extension to the Grizzly HTTP Webserver.
 void service(Request req, Response res)
          Wrap a Request and Response with associated high level classes like GrizzlyRequest and GrizzlyResponse.
 void setHandleStaticResources(boolean handleStaticResources)
          Enable static resource handling.
 
Methods inherited from class com.sun.grizzly.tcp.StaticResourcesAdapter
customizedErrorPage, fireAdapterEvent, getLogger, getRootFolder, service, setLogger, setRootFolder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADAPTER_NOTES

public static final int ADAPTER_NOTES
See Also:
Constant Field Values

ALLOW_BACKSLASH

protected static final boolean ALLOW_BACKSLASH
See Also:
Constant Field Values
Constructor Detail

GrizzlyAdapter

public GrizzlyAdapter()

GrizzlyAdapter

public GrizzlyAdapter(String publicDirectory)
Method Detail

service

public void service(Request req,
                    Response res)
             throws Exception
Wrap a Request and Response with associated high level classes like GrizzlyRequest and GrizzlyResponse. The later objects offer more high level API like GrizzlyInputStream, GrizzlyRead etc.

Specified by:
service in interface Adapter
Overrides:
service in class StaticResourcesAdapter
Parameters:
req -
res -
Throws:
Exception

service

public abstract void service(GrizzlyRequest request,
                             GrizzlyResponse response)
This method should contains the logic for any http extension to the Grizzly HTTP Webserver.


afterService

public abstract void afterService(GrizzlyRequest request,
                                  GrizzlyResponse response)
                           throws Exception
This method should contains the logic for any http extension to the Grizzly HTTP Webserver.

Throws:
Exception

afterService

public void afterService(Request req,
                         Response res)
                  throws Exception
Description copied from interface: Adapter
Finish the response and recycle the request/response tokens. Base on the connection header, the underlying socket transport will be closed

Specified by:
afterService in interface Adapter
Overrides:
afterService in class StaticResourcesAdapter
Throws:
Exception

convertURI

protected void convertURI(MessageBytes uri,
                          GrizzlyRequest request)
                   throws Exception
Throws:
Exception

normalize

public static boolean normalize(MessageBytes uriMB)
Normalize URI.

This method normalizes "\", "//", "/./" and "/../". This method will return false when trying to go above the root, or if the URI contains a null byte.

Parameters:
uriMB - URI to be normalized

copyBytes

protected static void copyBytes(byte[] b,
                                int dest,
                                int src,
                                int len)
Copy an array of bytes to a different position. Used during normalization.


log

protected void log(String message)
Log a message on the Logger associated with our Container (if any)

Parameters:
message - Message to be logged

log

protected void log(String message,
                   Throwable throwable)
Log a message on the Logger associated with our Container (if any)

Parameters:
message - Message to be logged
throwable - Associated exception

convertMB

protected void convertMB(MessageBytes mb)
Character conversion of the a US-ASCII MessageBytes.


isHandleStaticResources

public boolean isHandleStaticResources()
Return true if this class should handle static resources.

Returns:
true if this class should handle static resources.

setHandleStaticResources

public void setHandleStaticResources(boolean handleStaticResources)
Enable static resource handling. Default is false.

Parameters:
handleStaticResources -


Copyright © 2008 SUN Microsystems. All Rights Reserved.