tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup ContextConfig.java LocalStrings.properties
Date Tue, 03 Oct 2000 21:30:47 GMT
craigmcc    00/10/03 14:30:45

  Modified:    catalina/src/share/org/apache/catalina Context.java
               catalina/src/share/org/apache/catalina/connector
                        HttpResponseBase.java
               catalina/src/share/org/apache/catalina/core
                        LocalStrings.properties StandardContext.java
                        StandardContextValve.java StandardWrapperValve.java
               catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java LocalStrings.properties
  Log:
  Introduce a new "available" property for Contexts, which can be used
  (among other things) to disable the use of an application that encountered
  initialization errors (such as parsing problems in web.xml).  Such
  applications will now throw a 503 status when you attempt to access any
  URL within that app.
  
  Revision  Changes    Path
  1.9       +18 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Context.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Context.java	2000/09/30 19:15:43	1.8
  +++ Context.java	2000/10/03 21:30:28	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Context.java,v
1.8 2000/09/30 19:15:43 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/09/30 19:15:43 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Context.java,v
1.9 2000/10/03 21:30:28 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/10/03 21:30:28 $
    *
    * ====================================================================
    *
  @@ -95,7 +95,7 @@
    * <p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2000/09/30 19:15:43 $
  + * @version $Revision: 1.9 $ $Date: 2000/10/03 21:30:28 $
    */
   
   public interface Context extends Container {
  @@ -123,6 +123,20 @@
        * @param listeners The set of instantiated listener objects.
        */
       public void setApplicationListeners(Object listeners[]);
  +
  +
  +    /**
  +     * Return the application available flag for this Context.
  +     */
  +    public boolean getAvailable();
  +
  +
  +    /**
  +     * Set the application available flag for this Context.
  +     *
  +     * @param available The new application available flag
  +     */
  +    public void setAvailable(boolean available);
   
   
       /**
  
  
  
  1.10      +18 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java
  
  Index: HttpResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpResponseBase.java	2000/09/20 17:11:38	1.9
  +++ HttpResponseBase.java	2000/10/03 21:30:31	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
1.9 2000/09/20 17:11:38 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/09/20 17:11:38 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
1.10 2000/10/03 21:30:31 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/10/03 21:30:31 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    * methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/09/20 17:11:38 $
  + * @version $Revision: 1.10 $ $Date: 2000/10/03 21:30:31 $
    */
   
   public class HttpResponseBase
  @@ -158,6 +158,20 @@
   
   
       // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Perform whatever actions are required to flush and close the output
  +     * stream or writer, in a single operation.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public void finishResponse() throws IOException {
  +
  +        sendHeaders();
  +        super.finishResponse();
  +
  +    }
   
   
       /**
  
  
  
  1.10      +1 -0      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/LocalStrings.properties,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocalStrings.properties	2000/09/30 19:15:45	1.9
  +++ LocalStrings.properties	2000/10/03 21:30:34	1.10
  @@ -25,6 +25,7 @@
   standardContext.filterMap.either=Filter mapping must specify either a <url-pattern>
or a <servlet-name>
   standardContext.filterMap.name=Filter mapping specifies an unknown filter name {0}
   standardContext.filterMap.pattern=Invalid <url-pattern> {0} in filter mapping
  +standardContext.isUnavailable=This application is not currently available
   standardContext.mappingError=MAPPING configuration error for relative URI {0}
   standardContext.notReloadable=Reloading is disabled on this Context
   standardContext.notStarted=Context has not yet been started
  
  
  
  1.17      +86 -39    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- StandardContext.java	2000/09/30 19:15:45	1.16
  +++ StandardContext.java	2000/10/03 21:30:35	1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.16 2000/09/30 19:15:45 craigmcc Exp $
  - * $Revision: 1.16 $
  - * $Date: 2000/09/30 19:15:45 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.17 2000/10/03 21:30:35 craigmcc Exp $
  + * $Revision: 1.17 $
  + * $Date: 2000/10/03 21:30:35 $
    *
    * ====================================================================
    *
  @@ -106,7 +106,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.16 $ $Date: 2000/09/30 19:15:45 $
  + * @version $Revision: 1.17 $ $Date: 2000/10/03 21:30:35 $
    */
   
   public final class StandardContext
  @@ -153,6 +153,12 @@
   
   
       /**
  +     * The application available flag for this Context.
  +     */
  +    private boolean available = false;
  +
  +
  +    /**
        * The Locale to character set mapper for this application.
        */
       private CharsetMapper charsetMapper = null;
  @@ -398,6 +404,32 @@
   
   
       /**
  +     * Return the application available flag for this Context.
  +     */
  +    public boolean getAvailable() {
  +
  +        return (this.available);
  +
  +    }
  +
  +
  +    /**
  +     * Set the application available flag for this Context.
  +     *
  +     * @param available The new application available flag
  +     */
  +    public void setAvailable(boolean available) {
  +
  +        boolean oldAvailable = this.available;
  +        this.available = available;
  +	support.firePropertyChange("available",
  +				   new Boolean(oldAvailable),
  +                                   new Boolean(this.available));
  +
  +    }
  +
  +
  +    /**
        * Return the Locale to character set mapper for this Context.
        */
       public CharsetMapper getCharsetMapper() {
  @@ -2344,42 +2376,57 @@
   
   	// Standard container startup
   	super.start();
  +        if (!available)
  +            return;
   
  -	// Collect "load on startup" servlets that need to be initialized
  -	TreeMap map = new TreeMap();
  -	Container children[] = findChildren();
  -	for (int i = 0; i < children.length; i++) {
  -	    Wrapper wrapper = (Wrapper) children[i];
  -	    int loadOnStartup = wrapper.getLoadOnStartup();
  -	    if (loadOnStartup < 0)
  -		continue;
  -	    if (loadOnStartup == 0)	// Arbitrarily put them last
  -		loadOnStartup = Integer.MAX_VALUE;
  -	    Integer key = new Integer(loadOnStartup);
  -	    ArrayList list = (ArrayList) map.get(key);
  -	    if (list == null) {
  -		list = new ArrayList();
  -		map.put(key, list);
  -	    }
  -	    list.add(wrapper);
  -	}
  -
  -	// Load the collected "load on startup" servlets
  -	Iterator keys = map.keySet().iterator();
  -	while (keys.hasNext()) {
  -	    Integer key = (Integer) keys.next();
  -	    ArrayList list = (ArrayList) map.get(key);
  -	    Iterator wrappers = list.iterator();
  -	    while (wrappers.hasNext()) {
  -		Wrapper wrapper = (Wrapper) wrappers.next();
  -		try {
  -		    wrapper.load();
  -		} catch (ServletException e) {
  -		    log(sm.getString("standardWrapper.loadException",
  -				     getName()), e);
  -		}
  -	    }
  -	}
  +        // Collect "load on startup" servlets that need to be initialized
  +        TreeMap map = new TreeMap();
  +        Container children[] = findChildren();
  +        for (int i = 0; i < children.length; i++) {
  +            Wrapper wrapper = (Wrapper) children[i];
  +            int loadOnStartup = wrapper.getLoadOnStartup();
  +            if (loadOnStartup < 0)
  +                continue;
  +            if (loadOnStartup == 0)	// Arbitrarily put them last
  +                loadOnStartup = Integer.MAX_VALUE;
  +            Integer key = new Integer(loadOnStartup);
  +            ArrayList list = (ArrayList) map.get(key);
  +            if (list == null) {
  +                list = new ArrayList();
  +                map.put(key, list);
  +            }
  +            list.add(wrapper);
  +        }
  +
  +        // Load the collected "load on startup" servlets
  +        Iterator keys = map.keySet().iterator();
  +        while (keys.hasNext()) {
  +            Integer key = (Integer) keys.next();
  +            ArrayList list = (ArrayList) map.get(key);
  +            Iterator wrappers = list.iterator();
  +            while (wrappers.hasNext()) {
  +                Wrapper wrapper = (Wrapper) wrappers.next();
  +                try {
  +                    wrapper.load();
  +                } catch (ServletException e) {
  +                    log(sm.getString("standardWrapper.loadException",
  +                                     getName()), e);
  +                }
  +            }
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Stop this Context component.
  +     *
  +     * @exception LifecycleException if a shutdown error occurs
  +     */
  +    public void stop() throws LifecycleException {
  +
  +        setAvailable(false);
  +        super.stop();
   
       }
   
  
  
  
  1.3       +9 -4      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContextValve.java
  
  Index: StandardContextValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContextValve.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardContextValve.java	2000/09/09 03:20:50	1.2
  +++ StandardContextValve.java	2000/10/03 21:30:36	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContextValve.java,v
1.2 2000/09/09 03:20:50 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/09/09 03:20:50 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContextValve.java,v
1.3 2000/10/03 21:30:36 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/10/03 21:30:36 $
    *
    * ====================================================================
    *
  @@ -85,7 +85,7 @@
    * when processing HTTP requests.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/09/09 03:20:50 $
  + * @version $Revision: 1.3 $ $Date: 2000/10/03 21:30:36 $
    */
   
   final class StandardContextValve
  @@ -152,6 +152,11 @@
   	    ((HttpServletResponse) response.getResponse()).sendError
   		(HttpServletResponse.SC_NOT_FOUND,
   		 sm.getString("standardContext.notFound"));
  +            try {
  +                response.finishResponse();
  +            } catch (IOException e) {
  +                ;
  +            }
   	    return;
   	}
   
  
  
  
  1.9       +12 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StandardWrapperValve.java	2000/09/09 03:20:51	1.8
  +++ StandardWrapperValve.java	2000/10/03 21:30:37	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
1.8 2000/09/09 03:20:51 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/09/09 03:20:51 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
1.9 2000/10/03 21:30:37 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/10/03 21:30:37 $
    *
    * ====================================================================
    *
  @@ -103,7 +103,7 @@
    * <code>StandardWrapper</code> container implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2000/09/09 03:20:51 $
  + * @version $Revision: 1.9 $ $Date: 2000/10/03 21:30:37 $
    */
   
   final class StandardWrapperValve
  @@ -200,8 +200,15 @@
               ((HttpRequest) request).setServletPath(jspFile);
           }
   
  +        // Check for the application being marked unavailable
  +        if (!((Context) wrapper.getParent()).getAvailable()) {
  +            hres.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
  +                           sm.getString("standardContext.isUnavailable"));
  +            unavailable = true;
  +        }
  +
   	// Check for the servlet being marked unavailable
  -	if (wrapper.isUnavailable()) {
  +	if (!unavailable && wrapper.isUnavailable()) {
   	    log(sm.getString("standardWrapper.isUnavailable",
   			     wrapper.getName()));
   	    if (hres == null) {
  
  
  
  1.19      +41 -11    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ContextConfig.java	2000/10/03 18:57:44	1.18
  +++ ContextConfig.java	2000/10/03 21:30:42	1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.18 2000/10/03 18:57:44 craigmcc Exp $
  - * $Revision: 1.18 $
  - * $Date: 2000/10/03 18:57:44 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.19 2000/10/03 21:30:42 craigmcc Exp $
  + * $Revision: 1.19 $
  + * $Date: 2000/10/03 21:30:42 $
    *
    * ====================================================================
    *
  @@ -111,7 +111,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.18 $ $Date: 2000/10/03 18:57:44 $
  + * @version $Revision: 1.19 $ $Date: 2000/10/03 21:30:42 $
    */
   
   public final class ContextConfig
  @@ -142,6 +142,12 @@
   
   
       /**
  +     * Track any fatal errors during startup configuration processing.
  +     */
  +    private boolean ok = false;
  +
  +
  +    /**
        * The string resources for this package.
        */
       private static final StringManager sm =
  @@ -227,13 +233,16 @@
   	} catch (InvocationTargetException e) {
   	    log(sm.getString("contextConfig.applicationConfig"),
   		e.getTargetException());
  +            ok = false;
           } catch (SAXParseException e) {
               log(sm.getString("contextConfig.applicationParse"), e);
               log(sm.getString("contextConfig.applicationPosition",
                                "" + e.getLineNumber(),
                                "" + e.getColumnNumber()));
  +            ok = false;
   	} catch (Exception e) {
   	    log(sm.getString("contextConfig.applicationParse"), e);
  +            ok = false;
   	} finally {
   	    try {
   		stream.close();
  @@ -288,6 +297,7 @@
   		    ("org.apache.catalina.startup.Authenticators");
   	    } catch (MissingResourceException e) {
   		log(sm.getString("contextConfig.authenticatorResources"), e);
  +                ok = false;
   		return;
   	    }
   	}
  @@ -303,6 +313,7 @@
   	if (authenticatorName == null) {
   	    log(sm.getString("contextConfig.authenticatorMissing",
   			     loginConfig.getAuthMethod()));
  +            ok = false;
   	    return;
   	}
   
  @@ -317,6 +328,7 @@
   	} catch (Throwable t) {
   	    log(sm.getString("contextConfig.authenticatorInstantiate",
   			     authenticatorName), t);
  +            ok = false;
   	}
   
       }
  @@ -355,6 +367,7 @@
               log(sm.getString("contextConfig.certificatesConfig.added"));
           } catch (Throwable t) {
               log(sm.getString("contextConfig.certificatesConfig.error"), t);
  +            ok = false;
           }
   
       }
  @@ -617,13 +630,16 @@
   	} catch (InvocationTargetException e) {
   	    log(sm.getString("contextConfig.defaultConfig"),
   		e.getTargetException());
  +            ok = false;
           } catch (SAXParseException e) {
               log(sm.getString("contextConfig.defaultParse"), e);
               log(sm.getString("contextConfig.defaultPosition",
                                "" + e.getLineNumber(),
                                "" + e.getColumnNumber()));
  +            ok = false;
   	} catch (Exception e) {
   	    log(sm.getString("contextConfig.defaultParse"), e);
  +            ok = false;
   	} finally {
   	    try {
   		stream.close();
  @@ -656,10 +672,10 @@
   		Class clazz = loader.loadClass(listeners[i]);
   		results[i] = clazz.newInstance();
   	    } catch (Throwable t) {
  -		// FIXME - should we do anything besides log these?
   		log(sm.getString("contextConfig.applicationListener",
   				 listeners[i]), t);
   		error = true;
  +                ok = false;
   	    }
   	}
   	if (!error)
  @@ -689,8 +705,8 @@
   		  (ServletContextListener) listeners[i];
   		listener.contextInitialized(event);
   	    } catch (Throwable t) {
  -	        // FIXME - should we do anything besides log these?
   	        log(sm.getString("contextConfig.applicationStart"), t);
  +                ok = false;
   	    }
   	}
   
  @@ -719,8 +735,8 @@
   		  (ServletContextListener) listeners[j];
   		listener.contextDestroyed(event);
   	    } catch (Throwable t) {
  -	        // FIXME - should we do anything besides log these?
   	        log(sm.getString("contextConfig.applicationStop"), t);
  +                ok = false;
   	    }
   	}
   
  @@ -866,6 +882,7 @@
   
   	if (debug > 0)
   	    log(sm.getString("contextConfig.start"));
  +        ok = true;
   
   	// Configure a mapper to read a web application deployment descriptor
   	XmlMapper mapper = createMapper();
  @@ -900,17 +917,21 @@
   	applicationConfig(mapper);
   
           // Configure a certificates exposer valve, if required
  -        certificatesConfig();
  +        if (ok)
  +            certificatesConfig();
   
   	// Configure an authenticator if we need one
  -	authenticatorConfig();
  +        if (ok)
  +            authenticatorConfig();
   
   	// Configure the application event listeners for this Context
   	// PREREQUISITE:  class loader has been configured
  -	listenerConfig();
  +        if (ok)
  +            listenerConfig();
   
   	// Send an application start event to all interested listeners
  -	listenerStartEvent();
  +        if (ok)
  +            listenerStartEvent();
   
           // Dump the contents of this pipeline if requested
           if (debug >= 1) {
  @@ -923,6 +944,14 @@
               log("======================");
           }
   
  +        // Make our application available if no problems were encountered
  +        if (ok)
  +            context.setAvailable(true);
  +        else {
  +            log(sm.getString("contextConfig.unavailable"));
  +            context.setAvailable(false);
  +        }
  +
       }
   
   
  @@ -933,6 +962,7 @@
   
   	if (debug > 0)
   	    log(sm.getString("contextConfig.stop"));
  +        ok = true;
   
   	// Send an application stop event to all interested listeners
   	listenerStopEvent();
  
  
  
  1.7       +1 -0      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalStrings.properties	2000/10/03 18:57:44	1.6
  +++ LocalStrings.properties	2000/10/03 21:30:44	1.7
  @@ -27,6 +27,7 @@
   contextConfig.defaultResources=Configuring default Resources
   contextConfig.start=ContextConfig: Processing START
   contextConfig.stop=ContextConfig: Processing STOP
  +contextConfig.unavailable=Marking this application unavailable due to previous error(s)
   embedded.alreadyStarted=Embedded service has already been started
   embedded.noEngines=No engines have been defined yet
   embedded.notStarted=Embedded service has not yet been started
  
  
  

Mime
View raw message