pygmy.handlers
Class ResourceHandler
java.lang.Object
pygmy.core.AbstractHandler
pygmy.handlers.ResourceHandler
- All Implemented Interfaces:
- Handler
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.
url-prefix | The prefix to filter request urls. | None | Yes |
resourceMount | A 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.
| None | Yes |
default | The name of the default resource that should be used if no file is specified in the URL. ( like index.html ) | index.html | No |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RESOURCE_MOUNT_OPTION
public static final ConfigOption RESOURCE_MOUNT_OPTION
DEFAULT_RESOURCE_OPTION
public static final ConfigOption DEFAULT_RESOURCE_OPTION
ResourceHandler
public ResourceHandler()
initialize
public boolean initialize(java.lang.String handlerName,
Server server)
- Specified by:
initialize
in interface Handler
- Overrides:
initialize
in class AbstractHandler
handleBody
protected boolean handleBody(HttpRequest request,
HttpResponse response)
throws java.io.IOException
- Overrides:
handleBody
in class AbstractHandler
- Throws:
java.io.IOException