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/util/xml SaxContext.java XmlMapper.java
Date Fri, 24 Nov 2000 22:36:26 GMT
craigmcc    00/11/24 14:36:26

  Modified:    catalina/src/share/org/apache/catalina Context.java
               catalina/src/share/org/apache/catalina/core
                        StandardContext.java
               catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java
               catalina/src/share/org/apache/catalina/util/xml
                        SaxContext.java XmlMapper.java
  Log:
  Provide a mechanism where the public identifier of the web application
  deployment descriptor DTD is communicated to the Context implementation
  object.  This will be necessary in order to apply the looser (in 2.2)
  versus tighter (in 2.3) validation on web.xml values (such as the 2.3
  requirement that a <jsp-file> entry begin with a "/").
  
  This mechanism is not yet used -- that will be the next patch, separated
  so that we can clearly see what rules are being relaxed (in the name of
  backwards compatibility) when parsing a 2.2 web.xml file.
  
  Revision  Changes    Path
  1.14      +20 -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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Context.java	2000/10/29 00:37:55	1.13
  +++ Context.java	2000/11/24 22:36:22	1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Context.java,v
1.13 2000/10/29 00:37:55 craigmcc Exp $
  - * $Revision: 1.13 $
  - * $Date: 2000/10/29 00:37:55 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Context.java,v
