001: /*
002: * (C) Copyright 2003 Nabh Information Systems, Inc.
003: *
004: * All copyright notices regarding Nabh's products MUST remain
005: * intact in the scripts and in the outputted HTML.
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package com.nabhinc.core;
023:
024: import org.apache.commons.logging.Log;
025: import org.apache.commons.logging.LogFactory;
026:
027: import javax.servlet.ServletConfig;
028: import javax.servlet.ServletException;
029: import javax.servlet.http.HttpServlet;
030:
031: /**
032: * Root class of StringBeans servlets. At present only defines
033: * logging methods.
034: *
035: * @author Padmanabh Dabke
036: * (c) 2001,2003 Nabh Information Systems, Inc. All Rights Reserved.
037: */
038: public class AbstractServlet extends HttpServlet {
039:
040: /**
041: * Comment for <code>serialVersionUID</code>
042: */
043: private static final long serialVersionUID = 3257566196240233781L;
044:
045: /**
046: * Default logger for the servlet
047: */
048: private Log asLogger = null; //LogFactory.getLog(this.getClass());
049:
050: public void init(ServletConfig config) throws ServletException {
051: super .init(config);
052: // System.setProperty("stringbeans.home", config.getServletContext().getRealPath(""));
053: asLogger = LogFactory.getLog(this .getClass());
054: }
055:
056: /**
057: * Do nothing constructor.
058: */
059: public AbstractServlet() {
060: super ();
061: }
062:
063: /**
064: * Logs a debug message.
065: * @param msg Message to be logged
066: */
067: public void debug(String msg) {
068: asLogger.debug(msg);
069: }
070:
071: /**
072: * Logs informational message.
073: * @param msg Message to be logged
074: */
075: public void info(String msg) {
076: asLogger.info(msg);
077: }
078:
079: /**
080: * Logs an error message.
081: * @param msg Message to be logged
082: */
083: public void error(String msg) {
084: asLogger.error(msg);
085: }
086:
087: /**
088: * Logs an error message.
089: * @param msg Message to be logged
090: */
091: public void error(String msg, Throwable t) {
092: asLogger.error(msg, t);
093: }
094:
095: /**
096: * Logs a warning message.
097: * @param msg Message to be logged
098: */
099: public void warn(String msg) {
100: asLogger.warn(msg);
101: }
102:
103: /**
104: * Logs a warning message.
105: * @param msg Message to be logged
106: */
107: public void warn(String msg, Throwable t) {
108: asLogger.warn(msg, t);
109: }
110:
111: public void fatal(String msg) {
112: asLogger.fatal(msg);
113: }
114:
115: public void fatal(String msg, Throwable t) {
116: asLogger.fatal(msg, t);
117: }
118:
119: public void trace(Object msg) {
120: asLogger.trace(msg);
121: }
122:
123: public void trace(Object msg, Throwable err) {
124: asLogger.trace(msg, err);
125: }
126:
127: }
|