com.sun.grizzly.tcp
Class StaticResourcesAdapter

java.lang.Object
  extended by com.sun.grizzly.tcp.StaticResourcesAdapter
All Implemented Interfaces:
Adapter
Direct Known Subclasses:
CometdAdapter, DynamicContentAdapter, GrizzletAdapter, GrizzlyAdapter

public class StaticResourcesAdapter
extends Object
implements Adapter

Simple HTTP based Web Server. Part of this class is from Tomcat sandbox code from Costin Manolache.

Author:
Jeanfrancois Arcand

Field Summary
protected  boolean commitErrorResponse
          Commit the 404 response automatically.
protected  Logger logger
           
 
Fields inherited from interface com.sun.grizzly.tcp.Adapter
CONNECTION_PROCESSING_COMPLETED, CONNECTION_PROCESSING_STARTED, REQUEST_PROCESSING_COMPLETED, REQUEST_PROCESSING_STARTED
 
Constructor Summary
StaticResourcesAdapter()
           
StaticResourcesAdapter(String rootFolder)
           
 
Method Summary
 void afterService(Request req, Response res)
          Finish the response and recycle the request/response tokens.
protected  void customizedErrorPage(Request req, Response res)
          Customize the error pahe
 void fireAdapterEvent(String string, Object object)
          Not Used.
 Logger getLogger()
           
 String getRootFolder()
           
 void service(Request req, Response res)
          Call the service method, and notify all listeners
protected  void service(String uri, Request req, Response res)
          Lookup a resource based on the request URI.
 void setLogger(Logger logger)
           
 void setRootFolder(String newRoot)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger

commitErrorResponse

protected boolean commitErrorResponse
Commit the 404 response automatically.

Constructor Detail

StaticResourcesAdapter

public StaticResourcesAdapter()

StaticResourcesAdapter

public StaticResourcesAdapter(String rootFolder)
Method Detail

service

public void service(Request req,
                    Response res)
             throws Exception
Description copied from interface: Adapter
Call the service method, and notify all listeners

Specified by:
service in interface Adapter
Throws:
Exception - if an error happens during handling of the request. Common errors are:
  • IOException if an input/output error occurs and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
  • ServletException if a servlet throws an exception and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
Tomcat should be able to handle and log any other exception ( including runtime exceptions )

service

protected void service(String uri,
                       Request req,
                       Response res)
                throws Exception
Lookup a resource based on the request URI.

Parameters:
uri - The request URI
req - The request objects
res - The response object
Throws:
Exception

customizedErrorPage

protected void customizedErrorPage(Request req,
                                   Response res)
                            throws Exception
Customize the error pahe

Parameters:
req -
res -
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
Throws:
Exception

fireAdapterEvent

public void fireAdapterEvent(String string,
                             Object object)
Not Used.

Specified by:
fireAdapterEvent in interface Adapter
Parameters:
string -
object -

getRootFolder

public String getRootFolder()

setRootFolder

public void setRootFolder(String newRoot)

getLogger

public Logger getLogger()

setLogger

public void setLogger(Logger logger)


Copyright © 2010 SUN Microsystems. All Rights Reserved.