tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardHost.java
Date Wed, 26 Sep 2001 18:00:09 GMT
remm        01/09/26 11:00:09

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardHost.java
  Log:
  - Error report and dispatching refactoring.
  - The StandardHost will automatically add two valves on startup: the error page
    dispatcher valve, and an error report valve.
  - The error report valve used is pluggable. The errorReportValveClass property
    allows to specify the valve classname.
  - Since both the error page dispatching and error page output are done at the host
    level, that allows to:
    - set an error page for 401, 403, 503 (although it will still NOT work if the whole context
is
      unavailable), as well as the status code returned by the context (404 and 400), or
      any exception which happens somewhere else during the processing.
    - get nice error reports in nearly all situations.
  - No errors are reported when running the tester with this refactoring.
  
  Revision  Changes    Path
  1.19      +73 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHost.java
  
  Index: StandardHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHost.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StandardHost.java	2001/08/27 19:10:25	1.18
  +++ StandardHost.java	2001/09/26 18:00:09	1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHost.java,v
1.18 2001/08/27 19:10:25 craigmcc Exp $
  - * $Revision: 1.18 $
  - * $Date: 2001/08/27 19:10:25 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHost.java,v
1.19 2001/09/26 18:00:09 remm Exp $
  + * $Revision: 1.19 $
  + * $Date: 2001/09/26 18:00:09 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,9 @@
   import org.apache.catalina.LifecycleListener;
   import org.apache.catalina.Request;
   import org.apache.catalina.Response;
  +import org.apache.catalina.Valve;
   import org.apache.catalina.core.DefaultContext;
  +import org.apache.catalina.valves.ErrorDispatcherValve;
   
   
   /**
  @@ -100,7 +102,8 @@
    * requests directed to a particular web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.18 $ $Date: 2001/08/27 19:10:25 $
  + * @author Remy Maucherat
  + * @version $Revision: 1.19 $ $Date: 2001/09/26 18:00:09 $
    */
   
   public class StandardHost
  @@ -154,6 +157,14 @@
   
   
       /**
  +     * The Java class name of the default error reporter implementation class 
  +     * for deployed web applications.
  +     */
  +    private String errorReportValveClass =
  +        "org.apache.catalina.valves.ErrorReportValve";
  +
  +
  +    /**
        * The descriptive information string for this implementation.
        */
       private static final String info =
  @@ -304,6 +315,34 @@
   
   
       /**
  +     * Return the Java class name of the error report valve class
  +     * for new web applications.
  +     */
  +    public String getErrorReportValveClass() {
  +
  +        return (this.errorReportValveClass);
  +
  +    }
  +
  +
  +    /**
  +     * Set the Java class name of the error report valve class
  +     * for new web applications.
  +     *
  +     * @param errorReportValveClass The new error report valve class
  +     */
  +    public void setErrorReportValveClass(String errorReportValveClass) {
  +
  +        String oldErrorReportValveClassClass = this.errorReportValveClass;
  +        this.errorReportValveClass = errorReportValveClass;
  +        support.firePropertyChange("errorReportValveClass",
  +                                   oldErrorReportValveClassClass, 
  +                                   this.errorReportValveClass);
  +
  +    }
  +
  +
  +    /**
        * Return the canonical, fully qualified, name of the virtual host
        * this Container represents.
        */
  @@ -541,6 +580,36 @@
           sb.append(getName());
           sb.append("]");
           return (sb.toString());
  +
  +    }
  +
  +
  +    /**
  +     * Start this host.
  +     *
  +     * @exception IllegalStateException if this component has already been
  +     *  started
  +     * @exception LifecycleException if this component detects a fatal error
  +     *  that prevents it from being started
  +     */
  +    public synchronized void start() throws LifecycleException {
  +
  +        // Set error report valve
  +        if (errorReportValveClass != null) {
  +            try {
  +                Valve valve = (Valve) Class.forName(errorReportValveClass)
  +                    .newInstance();
  +                addValve(valve);
  +            } catch (Throwable t) {
  +                // FIXME
  +                t.printStackTrace();
  +            }
  +        }
  +
  +        // Set dispatcher valve
  +        addValve(new ErrorDispatcherValve());
  +
  +        super.start();
   
       }
   
  
  
  

Mime
View raw message