craigmcc    01/01/22 18:52:01

  Modified:    catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java
  Log:
  Third of four commits for the Valve API change.
  
  Changes reflect the fact that the Context implementation delegates to a
  Pipeline implementation, rather than implementing Pipeline directly.
  
  Revision  Changes    Path
  1.36      +36 -29    
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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ContextConfig.java        2000/12/22 00:37:52     1.35
  +++ ContextConfig.java        2001/01/23 02:52:00     1.36
  @@ -1,13 +1,13 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
 1.35 2000/12/22 00:37:52 craigmcc Exp $
  - * $Revision: 1.35 $
  - * $Date: 2000/12/22 00:37:52 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
 1.36 2001/01/23 02:52:00 craigmcc Exp $
  + * $Revision: 1.36 $
  + * $Date: 2001/01/23 02:52:00 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -118,7 +118,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.35 $ $Date: 2000/12/22 00:37:52 $
  + * @version $Revision: 1.36 $ $Date: 2001/01/23 02:52:00 $
    */
   
   public final class ContextConfig
  @@ -278,21 +278,18 @@
        // Has an authenticator been configured already?
        if (context instanceof Authenticator)
            return;
  -     if (context instanceof ContainerBase) {
  -         Valve basic = ((ContainerBase) context).getBasic();
  -         if ((basic != null) && (basic instanceof Authenticator))
  -             return;
  -     }
  -     if (context instanceof Pipeline) {
  -         Valve valve = ((Pipeline) context).findValves();
  -         while (valve != null) {
  -             if (valve instanceof Authenticator)
  -                 return;
  -             if (valve instanceof ValveBase)
  -                 valve = ((ValveBase) valve).getNext();
  -             else
  -                 valve = null;
  -         }
  +        if (context instanceof ContainerBase) {
  +            Pipeline pipeline = ((ContainerBase) context).getPipeline();
  +            if (pipeline != null) {
  +                Valve basic = pipeline.getBasic();
  +                if ((basic != null) && (basic instanceof Authenticator))
  +                    return;
  +                Valve valves[] = pipeline.getValves();
  +                for (int i = 0; i < valves.length; i++) {
  +                    if (valves[i] instanceof Authenticator)
  +                        return;
  +                }
  +            }
        } else {
            return;     // Cannot install a Valve even if it would be needed
        }
  @@ -336,9 +333,14 @@
        try {
            Class authenticatorClass = Class.forName(authenticatorName);
            authenticator = (Valve) authenticatorClass.newInstance();
  -         ((Pipeline) context).addValve(authenticator);
  -         log(sm.getString("contextConfig.authenticatorConfigured",
  -                          loginConfig.getAuthMethod()));
  +            if (context instanceof ContainerBase) {
  +                Pipeline pipeline = ((ContainerBase) context).getPipeline();
  +                if (pipeline != null) {
  +                    pipeline.addValve(authenticator);
  +                    log(sm.getString("contextConfig.authenticatorConfigured",
  +                                     loginConfig.getAuthMethod()));
  +                }
  +            }
        } catch (Throwable t) {
            log(sm.getString("contextConfig.authenticatorInstantiate",
                             authenticatorName), t);
  @@ -377,8 +379,14 @@
   
           // Add this Valve to our Pipeline
           try {
  -            ((Pipeline) context).addValve(certificates);
  -            log(sm.getString("contextConfig.certificatesConfig.added"));
  +            if (context instanceof ContainerBase) {
  +                Pipeline pipeline = ((ContainerBase) context).getPipeline();
  +                if (pipeline != null) {
  +                    pipeline.addValve(certificates);
  +                    log(sm.getString
  +                        ("contextConfig.certificatesConfig.added"));
  +                }
  +            }
           } catch (Throwable t) {
               log(sm.getString("contextConfig.certificatesConfig.error"), t);
               ok = false;
  @@ -899,10 +907,9 @@
           // Dump the contents of this pipeline if requested
           if (debug >= 1) {
               log("Pipline Configuration:");
  -            Valve valve = ((Pipeline) context).findValves();
  -            while (valve != null) {
  -                log("  " + valve.getInfo());
  -                valve = valve.getNext();
  +            Valve valves[] = ((Pipeline) context).getValves();
  +            for (int i = 0; i < valves.length; i++) {
  +                log("  " + valves[i].getInfo());
               }
               log("======================");
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to