dwinterfeldt    02/02/25 19:38:57

  Modified:    src/share/org/apache/struts/action ActionServlet.java
                        RequestProcessor.java
               src/share/org/apache/struts/actions DispatchAction.java
               src/share/org/apache/struts/upload
                        DiskMultipartRequestHandler.java
               src/share/org/apache/struts/util GenericDataSource.java
                        MessageResources.java MessageResourcesFactory.java
                        RequestUtils.java
  Log:
  Changed logging to use Commons Logging package.
  
  Revision  Changes    Path
  1.93      +48 -35    
jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- ActionServlet.java        23 Feb 2002 22:54:17 -0000      1.92
  +++ ActionServlet.java        26 Feb 2002 03:38:56 -0000      1.93
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.92 
2002/02/23 22:54:17 craigmcc Exp $
  - * $Revision: 1.92 $
  - * $Date: 2002/02/23 22:54:17 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.93 
2002/02/26 03:38:56 dwinterfeldt Exp $
  + * $Revision: 1.93 $
  + * $Date: 2002/02/26 03:38:56 $
    *
    * ====================================================================
    *
  @@ -86,6 +86,8 @@
   import org.apache.commons.collections.FastHashMap;
   import org.apache.commons.digester.Digester;
   import org.apache.commons.digester.Rule;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.config.ActionConfig;
   import org.apache.struts.config.ApplicationConfig;
   import org.apache.struts.config.ConfigRuleSet;
  @@ -267,7 +269,7 @@
    *
    * @author Craig R. McClanahan
    * @author Ted Husted
  - * @version $Revision: 1.92 $ $Date: 2002/02/23 22:54:17 $
  + * @version $Revision: 1.93 $ $Date: 2002/02/26 03:38:56 $
    */
   
   public class ActionServlet
  @@ -276,7 +278,11 @@
   
       // ----------------------------------------------------- Instance Variables
   
  -
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +    
       /**
        * The context-relative path to our configuration resource for the
        * default sub-application.
  @@ -377,8 +383,8 @@
        */
       public void destroy() {
   
  -        if (debug >= 1) {
  -            log(internal.getMessage("finalizing"));
  +        if (log.isDebugEnabled()) {
  +            log.debug(internal.getMessage("finalizing"));
           }
   
           destroyApplications();
  @@ -476,13 +482,16 @@
        */
       public void addServletMapping(String servletName, String urlPattern) {
   
  -        if (debug >= 1)
  -            log("Process servletName=" + servletName +
  -                ", urlPattern=" + urlPattern);
  -        if (servletName == null)
  +        if (log.isDebugEnabled()) {
  +            log.debug("Process servletName=" + servletName +
  +                      ", urlPattern=" + urlPattern);
  +        }
  +        if (servletName == null) {
               return;
  -        if (servletName.equals(this.servletName))
  +        }
  +        if (servletName.equals(this.servletName)) {
               this.servletMapping = urlPattern;
  +        }
   
       }
   
  @@ -612,8 +621,9 @@
        */
       public void log(String message, int level) {
   
  -        if (debug >= level)
  +        if (debug >= level) {
               log(message);
  +        }
   
       }
   
  @@ -679,12 +689,13 @@
                   getServletContext().removeAttribute(key);
                   DataSource dataSource = findDataSource(key);
                   if (dataSource instanceof GenericDataSource) {
  -                    if (debug >= 1)
  -                        log(internal.getMessage("dataSource.destroy", key));
  +                    if (log.isDebugEnabled()) {
  +                        log.debug(internal.getMessage("dataSource.destroy", key));
  +                    }
                       try {
                           ((GenericDataSource) dataSource).close();
                       } catch (SQLException e) {
  -                        log(internal.getMessage("destroyDataSource", key), e);
  +                        log.error(internal.getMessage("destroyDataSource", key), e);
                       }
                   }
               }
  @@ -737,8 +748,8 @@
       protected ApplicationConfig initApplicationConfig
           (String prefix, String path) throws ServletException {
   
  -        if (debug >= 1) {
  -            log("Initializing application path '" + prefix +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Initializing application path '" + prefix +
                   "' configuration from '" + path + "'");
           }
   
  @@ -756,7 +767,7 @@
               getServletContext().setAttribute
                   (Action.APPLICATION_KEY + prefix, config);
           } catch (Throwable t) {
  -            log(internal.getMessage("configParse", path), t);
  +            log.error(internal.getMessage("configParse", path), t);
               throw new UnavailableException
                   (internal.getMessage("configParse", path));
           } finally {
  @@ -797,8 +808,8 @@
       protected void initApplicationDataSources
           (ApplicationConfig config) throws ServletException {
   
  -        if (debug >= 1) {
  -            log("Initializing application path '" + config.getPrefix() +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Initializing application path '" + config.getPrefix() +
                   "' data sources");
           }
   
  @@ -811,8 +822,8 @@
   
           dataSources.setFast(false);
           for (int i = 0; i < dscs.length; i++) {
  -            if (debug >= 1) {
  -                log("Initializing application path '" + config.getPrefix() +
  +            if (log.isDebugEnabled()) {
  +                log.debug("Initializing application path '" + config.getPrefix() +
                       "' data source '" + dscs[i].getKey() + "'");
               }
               DataSource ds = null;
  @@ -825,7 +836,7 @@
                       ((GenericDataSource) ds).open();
                   }
               } catch (Throwable t) {
  -                log(internal.getMessage
  +                log.error(internal.getMessage
                       ("dataSource.init", dscs[i].getKey()), t);
                   throw new UnavailableException
                       (internal.getMessage("dataSource.init", dscs[i].getKey()));
  @@ -854,8 +865,8 @@
       protected void initApplicationPlugIns
           (ApplicationConfig config) throws ServletException {
   
  -        if (debug >= 1) {
  -            log("Initializing application path '" + config.getPrefix() +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Initializing application path '" + config.getPrefix() +
                   "' plug ins");
           }
   
  @@ -886,8 +897,8 @@
                   (mrcs[i].getParameter() == null)) {
                   continue;
               }
  -            if (debug >= 1) {
  -                log("Initializing application path '" + config.getPrefix() +
  +            if (log.isDebugEnabled()) {
  +                log.debug("Initializing application path '" + config.getPrefix() +
                       "' message resources from '" +
                       mrcs[i].getParameter() + "'");
               }
  @@ -903,7 +914,7 @@
                   getServletContext().setAttribute
                       (mrcs[i].getKey() + config.getPrefix(), resources);
               } catch (Throwable t) {
  -                log(internal.getMessage
  +                log.error(internal.getMessage
                       ("applicationResources", mrcs[i].getParameter()), t);
                   throw new UnavailableException
                       (internal.getMessage
  @@ -967,7 +978,7 @@
           try {
               internal = MessageResources.getMessageResources(internalName);
           } catch (MissingResourceException e) {
  -            log("Cannot load internal resources from '" + internalName + "'",
  +            log.error("Cannot load internal resources from '" + internalName + "'",
                   e);
               throw new UnavailableException
                   ("Cannot load internal resources from '" + internalName + "'");
  @@ -1043,24 +1054,26 @@
           digester.addCallParam("web-app/servlet-mapping/url-pattern", 1);
   
           // Process the web application deployment descriptor
  -        if (debug >= 1)
  -            log("Scanning web.xml for controller servlet mapping");
  +        if (log.isDebugEnabled()) {
  +            log.debug("Scanning web.xml for controller servlet mapping");
  +        }
           InputStream input= null;
           try {
               input =
                   getServletContext().getResourceAsStream("/WEB-INF/web.xml");
               digester.parse(input);
           } catch (Throwable e) {
  -            log(internal.getMessage("configWebXml"), e);
  +            log.error(internal.getMessage("configWebXml"), e);
           } finally {
               if (input != null)
                   input = null;
           }
   
           // Record a servlet context attribute (if appropriate)
  -        if (debug >= 1)
  -            log("Mapping for servlet '" + servletName + "' = '" +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Mapping for servlet '" + servletName + "' = '" +
                   servletMapping + "'");
  +        }
           if (servletMapping != null)
               getServletContext().setAttribute(Action.SERVLET_KEY,
                                                servletMapping);
  
  
  
  1.4       +49 -43    
jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java
  
  Index: RequestProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestProcessor.java     7 Feb 2002 14:02:22 -0000       1.3
  +++ RequestProcessor.java     26 Feb 2002 03:38:56 -0000      1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v 
1.3 2002/02/07 14:02:22 cedric Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/07 14:02:22 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v 
1.4 2002/02/26 03:38:56 dwinterfeldt Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/26 03:38:56 $
    *
    * ====================================================================
    *
  @@ -73,6 +73,8 @@
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
   import org.apache.commons.collections.FastHashMap;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.config.ActionConfig;
   import org.apache.struts.config.ApplicationConfig;
   import org.apache.struts.config.ControllerConfig;
  @@ -92,7 +94,7 @@
    * interested in changing.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2002/02/07 14:02:22 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/26 03:38:56 $
    * @since Struts 1.1
    */
   
  @@ -120,6 +122,10 @@
   
       // ----------------------------------------------------- Instance Variables
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
        * The set of Action instances that have been created and initialized,
  @@ -205,8 +211,8 @@
           if (path == null) {
               return;
           }
  -        if (getDebug() >= 1) {
  -            log("Processing a '" + request.getMethod() +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Processing a '" + request.getMethod() +
                   "' for path '" + path + "'");
           }
   
  @@ -285,21 +291,21 @@
   
           // Acquire the Action instance we will be using (if there is one)
           String className = mapping.getType();
  -        if (getDebug() >= 2) {
  -            log(" Looking for Action instance for class " + className);
  +        if (log.isInfoEnabled()) {
  +            log.info(" Looking for Action instance for class " + className);
           }
           Action instance = (Action) actions.get(className);
           if (instance != null) {
  -            if (getDebug() >= 2) {
  -                log(" Returning existing Action instance of class '" +
  +            if (log.isInfoEnabled()) {
  +                log.info(" Returning existing Action instance of class '" +
                       className + "'");
               }
               return (instance);
           }
   
           // Create a new Action instance if necessary
  -        if (getDebug() >= 2) {
  -            log(" Creating new Action instance of class '" +
  +        if (log.isInfoEnabled()) {
  +            log.info(" Creating new Action instance of class '" +
                   className + "'");
           }
           synchronized (actions) {
  @@ -309,7 +315,7 @@
                   instance.setServlet(this.servlet);
                   actions.put(className, instance);
               } catch (Throwable t) {
  -                log(getInternal().getMessage("actionCreate",
  +                log.error(getInternal().getMessage("actionCreate",
                                                mapping.getPath()), t);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  @@ -343,8 +349,8 @@
           }
   
           // Store the new instance in the appropriate scope
  -        if (getDebug() >= 2) {
  -            log(" Storing ActionForm bean instance in scope '" +
  +        if (log.isInfoEnabled()) {
  +            log.info(" Storing ActionForm bean instance in scope '" +
                   mapping.getScope() + "' under attribute key '" +
                   mapping.getAttribute() + "'");
           }
  @@ -478,8 +484,8 @@
           // Is there a defined handler for this exception?
           ExceptionConfig config = mapping.findException(exception.getClass());
           if (config == null) {
  -            if (getDebug() >= 1) {
  -                log(getInternal().getMessage("unhandledException",
  +            if (log.isDebugEnabled()) {
  +                log.debug(getInternal().getMessage("unhandledException",
                                                exception.getClass()));
               }
               if (exception instanceof IOException) {
  @@ -535,8 +541,8 @@
   
           // Delegate the processing of this request
           // FIXME - exception handling?
  -        if (getDebug() >= 2) {
  -            log(" Delegating via forward to '" + uri + "'");
  +        if (log.isInfoEnabled()) {
  +            log.info(" Delegating via forward to '" + uri + "'");
           }
           doForward(uri, request, response);
           return (false);
  @@ -574,8 +580,8 @@
   
           // Delegate the processing of this request
           // FIXME - exception handling?
  -        if (getDebug() >= 2) {
  -            log(" Delegating via forward to '" + uri + "'");
  +        if (log.isInfoEnabled()) {
  +            log.info(" Delegating via forward to '" + uri + "'");
           }
           doInclude(uri, request, response);
           return (false);
  @@ -608,8 +614,8 @@
           // Use the Locale returned by the servlet container (if any)
           Locale locale = request.getLocale();
           if (locale != null) {
  -            if (getDebug() >= 2) {
  -                log("Setting user locale '" + locale + "'");
  +            if (log.isInfoEnabled()) {
  +                log.info("Setting user locale '" + locale + "'");
               }
               session.setAttribute(Action.LOCALE_KEY, locale);
           }
  @@ -652,7 +658,7 @@
           }
   
           // No mapping can be found to process this request
  -        log(getInternal().getMessage("processInvalid", path));
  +        log.error(getInternal().getMessage("processInvalid", path));
           response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                              getInternal().getMessage
                              ("processInvalid", path));
  @@ -737,7 +743,7 @@
           }
           String prefix = appConfig.getPrefix();
           if (!path.startsWith(prefix)) {
  -            log(getInternal().getMessage("processPath",
  +            log.error(getInternal().getMessage("processPath",
                                            request.getRequestURI()));
               response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                                  getInternal().getMessage
  @@ -777,8 +783,8 @@
           }
   
           // Populate the bean properties of this ActionForm instance
  -        if (getDebug() >= 2) {
  -            log(" Populating bean properties from this request");
  +        if (log.isInfoEnabled()) {
  +            log.info(" Populating bean properties from this request");
           }
           form.reset(mapping, request);
           if (mapping.getMultipartClass() != null) {
  @@ -836,8 +842,8 @@
           // Check the current user against the list of required roles
           for (int i = 0; i < roles.length; i++) {
               if (request.isUserInRole(roles[i])) {
  -                if (getDebug() >= 2) {
  -                    log(" User '" + request.getRemoteUser() +
  +                if (log.isInfoEnabled()) {
  +                    log.info(" User '" + request.getRemoteUser() +
                           "' has role '" + roles[i] + "', granting access");
                   }
                   return (true);
  @@ -845,8 +851,8 @@
           }
   
           // The current user is not authorized for this action
  -        if (getDebug() >= 2) {
  -            log(" User '" + request.getRemoteUser() +
  +        if (log.isInfoEnabled()) {
  +            log.info(" User '" + request.getRemoteUser() +
                   "' does not have any required role, denying access");
           }
           response.sendError(HttpServletResponse.SC_BAD_REQUEST,
  @@ -885,8 +891,8 @@
           // Was this submit cancelled?
           if ((request.getParameter(Constants.CANCEL_PROPERTY) != null) ||
               (request.getParameter(Constants.CANCEL_PROPERTY_X) != null)) {
  -            if (getDebug() >= 2) {
  -                log(" Cancelled transaction, skipping validation");
  +            if (log.isInfoEnabled()) {
  +                log.info(" Cancelled transaction, skipping validation");
               }
               return (true);
           }
  @@ -897,21 +903,21 @@
           }
   
           // Call the form bean's validation method
  -        if (getDebug() >= 2) {
  -            log(" Validating input form properties");
  +        if (log.isInfoEnabled()) {
  +            log.info(" Validating input form properties");
           }
           ActionErrors errors = form.validate(mapping, request);
           if ((errors == null) || errors.empty()) {
  -            if (getDebug() >= 2) {
  -                log("  No errors detected, accepting input");
  +            if (log.isInfoEnabled()) {
  +                log.info("  No errors detected, accepting input");
               }
               return (true);
           }
   
           // Special handling for multipart request
           if (form.getMultipartRequestHandler() != null) {
  -            if (getDebug() >= 2) {
  -                log("  Rolling back multipart request");
  +            if (log.isInfoEnabled()) {
  +                log.info("  Rolling back multipart request");
               }
               form.getMultipartRequestHandler().rollback();
           }
  @@ -919,8 +925,8 @@
           // Has an input form been specified for this mapping?
           String input = mapping.getInput();
           if (input == null) {
  -            if (getDebug() >= 2) {
  -                log(" Validation failed but no input form available");
  +            if (log.isInfoEnabled()) {
  +                log.info(" Validation failed but no input form available");
               }
               response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                  getInternal().getMessage("noInput",
  @@ -929,8 +935,8 @@
           }
   
           // Save our error messages and return to the input form if possible
  -        if (getDebug() >= 2) {
  -            log(" Validation failed, returning to '" + input + "'");
  +        if (log.isInfoEnabled()) {
  +            log.info(" Validation failed, returning to '" + input + "'");
           }
           request.setAttribute(Action.ERROR_KEY, errors);
           if (request instanceof MultipartRequestWrapper) {
  
  
  
  1.4       +16 -10    
jakarta-struts/src/share/org/apache/struts/actions/DispatchAction.java
  
  Index: DispatchAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/actions/DispatchAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DispatchAction.java       28 Nov 2001 17:22:58 -0000      1.3
  +++ DispatchAction.java       26 Feb 2002 03:38:57 -0000      1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/actions/DispatchAction.java,v 1.3 
2001/11/28 17:22:58 husted Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/11/28 17:22:58 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/actions/DispatchAction.java,v 1.4 
2002/02/26 03:38:57 dwinterfeldt Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/26 03:38:57 $
    *
    * ====================================================================
    *
  @@ -72,6 +72,8 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionForward;
  @@ -128,7 +130,7 @@
    * @author Niall Pemberton <[EMAIL PROTECTED]>
    * @author Craig R. McClanahan
    * @author Ted Husted
  - * @version $Revision: 1.3 $ $Date: 2001/11/28 17:22:58 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/26 03:38:57 $
    */
   
   public abstract class DispatchAction extends Action {
  @@ -136,6 +138,10 @@
   
       // ----------------------------------------------------- Instance Variables
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
        * The Class instance of this <code>DispatchAction</code> class.
  @@ -189,7 +195,7 @@
               String message =
                   messages.getMessage("dispatch.method", mapping.getPath(),
                                       name);
  -            servlet.log(message);
  +            log.error(message, e);
               response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                  message);
               return (null);
  @@ -203,7 +209,7 @@
               String message =
                   messages.getMessage("dispatch.return", mapping.getPath(),
                                       name);
  -            servlet.log(message);
  +            log.error(message, e);
               response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                  message);
               return (null);
  @@ -211,7 +217,7 @@
               String message =
                   messages.getMessage("dispatch.error", mapping.getPath(),
                                       name);
  -            servlet.log(message, e);
  +            log.error(message, e);
               response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                  message);
               return (null);
  @@ -219,7 +225,7 @@
               String message =
                   messages.getMessage("dispatch.error", mapping.getPath(),
                                       name);
  -            servlet.log(message, e);
  +            log.error(message, e);
               response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                  message);
               return (null);
  @@ -259,7 +265,7 @@
           if (parameter == null) {
               String message =
                   messages.getMessage("dispatch.handler", mapping.getPath());
  -            servlet.log(message);
  +            log.error(message);
               response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                  message);
               return (null);
  @@ -271,7 +277,7 @@
               String message =
                   messages.getMessage("dispatch.parameter", mapping.getPath(),
                                       parameter);
  -            servlet.log(message);
  +            log.error(message);
               response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                                  message);
               return (null);
  
  
  
  1.12      +8 -1      
jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java
  
  Index: DiskMultipartRequestHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DiskMultipartRequestHandler.java  13 Jan 2002 00:25:37 -0000      1.11
  +++ DiskMultipartRequestHandler.java  26 Feb 2002 03:38:57 -0000      1.12
  @@ -10,6 +10,8 @@
   import javax.servlet.ServletContext;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionServlet;
   import org.apache.struts.action.ActionMapping;
  @@ -24,6 +26,11 @@
   public class DiskMultipartRequestHandler implements MultipartRequestHandler {
   
       /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +    
  +    /**
        * The ActionServlet instance used for this class
        */
       protected ActionServlet servlet;
  @@ -226,7 +233,7 @@
                   tempDir = System.getProperty("java.io.tmpdir");
   
                   if (appConfig.getServlet().getDebug() > 1) {
  -                    servlet.log("DiskMultipartRequestHandler.handleRequest(): " +
  +                    log.debug("DiskMultipartRequestHandler.handleRequest(): " +
                       "defaulting to java.io.tmpdir directory \"" +
                       tempDir);
                   }
  
  
  
  1.8       +78 -44    
jakarta-struts/src/share/org/apache/struts/util/GenericDataSource.java
  
  Index: GenericDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/GenericDataSource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- GenericDataSource.java    10 Jun 2001 03:37:26 -0000      1.7
  +++ GenericDataSource.java    26 Feb 2002 03:38:57 -0000      1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/GenericDataSource.java,v 1.7 
2001/06/10 03:37:26 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/06/10 03:37:26 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/GenericDataSource.java,v 1.8 
2002/02/26 03:38:57 dwinterfeldt Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/02/26 03:38:57 $
    *
    * ====================================================================
    *
  @@ -72,6 +72,8 @@
   import java.util.LinkedList;
   import java.util.Properties;
   import javax.sql.DataSource;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   
   
   /**
  @@ -178,7 +180,7 @@
    *
    * @author Craig R. McClanahan
    * @author Ted Husted
  - * @version $Revision: 1.7 $ $Date: 2001/06/10 03:37:26 $
  + * @version $Revision: 1.8 $ $Date: 2002/02/26 03:38:57 $
    */
   
   public class GenericDataSource implements DataSource {
  @@ -186,6 +188,11 @@
   
       // ----------------------------------------------------- Instance Constants
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
  +
   
       private static final String SQLEXCEPTION_GETCONNECTION =
        "getConnection(String username, String password)  Method not supported. Use 
getConnection() instead.";
  @@ -449,23 +456,28 @@
       public Connection getConnection() throws SQLException {
   
           int seconds = 0;
  -        if (debug >= 2)
  -            log("  getConnection()");
  +        if (log.isInfoEnabled()) {
  +            log.info("  getConnection()");
  +        }
   
           // Validate the opened status of this data source
  -        if (closed)
  +        if (closed) {
               throw new SQLException("getConnection:  Data source is closed");
  -        if (driver == null)
  +        }
  +        if (driver == null) {
               open();
  +        }
   
           while (true) {
   
               // Have we timed out yet?
  -            if (debug >= 3)
  -                log("   Check for timeout, activeCount=" + activeCount +
  +            if (log.isInfoEnabled()) {
  +                log.info("   Check for timeout, activeCount=" + activeCount +
                       ", useCount=" + useCount);
  -            if ((loginTimeout > 0) && (seconds >= loginTimeout))
  +            }
  +            if ((loginTimeout > 0) && (seconds >= loginTimeout)) {
                   break;
  +            }
   
               // Return an existing connection from the pool if there is one
               synchronized (connections) {
  @@ -474,16 +486,16 @@
                       // Allocate the first available connection
                       GenericConnection connection =
                           (GenericConnection) connections.removeFirst();
  -                    if (debug >= 3)
  -                        log("   Found available connection");
  +                    if (log.isInfoEnabled()) {
  +                        log.info("   Found available connection");
  +                    }
   
                       // Make sure this connection is not stale
                       connection.setClosed(false);
                       try {
                           ping(connection);
                       } catch (SQLException e) {
  -                        if (debug >= 3)
  -                            log("   Connection stale, releasing");
  +                        log.warn("   Connection stale, releasing");
                           try {
                               connection.getConnection().close();
                           } catch (SQLException f) {
  @@ -495,9 +507,11 @@
   
                       // unclose the connection's wrapper and return it
                       useCount++;
  -                    if (debug >= 3)
  -                        log("   Return allocated connection, activeCount=" +
  -                            activeCount + ", useCount=" + useCount);
  +                    if (log.isInfoEnabled()) {
  +                        log.info("   Return allocated connection, activeCount=" +
  +                                 activeCount + ", useCount=" + useCount);
  +                    }
  +                    
                       return(connection);
   
                   }
  @@ -513,16 +527,19 @@
                           throw e;
                       }
                       useCount++;
  -                    if (debug >= 3)
  -                        log("   Return new connection, activeCount=" +
  -                            activeCount + ", useCount=" + useCount);
  +                    if (log.isInfoEnabled()) {
  +                        log.info("   Return new connection, activeCount=" +
  +                                 activeCount + ", useCount=" + useCount);
  +                    }
  +                    
                       return (connection);
                   }
               }
   
               // Wait for an existing connection to be returned
  -            if (debug >= 3)
  -                log("   Sleep until next test");
  +            if (log.isInfoEnabled()) {
  +                log.info("   Sleep until next test");
  +            }
               try {
                   Thread.sleep(1000);
                   seconds++;
  @@ -533,8 +550,9 @@
           }
   
           // We have timed out awaiting an available connection
  -        if (debug >= 3)
  -            log("   Timeout awaiting connection");
  +        if (log.isInfoEnabled()) {
  +            log.info("   Timeout awaiting connection");
  +        }
           throw new SQLException
               ("getConnection: Timeout awaiting connection");
   
  @@ -576,6 +594,8 @@
        * Return the log writer for this data source.
        *
        * @exception SQLException if a database access error occurs
  +     *
  +     * @deprecated Switched to Commons Logging.
        */
       public PrintWriter getLogWriter() throws SQLException {
   
  @@ -604,6 +624,8 @@
        * @param logWriter The new log writer
        *
        * @exception SQLException if a database access error occurs
  +     *
  +     * @deprecated Switched to Commons Logging.
        */
       public void setLogWriter(PrintWriter logWriter) throws SQLException {
   
  @@ -624,8 +646,9 @@
   
           if (closed)
               throw new SQLException("close:  Data Source already closed");
  -        if (debug >= 1)
  -            log(" close()");
  +        if (log.isDebugEnabled()) {
  +            log.debug(" close()");
  +        }
   
           // Shut down all active connections
           while (activeCount > 0) {
  @@ -651,8 +674,9 @@
           // Have we already been opened?
           if (driver != null)
               return;
  -        if (debug >= 1)
  -            log(" open()");
  +        if (log.isDebugEnabled()) {
  +            log.debug(" open()");
  +        }
   
           // Instantiate our database driver
           try {
  @@ -726,14 +750,16 @@
       protected synchronized Connection createConnection() throws SQLException {
   
           if (activeCount < maxCount) {
  -            if (debug >= 3)
  -                log("   createConnection()");
  +            if (log.isInfoEnabled()) {
  +                log.info("   createConnection()");
  +            }
               Connection conn = driver.connect(url, properties);
               activeCount++;
               return (new GenericConnection(this, conn, autoCommit, readOnly));
           }
  -        if (debug >= 3)
  -            log("   createConnection() returning null");
  +        
  +        log.error("   createConnection() returning null");
  +        
           return (null);
   
       }
  @@ -743,6 +769,8 @@
        * Log the specified message to our log writer, if we have one.
        *
        * @param message The message to be logged
  +     *
  +     * @deprecated Switched to Commons Logging.
        */
       protected void log(String message) {
   
  @@ -762,6 +790,8 @@
        *
        * @param message The message to be logged
        * @param throwable The exception to be logged
  +     *
  +     * @deprecated Switched to Commons Logging.
        */
       protected void log(String message, Throwable throwable) {
   
  @@ -787,19 +817,21 @@
   
           if (pingCommand != null) {
   
  -            if (debug >= 4)
  -                log("    ping(" + pingCommand + ")");
  +            if (log.isDebugEnabled()) {
  +                log.debug("    ping(" + pingCommand + ")");
  +            }
   
               Statement stmt = conn.createStatement();
               try {
                   stmt.execute(pingCommand);
                   stmt.close();
               } catch (SQLException e) {
  -                if (debug >= 5)
  -                    log("     ping() failed:  " + e);
  +                log.warn("ping failed:  " + e.getMessage(), e);
  +
                   try {
  -                    if (stmt != null)
  +                    if (stmt != null) {
                           stmt.close();
  +                    }
                   } catch (SQLException f) {
                       ;
                   }
  @@ -810,8 +842,9 @@
   
           if (pingQuery != null) {
   
  -            if (debug >= 4)
  -                log("    ping(" + pingQuery + ")");
  +            if (log.isDebugEnabled()) {
  +                log.debug("    ping(" + pingQuery + ")");
  +            }
   
               ResultSet rs = null;
               Statement stmt = conn.createStatement();
  @@ -823,8 +856,8 @@
                   rs.close();
                   stmt.close();
               } catch (SQLException e) {
  -                if (debug >= 5)
  -                    log("     ping() failed: " + e);
  +                log.warn("ping failed: " + e.getMessage(), e);
  +                
                   try {
                       if (rs != null)
                           rs.close();
  @@ -855,9 +888,10 @@
        */
       void returnConnection(GenericConnection conn) {
   
  -        if (debug >= 2)
  -            log("  releaseConnection(), activeCount=" + activeCount +
  +        if (log.isInfoEnabled()) {
  +            log.info("  releaseConnection(), activeCount=" + activeCount +
                   ", useCount=" + (useCount - 1));
  +        }
   
           synchronized (connections) {
               connections.addLast(conn);
  
  
  
  1.12      +12 -14    
jakarta-struts/src/share/org/apache/struts/util/MessageResources.java
  
  Index: MessageResources.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResources.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MessageResources.java     6 Aug 2001 22:36:27 -0000       1.11
  +++ MessageResources.java     26 Feb 2002 03:38:57 -0000      1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResources.java,v 1.11 
2001/08/06 22:36:27 craigmcc Exp $
  - * $Revision: 1.11 $
  - * $Date: 2001/08/06 22:36:27 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResources.java,v 1.12 
2002/02/26 03:38:57 dwinterfeldt Exp $
  + * $Revision: 1.12 $
  + * $Date: 2002/02/26 03:38:57 $
    *
    * ====================================================================
    * 
  @@ -67,6 +67,8 @@
   import java.text.MessageFormat;
   import java.util.HashMap;
   import java.util.Locale;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   
   
   /**
  @@ -89,7 +91,7 @@
    * application server environments.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2001/08/06 22:36:27 $
  + * @version $Revision: 1.12 $ $Date: 2002/02/26 03:38:57 $
    */
   
   public abstract class MessageResources implements Serializable {
  @@ -97,6 +99,10 @@
   
       // ------------------------------------------------------------- Properties
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
        * The configuration parameter used to initialize this MessageResources.
  @@ -559,11 +565,7 @@
        * @param message The message to be logged
        */
       public void log(String message) {
  -
  -        System.out.print("MessageResources: ");
  -        System.out.println(message);
  -        System.out.flush();
  -
  +        log.debug(message);
       }
   
   
  @@ -575,11 +577,7 @@
        * @param throwable The exception to be logged
        */
       public void log(String message, Throwable throwable) {
  -
  -        System.out.print("MessageResources: ");
  -        System.out.println(message);
  -        throwable.printStackTrace(System.out);
  -
  +        log.debug(message, throwable);
       }
   
   
  
  
  
  1.5       +11 -6     
jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java
  
  Index: MessageResourcesFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MessageResourcesFactory.java      12 Feb 2001 00:32:13 -0000      1.4
  +++ MessageResourcesFactory.java      26 Feb 2002 03:38:57 -0000      1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java,v
 1.4 2001/02/12 00:32:13 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/02/12 00:32:13 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/MessageResourcesFactory.java,v
 1.5 2002/02/26 03:38:57 dwinterfeldt Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/26 03:38:57 $
    *
    * ====================================================================
    * 
  @@ -64,6 +64,8 @@
   
   
   import java.io.Serializable;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   
   
   /**
  @@ -81,7 +83,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2001/02/12 00:32:13 $
  + * @version $Revision: 1.5 $ $Date: 2002/02/26 03:38:57 $
    */
   
   public abstract class MessageResourcesFactory implements Serializable {
  @@ -119,6 +121,10 @@
   
       // ------------------------------------------------------ Static Properties
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private static Log LOG = 
LogSource.getInstance(MessageResourcesFactory.class.getName());
   
       /**
        * The Java class to be used for
  @@ -163,8 +169,7 @@
                   (MessageResourcesFactory) clazz.newInstance();
               return (factory);
           } catch (Throwable t) {
  -            System.out.println("MessageResourcesFactory.createFactory");
  -            t.printStackTrace(System.out);
  +            LOG.error("MessageResourcesFactory.createFactory", t);
               return (null);
           }
   
  
  
  
  1.29      +16 -10    
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
  
  Index: RequestUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- RequestUtils.java 17 Jan 2002 00:15:05 -0000      1.28
  +++ RequestUtils.java 26 Feb 2002 03:38:57 -0000      1.29
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v 1.28 
2002/01/17 00:15:05 craigmcc Exp $
  - * $Revision: 1.28 $
  - * $Date: 2002/01/17 00:15:05 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v 1.29 
2002/02/26 03:38:57 dwinterfeldt Exp $
  + * $Revision: 1.29 $
  + * $Date: 2002/02/26 03:38:57 $
    *
    * ====================================================================
    *
  @@ -84,6 +84,8 @@
   import org.apache.commons.beanutils.BeanUtils;
   import org.apache.commons.beanutils.DynaBean;
   import org.apache.commons.beanutils.PropertyUtils;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionError;
   import org.apache.struts.action.ActionErrors;
  @@ -108,7 +110,7 @@
    *
    * @author Craig R. McClanahan
    * @author Ted Husted
  - * @version $Revision: 1.28 $ $Date: 2002/01/17 00:15:05 $
  + * @version $Revision: 1.29 $ $Date: 2002/02/26 03:38:57 $
    */
   
   public class RequestUtils {
  @@ -116,6 +118,10 @@
   
       // ------------------------------------------------------- Static Variables
   
  +    /**
  +     * Commons Logging instance.
  +    */
  +    private static Log LOG = LogSource.getInstance(RequestUtils.class.getName());
   
       /**
        * The default Locale for our server.
  @@ -496,7 +502,7 @@
   
           // Look up any existing form bean instance
           if (appConfig.getControllerConfig().getDebug() >= 2) {
  -            servlet.log(" Looking for ActionForm bean instance in scope '" +
  +            LOG.info(" Looking for ActionForm bean instance in scope '" +
                           mapping.getScope() + "' under attribute key '" +
                           attribute + "'");
           }
  @@ -543,7 +549,7 @@
                       DynaActionFormClass.createDynaActionFormClass(config);
                   instance = (ActionForm) dynaClass.newInstance();
               } catch (Throwable t) {
  -                servlet.log(servlet.getInternal().getMessage
  +                LOG.error(servlet.getInternal().getMessage
                               ("formBean", config.getName()), t);
                   return (null);
               }
  @@ -553,7 +559,7 @@
                   Class clazz = Class.forName(config.getType());
                   instance = (ActionForm) clazz.newInstance();
               } catch (Throwable t) {
  -                servlet.log(servlet.getInternal().getMessage
  +                LOG.error(servlet.getInternal().getMessage
                               ("formBean", config.getType()), t);
                   return (null);
               }
  @@ -928,18 +934,18 @@
                       Class.forName(multipartClass).newInstance();
               }
               catch (ClassNotFoundException cnfe) {
  -                servlet.log("MultipartRequestHandler class \"" +
  +                LOG.error("MultipartRequestHandler class \"" +
                       multipartClass + "\" in mapping class not found, " +
                       "defaulting to global multipart class");
               }
               catch (InstantiationException ie) {
  -                servlet.log("InstantiaionException when instantiating " +
  +                LOG.error("InstantiaionException when instantiating " +
                       "MultipartRequestHandler \"" + multipartClass + "\", " +
                       "defaulting to global multipart class, exception: " +
                       ie.getMessage());
               }
               catch (IllegalAccessException iae) {
  -                servlet.log("IllegalAccessException when instantiating " +
  +                LOG.error("IllegalAccessException when instantiating " +
                       "MultipartRequestHandler \"" + multipartClass + "\", " +
                       "defaulting to global multipart class, exception: " +
                       iae.getMessage());
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to