A second round of fixes to simplify the web application setup code and provide for a connection context accessible by the application when handling web requests.

This commit is contained in:
wcrisman
2014-07-11 12:32:03 -07:00
parent 07b8c2ff8d
commit 2b035e092c
13 changed files with 381 additions and 374 deletions

View File

@@ -33,16 +33,12 @@ public class WebOptions {
private File externalBaseDirectory = null;
/** An optional directory where cache files are stored. These files are not part of the webapp's general distribution and are fully re-creatable. */
private File cacheBaseDirectory = null;
private IHashMap nameSubstitutionMap = new LiteHashMap(10);
private IHashMap pathSubstitutionMap = new LiteHashMap(10);
private String defaultPackageName = null;
private long sessionTimeout = 3600000;
private long sessionCheckInterval = 3600000;
private IBadSessionHandler badSessionHandler = null;
/** Replaces the default handling of a user's access to static (file system based) resources. Allows for permission validation. */
private IResourceRequestHandler resourceRequestHandler = null;
/** Replaces the default handling of web dav requests. */
private IWebdavRequestHandler webdavRequestHandler = null;
private ResourceRequestHandler resourceRequestHandler = null;
/** Sets the cutoff size for caching a file in memory. This may be zero to stop caching resources alltogether. Defaults to 10KB. */
private long cacheCutoffSize = 10000;
/** Whether responses should be compressed by default when possible. Certain resources that compress poorly will of course ignore this directive. */
@@ -187,32 +183,6 @@ public boolean getCompressResponses() {
public void setCompressResponses(boolean compressResponses) {
this.compressResponses = compressResponses;
}//setCompressResponses()//
public IHashMap getNameSubstitutionMap() {
return nameSubstitutionMap;
}//getNameSubstitutionMap()//
/**
* Sets the mapping between old resource names and new ones.
* This is used to substitute just the ending name for another ending name.
* It is not recommended to use this.
* <p>TODO: Replace this with something that uses a regular expression like language.</p>
* @param nameSubstitutionMap
*/
public void setNameSubstitutionMap(LiteHashMap nameSubstitutionMap) {
this.nameSubstitutionMap = nameSubstitutionMap;
}//setNameSubstitutionMap()//
public IHashMap getPathSubstitutionMap() {
return pathSubstitutionMap;
}//getPathSubstitutionMap()//
/**
* Sets the mapping between old resource request paths and new ones.
* This is used to substitute a *full* resource requested by the client with another *full* resource request.
* For example: "/" -> "/index.html" will only alter http://mydomain.com/ to become http://mydomain.com/index.html, but won't modify http://mydomain.com/path/ at all.
* <p>TODO: Replace this with something that uses a regular expression like language.</p>
* @param pathSubstitutionMap
*/
public void setPathSubstitutionMap(LiteHashMap pathSubstitutionMap) {
this.pathSubstitutionMap = pathSubstitutionMap == null ? new LiteHashMap(10) : pathSubstitutionMap;
}//setPathSubstitutionMap()//
public String getDefaultPackageName() {
return defaultPackageName;
}//getDefaultPackageName()//
@@ -255,51 +225,20 @@ public IBadSessionHandler getBadSessionHandler() {
public void setBadSessionHandler(IBadSessionHandler badSessionHandler) {
this.badSessionHandler = badSessionHandler;
}//setBadSessionHandler()//
/**
* Adds a resource name subtitution mapping where the old resource name will be replaced by the new resource name automatically prior to the request being processed.
* @param oldName The old resource name.
* @param newName The new resource name.
*/
public void addResourceNameSubstitution(String oldName, String newName) {
nameSubstitutionMap.put(oldName, newName);
}//addResourceNameSubstitution()//
/**
* Adds a path subtitution mapping where the old path will be replaced by the new path automatically prior to the request being processed.
* @param oldPath The old resource name. eg: "/"
* @param newPath The new resource name. eg: "/subdir/index.html"
* @param forward Whether the substitution should constitute a forward (where the client is told of the new path) versus a redirect.
*/
public void addPathSubstitution(String oldPath, String newPath, boolean forward) {
pathSubstitutionMap.put(oldPath, new PathSubstitution(newPath, forward));
}//addPathSubstitution()//
/**
* Gets the resource request handler which allows the application control over how users access static resources via the web server.
* @return Replaces the default handling of a user's access to static (file system based) resources. Allows for permission validation.
*/
public IResourceRequestHandler getResourceRequestHandler() {
public ResourceRequestHandler getResourceRequestHandler() {
return resourceRequestHandler;
}//getResourceRequestHandler()//
/**
* Sets the resource request handler which allows the application control over how users access static resources via the web server.
* @param resourceRequestHandler Replaces the default handling of a user's access to static (file system based) resources. Allows for permission validation.
*/
public void setResourceRequestHandler(IResourceRequestHandler resourceRequestHandler) {
public void setResourceRequestHandler(ResourceRequestHandler resourceRequestHandler) {
this.resourceRequestHandler = resourceRequestHandler;
}//setResourceRequestHandler()//
/**
* Gets the web dav request handler.
* @return Replaces the default handling of web dav commands.
*/
public IWebdavRequestHandler getWebdavRequestHandler() {
return webdavRequestHandler;
}//getWebdavRequestHandler()//
/**
* Sets the web dav request handler.
* @param webdavRequestHandler Replaces the default handling of web dav commands.
*/
public void setWebdavRequestHandler(IWebdavRequestHandler webdavRequestHandler) {
this.webdavRequestHandler = webdavRequestHandler;
}//setWebdavRequestHandler()//
public long getCacheCutoffSize() {
return cacheCutoffSize;
}//getCacheCutoffSize()//