blowtorch crufty tab indents; missing templates 404 instead of spewing logs

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1766 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
elizabeth
2006-01-20 10:52:19 +00:00
parent da75b303bc
commit daf016d62f
@@ -161,7 +161,7 @@ public class DispatcherServlet extends VelocityServlet
public void destroy () public void destroy ()
{ {
super.destroy(); super.destroy();
// shutdown our application // shutdown our application
_app.shutdown(); _app.shutdown();
} }
@@ -282,8 +282,19 @@ public class DispatcherServlet extends VelocityServlet
// to construct full paths // to construct full paths
ctx.put("context_path", req.getContextPath()); ctx.put("context_path", req.getContextPath());
// then select the template // then select the template
Template tmpl = selectTemplate(siteId, ictx); Template tmpl = null;
try {
tmpl = selectTemplate(siteId, ictx);
} catch (ResourceNotFoundException rnfe) {
// send up a 404. For some annoying reason, Jetty tells
// Apache that all is okay (200) when sending its own custom
// error pages, forcing us to use Jetty's custom error page
// handling code rather than passing it up the chain to be
// dealt with appropriately.
ictx.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
return null;
}
// assume the request is in the default character set unless it // assume the request is in the default character set unless it
// has actually been sensibly supplied by the browser // has actually been sensibly supplied by the browser
@@ -296,7 +307,7 @@ public class DispatcherServlet extends VelocityServlet
rsp.setContentType("text/html; charset=" + _charset); rsp.setContentType("text/html; charset=" + _charset);
Exception error = null; Exception error = null;
try { try {
// insert the application into the context in case the // insert the application into the context in case the
// logic or a tool wishes to make use of it // logic or a tool wishes to make use of it
ictx.put(APPLICATION_KEY, _app); ictx.put(APPLICATION_KEY, _app);
@@ -355,7 +366,7 @@ public class DispatcherServlet extends VelocityServlet
ictx.getResponse().sendRedirect(re.getRedirectURL()); ictx.getResponse().sendRedirect(re.getRedirectURL());
return null; return null;
} catch (HttpErrorException hee) { } catch (HttpErrorException hee) {
String msg = hee.getErrorMessage(); String msg = hee.getErrorMessage();
if (msg != null) { if (msg != null) {
ictx.getResponse().sendError(hee.getErrorCode(), msg); ictx.getResponse().sendError(hee.getErrorCode(), msg);
@@ -364,13 +375,13 @@ public class DispatcherServlet extends VelocityServlet
} }
return null; return null;
} catch (FriendlyException fe) { } catch (FriendlyException fe) {
// grab the error message, we'll deal with it shortly // grab the error message, we'll deal with it shortly
errmsg = fe.getMessage(); errmsg = fe.getMessage();
} catch (Exception e) { } catch (Exception e) {
errmsg = _app.handleException(req, logic, e); errmsg = _app.handleException(req, logic, e);
} }
// if we have an error message, insert it into the template // if we have an error message, insert it into the template
if (errmsg != null) { if (errmsg != null) {
@@ -380,10 +391,10 @@ public class DispatcherServlet extends VelocityServlet
if (msgmgr != null) { if (msgmgr != null) {
errmsg = msgmgr.getMessage(req, errmsg); errmsg = msgmgr.getMessage(req, errmsg);
} }
ictx.put(ERROR_KEY, errmsg); ictx.put(ERROR_KEY, errmsg);
} }
return tmpl; return tmpl;
} }
/** /**
@@ -439,7 +450,7 @@ public class DispatcherServlet extends VelocityServlet
// with the site identifier // with the site identifier
path = siteId + ":" + path; path = siteId + ":" + path;
} }
// Log.info("Loading template [path=" + path + "]."); // Log.info("Loading template [path=" + path + "].");
return RuntimeSingleton.getRuntimeServices().getTemplate(path); return RuntimeSingleton.getRuntimeServices().getTemplate(path);
} }
@@ -452,36 +463,36 @@ public class DispatcherServlet extends VelocityServlet
*/ */
protected Logic resolveLogic (String path) protected Logic resolveLogic (String path)
{ {
// look for a cached logic instance // look for a cached logic instance
String lclass = _app.generateClass(path); String lclass = _app.generateClass(path);
Logic logic = (Logic)_logic.get(lclass); Logic logic = (Logic)_logic.get(lclass);
if (logic == null) { if (logic == null) {
try { try {
Class pcl = Class.forName(lclass); Class pcl = Class.forName(lclass);
logic = (Logic)pcl.newInstance(); logic = (Logic)pcl.newInstance();
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
// nothing interesting to report // nothing interesting to report
} catch (Throwable t) { } catch (Throwable t) {
Log.warning("Unable to instantiate logic for application " + Log.warning("Unable to instantiate logic for application " +
"[path=" + path + ", lclass=" + lclass + "]."); "[path=" + path + ", lclass=" + lclass + "].");
Log.logStackTrace(t); Log.logStackTrace(t);
} }
// if something failed, use a dummy in it's place so that we // if something failed, use a dummy in it's place so that we
// don't sit around all day freaking out about our inability // don't sit around all day freaking out about our inability
// to instantiate the proper logic class // to instantiate the proper logic class
if (logic == null) { if (logic == null) {
logic = new DummyLogic(); logic = new DummyLogic();
} }
// cache the resolved logic instance // cache the resolved logic instance
_logic.put(lclass, logic); _logic.put(lclass, logic);
} }
return logic; return logic;
} }
/** The application being served by this dispatcher servlet. */ /** The application being served by this dispatcher servlet. */