| java.lang.Object sunlabs.brazil.handler.ResourceHandler
ResourceHandler | public class ResourceHandler implements Handler(Code) | | Handler for serving documents out of the jar file.
Look for url's as resources, presumably in the same "jar"
file as the class files.
This allows an entire web site to be included in the jar file.
A typical way to use this handler (with java 1.2+) is as follows:
- Add an existing web site to the jar file with:
jar uf [jar file] [web site]
- Create a config file, and add it to the jar file as:
sunlabs/brazil/main/config . See
sunlabs.brazil.server.Main Main.java for more info.
- Create a startup file containing:
Main-Class: sunlabs.brazil.server.Main ,
and add it to the manifest with:
jar ufm [jar file] [startup file]
- Start the server with:
java -jar [jar file] [optional server options....]
if no suffix is provided, and the "directory" exists, a redirect
is issued, to add-on the trailing slash.
The following server properties are used:
- root
- The document root path within the jar file
- prefix
- The url prefix to triger this handler
- default
- The default file name for url references ending in /
- mime.xxx
- The mime type for suffix xxx.
author: Stephen Uhler version: %V% ResourceHandler.java |
Method Summary | |
static String | getProperty(Properties props, String prefix, String name, String def) | public static byte[] | getResourceBytes(Properties props, String prefix, String file) Find a file blob as a resource in our jar file (experimental). | static String | getResourcePath(Properties props, String prefix, String file) | public static InputStream | getResourceStream(Properties props, String prefix, String file) Look for a file in the filesystem. | public static String | getResourceString(Properties props, String prefix, String file) | public boolean | init(Server server, String prefix) | public boolean | respond(Request request) |
getResourceBytes | public static byte[] getResourceBytes(Properties props, String prefix, String file) throws IOException(Code) | | Find a file blob as a resource in our jar file (experimental).
Parameters: props - where to look for server root property Parameters: prefix - " Parameters: file - The pseudo file to find as a resource |
getResourceStream | public static InputStream getResourceStream(Properties props, String prefix, String file) throws IOException(Code) | | Look for a file in the filesystem. If its not there, see if
we can find a resource in our jar file. Relative paths
are resolved with respect to the document root.
Parameters: props - where to look for server root property Parameters: prefix - " Parameters: file - The pseudo file to find as a resource |
|
|