Class WebServerFilter

java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.samples.http.download.WebServerFilter
All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter

public class WebServerFilter extends org.glassfish.grizzly.filterchain.BaseFilter
Simple Web server implementation, which locates requested resources in a local filesystem and transfers it asynchronously to a client.
Author:
Alexey Stashok
  • Constructor Summary

    Constructors
    Constructor
    Description
    WebServerFilter(String rootFolder)
    Construct a WebServer
  • Method Summary

    Modifier and Type
    Method
    Description
    org.glassfish.grizzly.filterchain.NextAction
    handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
    The method is called once we have received some HttpContent.

    Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter

    createContext, exceptionOccurred, handleAccept, handleClose, handleConnect, handleEvent, handleWrite, onAdded, onFilterChainChanged, onRemoved, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • WebServerFilter

      public WebServerFilter(String rootFolder)
      Construct a WebServer
      Parameters:
      rootFolder - Root folder in a local filesystem, where server will look for resources
  • Method Details

    • handleRead

      public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException
      The method is called once we have received some HttpContent. Filter gets HttpContent, which represents a part or complete HTTP request. If it's just a chunk of a complete HTTP request - filter checks whether it's the last chunk, if not - swallows content and returns. If incoming HttpContent represents complete HTTP request or it is the last HTTP request - it initiates file download and sends the file asynchronously to the client.
      Specified by:
      handleRead in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleRead in class org.glassfish.grizzly.filterchain.BaseFilter
      Parameters:
      ctx - Request processing context
      Returns:
      NextAction
      Throws:
      IOException