Added convenience functions to Log that allow callers to use Log.info()
rather than Log.log.info(), etc. git-svn-id: https://samskivert.googlecode.com/svn/trunk@50 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DispatcherServlet.java,v 1.1 2001/02/15 01:44:34 mdb Exp $
|
// $Id: DispatcherServlet.java,v 1.2 2001/02/16 03:27:54 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.webmacro;
|
package com.samskivert.webmacro;
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public class DispatcherServlet extends WMServlet
|
|||||||
public void start ()
|
public void start ()
|
||||||
throws ServletException
|
throws ServletException
|
||||||
{
|
{
|
||||||
// Log.log.info("Initializing dispatcher servlet.");
|
// Log.info("Initializing dispatcher servlet.");
|
||||||
|
|
||||||
// first load the properties file
|
// first load the properties file
|
||||||
Properties props = null;
|
Properties props = null;
|
||||||
@@ -129,15 +129,14 @@ public class DispatcherServlet extends WMServlet
|
|||||||
props = ConfigUtil.loadProperties("dispatcher.properties", cld);
|
props = ConfigUtil.loadProperties("dispatcher.properties", cld);
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.log.warning("Failure trying to load " +
|
Log.warning("Failure trying to load 'dispatcher.properties': " +
|
||||||
"'dispatcher.properties': " + ioe);
|
ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props == null) {
|
if (props == null) {
|
||||||
Log.log.warning("Unable to load properties for " +
|
Log.warning("Unable to load properties for dispatcher servlet.");
|
||||||
"dispatcher servlet.");
|
Log.warning("Make sure 'dispatcher.properties' file exists " +
|
||||||
Log.log.warning("Make sure 'dispatcher.properties' file " +
|
"somewhere in your classpath.");
|
||||||
"exists somewhere in your classpath.");
|
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,13 +151,13 @@ public class DispatcherServlet extends WMServlet
|
|||||||
|
|
||||||
// make sure we're not missing anything
|
// make sure we're not missing anything
|
||||||
if (baseURI == null) {
|
if (baseURI == null) {
|
||||||
Log.log.warning("Application '" + appid +
|
Log.warning("Application '" + appid + "' missing " +
|
||||||
"' missing base_uri specification.");
|
"base_uri specification.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (basePkg == null) {
|
if (basePkg == null) {
|
||||||
Log.log.warning("Application '" + appid +
|
Log.warning("Application '" + appid + "' missing " +
|
||||||
"' missing base_pkg specification.");
|
"base_pkg specification.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +177,10 @@ public class DispatcherServlet extends WMServlet
|
|||||||
throw new HandlerException("Unable to load template: " + e);
|
throw new HandlerException("Unable to load template: " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assume an HTML response unless otherwise massaged by the data
|
||||||
|
// populator
|
||||||
|
ctx.getResponse().setContentType("text/html");
|
||||||
|
|
||||||
// then we populate the context with data
|
// then we populate the context with data
|
||||||
try {
|
try {
|
||||||
ContextPopulator pop = selectPopulator(ctx);
|
ContextPopulator pop = selectPopulator(ctx);
|
||||||
@@ -214,7 +217,7 @@ public class DispatcherServlet extends WMServlet
|
|||||||
throws NotFoundException
|
throws NotFoundException
|
||||||
{
|
{
|
||||||
String path = cleanupURI(ctx.getRequest().getRequestURI());
|
String path = cleanupURI(ctx.getRequest().getRequestURI());
|
||||||
// Log.log.info("Loading template [path=" + path + "].");
|
// Log.info("Loading template [path=" + path + "].");
|
||||||
return getTemplate(path);
|
return getTemplate(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +237,7 @@ public class DispatcherServlet extends WMServlet
|
|||||||
{
|
{
|
||||||
String path = cleanupURI(ctx.getRequest().getRequestURI());
|
String path = cleanupURI(ctx.getRequest().getRequestURI());
|
||||||
String pclass = null;
|
String pclass = null;
|
||||||
// Log.log.info("Loading populator [path=" + path + "].");
|
// Log.info("Loading populator [path=" + path + "].");
|
||||||
|
|
||||||
// try to locate an application that matches this URI
|
// try to locate an application that matches this URI
|
||||||
for (int i = 0; i < _apps.size(); i++) {
|
for (int i = 0; i < _apps.size(); i++) {
|
||||||
@@ -258,9 +261,9 @@ public class DispatcherServlet extends WMServlet
|
|||||||
pop = (ContextPopulator)pcl.newInstance();
|
pop = (ContextPopulator)pcl.newInstance();
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.log.warning("Unable to instantiate populator for " +
|
Log.warning("Unable to instantiate populator for " +
|
||||||
"matching application [path=" + path +
|
"matching application [path=" + path +
|
||||||
", pclass=" + pclass + ", error=" + t + "].");
|
", pclass=" + pclass + ", error=" + t + "].");
|
||||||
// use a dummy in it's place so that we don't sit around
|
// use a dummy in it's place so that we don't sit around
|
||||||
// all day freaking out about our inability to instantiate
|
// all day freaking out about our inability to instantiate
|
||||||
// the proper populator class
|
// the proper populator class
|
||||||
@@ -288,7 +291,7 @@ public class DispatcherServlet extends WMServlet
|
|||||||
|
|
||||||
int sidx = uri.indexOf("/", dsidx + 2);
|
int sidx = uri.indexOf("/", dsidx + 2);
|
||||||
if (sidx == -1) {
|
if (sidx == -1) {
|
||||||
Log.log.warning("Malformed URI?! [uri=" + uri + "].");
|
Log.warning("Malformed URI?! [uri=" + uri + "].");
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ExceptionMap.java,v 1.2 2001/02/15 01:44:34 mdb Exp $
|
// $Id: ExceptionMap.java,v 1.3 2001/02/16 03:27:54 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.webmacro;
|
package com.samskivert.webmacro;
|
||||||
|
|
||||||
@@ -72,8 +72,7 @@ public class ExceptionMap
|
|||||||
ClassLoader cld = ExceptionMap.class.getClassLoader();
|
ClassLoader cld = ExceptionMap.class.getClassLoader();
|
||||||
InputStream config = ConfigUtil.getStream(PROPS_NAME, cld);
|
InputStream config = ConfigUtil.getStream(PROPS_NAME, cld);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
Log.log.warning("Unable to load " + PROPS_NAME +
|
Log.warning("Unable to load " + PROPS_NAME + " from CLASSPATH.");
|
||||||
" from CLASSPATH.");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// otherwise process ye old config file.
|
// otherwise process ye old config file.
|
||||||
@@ -101,9 +100,9 @@ public class ExceptionMap
|
|||||||
_keys.set(i, cl);
|
_keys.set(i, cl);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.log.warning("Unable to resolve exception " +
|
Log.warning("Unable to resolve exception class. " +
|
||||||
"class. [class=" + exclass +
|
"[class=" + exclass +
|
||||||
", error=" + t + "].");
|
", error=" + t + "].");
|
||||||
_keys.remove(i);
|
_keys.remove(i);
|
||||||
_values.remove(i);
|
_values.remove(i);
|
||||||
i--; // back on up a notch
|
i--; // back on up a notch
|
||||||
@@ -111,8 +110,7 @@ public class ExceptionMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.log.warning("Error reading exception mapping file: " +
|
Log.warning("Error reading exception mapping file: " + ioe);
|
||||||
ioe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Log.java,v 1.1 2001/02/13 20:00:28 mdb Exp $
|
// $Id: Log.java,v 1.2 2001/02/16 03:27:54 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.webmacro;
|
package com.samskivert.webmacro;
|
||||||
|
|
||||||
@@ -11,4 +11,22 @@ public class Log
|
|||||||
{
|
{
|
||||||
public static com.samskivert.util.Log log =
|
public static com.samskivert.util.Log log =
|
||||||
new com.samskivert.util.Log("com.samskivert.webmacro");
|
new com.samskivert.util.Log("com.samskivert.webmacro");
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void debug (String message)
|
||||||
|
{
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void info (String message)
|
||||||
|
{
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void warning (String message)
|
||||||
|
{
|
||||||
|
log.warning(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user