1.14 2000/11/24 22:36:22 craigmcc Exp $
  + * $Revision: 1.14 $
  + * $Date: 2000/11/24 22:36:22 $
    *
    * ====================================================================
    *
  @@ -95,7 +95,7 @@
    * <p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.13 $ $Date: 2000/10/29 00:37:55 $
  + * @version $Revision: 1.14 $ $Date: 2000/11/24 22:36:22 $
    */
   
   public interface Context extends Container {
  @@ -251,6 +251,22 @@
        * @param path The new context path
        */
       public void setPath(String path);
  +
  +
  +    /**
  +     * Return the public identifier of the deployment descriptor DTD that is
  +     * currently being parsed.
  +     */
  +    public String getPublicId();
  +
  +
  +    /**
  +     * Set the public identifier of the deployment descriptor DTD that is
  +     * currently being parsed.
  +     *
  +     * @param publicId The public identifier
  +     */
  +    public void setPublicId(String publicId);
   
   
       /**
  
  
  
  1.29      +38 -4     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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- StandardContext.java	2000/11/04 06:46:07	1.28
  +++ StandardContext.java	2000/11/24 22:36:23	1.29
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.28 2000/11/04 06:46:07 remm Exp $
  - * $Revision: 1.28 $
  - * $Date: 2000/11/04 06:46:07 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.29 2000/11/24 22:36:23 craigmcc Exp $
  + * $Revision: 1.29 $
  + * $Date: 2000/11/24 22:36:23 $
    *
    * ====================================================================
    *
  @@ -131,7 +131,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.28 $ $Date: 2000/11/04 06:46:07 $
  + * @version $Revision: 1.29 $ $Date: 2000/11/24 22:36:23 $
    */
   
   public final class StandardContext
  @@ -326,6 +326,14 @@
   
   
       /**
  +     * The public identifier of the DTD for the web application deployment
  +     * descriptor version we are currently parsing.  This is used to support
  +     * relaxed validation rules when processing version 2.2 web.xml files.
  +     */
  +    private String publicId = null;
  +
  +
  +    /**
        * The reloadable flag for this web application.
        */
       private boolean reloadable = false;
  @@ -730,6 +738,32 @@
       public void setPath(String path) {
   
   	setName(RequestUtil.URLDecode(path));
  +
  +    }
  +
  +
  +    /**
  +     * Return the public identifier of the deployment descriptor DTD that is
  +     * currently being parsed.
  +     */
  +    public String getPublicId() {
  +
  +        return (this.publicId);
  +
  +    }
  +
  +
  +    /**
  +     * Set the public identifier of the deployment descriptor DTD that is
  +     * currently being parsed.
  +     *
  +     * @param publicId The public identifier
  +     */
  +    public void setPublicId(String publicId) {
  +
  +	String oldPublicId = this.publicId;
  +        this.publicId = publicId;
  +        support.firePropertyChange("publicId", oldPublicId, publicId);
   
       }
   
  
  
  
  1.33      +51 -4     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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- ContextConfig.java	2000/10/31 23:49:02	1.32
  +++ ContextConfig.java	2000/11/24 22:36:24	1.33
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.32 2000/10/31 23:49:02 pierred Exp $
  - * $Revision: 1.32 $
  - * $Date: 2000/10/31 23:49:02 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.33 2000/11/24 22:36:24 craigmcc Exp $
  + * $Revision: 1.33 $
  + * $Date: 2000/11/24 22:36:24 $
    *
    * ====================================================================
    *
  @@ -72,6 +72,7 @@
   import java.io.InputStream;
   import java.io.IOException;
   import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Method;
   import java.net.JarURLConnection;
   import java.net.MalformedURLException;
   import java.net.URL;
  @@ -117,7 +118,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.32 $ $Date: 2000/10/31 23:49:02 $
  + * @version $Revision: 1.33 $ $Date: 2000/11/24 22:36:24 $
    */
   
   public final class ContextConfig
  @@ -432,6 +433,9 @@
   	mapper.registerDTDFile(Constants.WebDtdPublicId_23,
   			       resourceFile.toString());
   
  +        mapper.addRule("web-app",
  +                       new SetPublicIdAction("setPublicId"));
  +
   	mapper.addRule("web-app/context-param",
   		       mapper.methodSetter("addParameter", 2));
   	mapper.addRule("web-app/context-param/param-name",
  @@ -1108,6 +1112,49 @@
           securityConstraint.setAuthConstraint(true);
   	if (ctx.getDebug() > 0)
   	    ctx.log("Calling SecurityConstraint.setAuthConstraint(true)");
  +    }
  +
  +}
  +
  +
  +/**
  + * Class that calls a property setter for the top object on the stack,
  + * passing the public ID of the entity we are currently processing.
  + */
  +
  +final class SetPublicIdAction extends XmlAction {
  +
  +    public SetPublicIdAction(String method) {
  +        super();
  +        this.method = method;
  +    }
  +    
  +
  +    private String method = null;
  +
  +    public void start(SaxContext context) throws Exception {
  +
  +        Stack stack = context.getObjectStack();
  +        Object top = stack.peek();
  +        Class paramClasses[] = new Class[1];
  +        paramClasses[0] = "String".getClass();
  +        String paramValues[] = new String[1];
  +        paramValues[0] = context.getPublicId();
  +
  +        Method m = null;
  +        try {
  +            m = top.getClass().getMethod(method, paramClasses);
  +        } catch (NoSuchMethodException e) {
  +            context.log("Can't find method " + method + " in " + top +
  +                        " CLASS " + top.getClass());
  +            return;
  +        }
  +
  +        m.invoke(top, paramValues);
  +        if (context.getDebug() >= 1)
  +            context.log("" + top.getClass().getName() + "." + method +
  +                        "(" + paramValues[0] + ")");
  +
       }
   
   }
  
  
  
  1.2       +4 -0      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml/SaxContext.java
  
  Index: SaxContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml/SaxContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SaxContext.java	2000/08/11 22:46:26	1.1
  +++ SaxContext.java	2000/11/24 22:36:25	1.2
  @@ -62,4 +62,8 @@
       public int getDebug();
   
       public void log( String s );
  +
  +    public String getPublicId();
  +
   }
  +
  
  
  
  1.5       +11 -0     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml/XmlMapper.java
  
  Index: XmlMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml/XmlMapper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XmlMapper.java	2000/11/01 23:20:39	1.4
  +++ XmlMapper.java	2000/11/24 22:36:25	1.5
  @@ -46,6 +46,8 @@
       int debug=0;
       boolean validating=false;
   
  +    String publicId = null;
  +
       public XmlMapper() {
   	attributeStack = new Object[256]; // depth of the xml doc
   	tagStack = new String[256];
  @@ -68,6 +70,7 @@
           if (sp != 0) {
   	    System.out.println("The XML document is probably broken. " + sp);
   	}
  +        publicId = null;
       }
   
   
  @@ -167,6 +170,10 @@
   	return oStack;
       }
   
  +    public String getPublicId() {
  +        return publicId;
  +    }
  +
       public Object getRoot() {
   	return root;
       }
  @@ -427,6 +434,10 @@
       public InputSource resolveEntity(String publicId, String systemId)
   	throws SAXException
       {
  +        if (debug >= 1)
  +            System.out.println("Resolve: " + publicId + " " + systemId);
  +        this.publicId = publicId;
  +
   	String dtd = (String) fileDTDs.get(publicId);
   	if( dtd != null ) {
   	    File dtdF=new File( dtd );
  
  
  

Mime
View raw message