Class ResourceHandler

  extended by pygmy.core.AbstractHandler
      extended by pygmy.handlers.ResourceHandler
All Implemented Interfaces:

public class ResourceHandler
extends AbstractHandler
implements Handler

This serves up files from the class path. Usually this is used to serve files from within a jar file that is within the classpath of the application running. However, you could serve up files from anywhere in the classpath, no just jar files. This makes it easy to package part of your web content inside a jar file for easy distribution, but make it transparently available without the user needing to extract the content from the jar file. This is great for static or default content that you don't want users to have to manage. By putting a FileHandler and a ResourceHandler in a chain filtering on the same url-prefix, you can allow users to override or augment content from the jar file by placing the same file on the file system, but load the default from the jar file if the file not on the file system.

Parameter NameExplanationDefault ValueRequired
url-prefixThe prefix to filter request urls.NoneYes
resourceMountA path within the classpath to the root of the folder to share. The requested url minus the url-prefix will be added to this path to yield the path loaded from the classpath. NoneYes
defaultThe name of the default resource that should be used if no file is specified in the URL. ( like index.html )index.htmlNo

Field Summary
Fields inherited from class pygmy.core.AbstractHandler
handlerName, server, URL_PREFIX_OPTION, urlPrefix
Constructor Summary
Method Summary
protected  boolean handleBody(HttpRequest request, HttpResponse response)
 boolean initialize(java.lang.String handlerName, Server server)
Methods inherited from class pygmy.core.AbstractHandler
getMimeType, getName, getUrlPrefix, handle, isRequestdForHandler, shutdown
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface pygmy.core.Handler
getName, handle, shutdown

Field Detail


public static final ConfigOption RESOURCE_MOUNT_OPTION


public static final ConfigOption DEFAULT_RESOURCE_OPTION
Constructor Detail


public ResourceHandler()
Method Detail


public boolean initialize(java.lang.String handlerName,
                          Server server)
Specified by:
initialize in interface Handler
initialize in class AbstractHandler


protected boolean handleBody(HttpRequest request,
                             HttpResponse response)
handleBody in class AbstractHandler