jfarcand 2004/03/24 12:00:22 Modified: catalina/src/share/org/apache/catalina Context.java catalina/src/share/org/apache/catalina/core StandardContext.java catalina/src/share/org/apache/catalina/mbeans MBeanFactory.java catalina/src/share/org/apache/catalina/startup ContextConfig.java TldConfig.java Log: Add support for xml validation/namespaceAware at the <context> level. The new attributes override the ones set on the <host> element. Add a "dummy" method for jmx calls (until the admin starts supporting the new sets of attributes) Revision Changes Path 1.11 +69 -1 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Context.java Index: Context.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Context.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Context.java 27 Feb 2004 14:58:38 -0000 1.10 +++ Context.java 24 Mar 2004 20:00:22 -0000 1.11 @@ -1128,4 +1128,72 @@ public void removeWrapperListener(String listener); + /** + * Get the server.xml <context> attribute's xmlNamespaceAware. + * @return true if namespace awarenes is enabled. + * + */ + public boolean getXmlNamespaceAware(); + + + /** + * Get the server.xml <context> attribute's xmlValidation. + * @return true if validation is enabled. + * + */ + public boolean getXmlValidation(); + + + /** + * Set the validation feature of the XML parser used when + * parsing xml instances. + * @param xmlValidation true to enable xml instance validation + */ + public void setXmlValidation(boolean xmlValidation); + + + /** + * Set the namespace aware feature of the XML parser used when + * parsing xml instances. + * @param xmlNamespaceAware true to enable namespace awareness + */ + public void setXmlNamespaceAware(boolean xmlNamespaceAware); + /** + * Get the server.xml <context> attribute's xmlValidation. + * @return true if validation is enabled. + */ + + + /** + * Set the validation feature of the XML parser used when + * parsing tlds files. + * @param tldXmlValidation true to enable xml instance validation + */ + public void setTldValidation(boolean tldValidation); + + + /** + * Get the server.xml <context> attribute's webXmlValidation. + * @return true if validation is enabled. + * + */ + public boolean getTldValidation(); + + + /** + * Get the server.xml <host> attribute's xmlNamespaceAware. + * @return true if namespace awarenes is enabled. + */ + public boolean getTldNamespaceAware(); + + + /** + * Set the namespace aware feature of the XML parser used when + * parsing xml instances. + * @param xmlNamespaceAware true to enable namespace awareness + */ + public void setTldNamespaceAware(boolean tldNamespaceAware); + + } + 1.121 +126 -8 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java Index: StandardContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v retrieving revision 1.120 retrieving revision 1.121 diff -u -r1.120 -r1.121 --- StandardContext.java 22 Mar 2004 12:45:55 -0000 1.120 +++ StandardContext.java 24 Mar 2004 20:00:22 -0000 1.121 @@ -575,12 +575,38 @@ private long startTime; private long tldScanTime; - /** Name of the engine. If null, the domain is used. + /** + * Name of the engine. If null, the domain is used. */ private String engineName = null; private String j2EEApplication="none"; private String j2EEServer="none"; + + /** + * Attribute value used to turn on/off XML validation + */ + private boolean webXmlValidation = false; + + + /** + * Attribute value used to turn on/off XML namespace validation + */ + private boolean webXmlNamespaceAware = false; + + + /** + * Attribute value used to turn on/off XML validation + */ + private boolean tldValidation = false; + + + /** + * Attribute value used to turn on/off TLD XML namespace validation + */ + private boolean tldNamespaceAware = false; + + // ----------------------------------------------------- Context Properties public void setName( String name ) { @@ -4179,10 +4205,24 @@ // Read tldListeners. XXX Option to disable TldConfig tldConfig = new TldConfig(); tldConfig.setContext(this); - tldConfig.setXmlValidation - (((StandardHost) getParent()).getXmlValidation()); - tldConfig.setXmlNamespaceAware - (((StandardHost) getParent()).getXmlNamespaceAware()); + + // (1) check if the attribute has been defined + // on the context element. + tldConfig.setTldValidation(tldValidation); + tldConfig.setTldNamespaceAware(tldNamespaceAware); + + // (2) if the attribute wasn't defined on the context + // try the host. + if (!tldValidation){ + tldConfig.setTldValidation + (((StandardHost) getParent()).getXmlValidation()); + } + + if (!tldNamespaceAware){ + tldConfig.setTldNamespaceAware + (((StandardHost) getParent()).getXmlNamespaceAware()); + } + try { tldConfig.execute(); } catch (Exception ex) { @@ -5415,10 +5455,88 @@ } + /** + * Set the validation feature of the XML parser used when + * parsing xml instances. + * @param xmlValidation true to enable xml instance validation + */ + public void setXmlValidation(boolean webXmlValidation){ + + this.webXmlValidation = webXmlValidation; + + } + + /** + * Get the server.xml <context> attribute's xmlValidation. + * @return true if validation is enabled. + * + */ + public boolean getXmlValidation(){ + return webXmlValidation; + } - /** Support for "stateManageable" JSR77 - * + /** + * Get the server.xml <context> attribute's xmlNamespaceAware. + * @return true if namespace awarenes is enabled. + */ + public boolean getXmlNamespaceAware(){ + return webXmlNamespaceAware; + } + + + /** + * Set the namespace aware feature of the XML parser used when + * parsing xml instances. + * @param xmlNamespaceAware true to enable namespace awareness + */ + public void setXmlNamespaceAware(boolean webXmlNamespaceAware){ + this.webXmlNamespaceAware= webXmlNamespaceAware; + } + + + /** + * Set the validation feature of the XML parser used when + * parsing tlds files. + * @param tldXmlValidation true to enable xml instance validation + */ + public void setTldValidation(boolean tldValidation){ + + this.tldValidation = tldValidation; + + } + + /** + * Get the server.xml <context> attribute's webXmlValidation. + * @return true if validation is enabled. + * + */ + public boolean getTldValidation(){ + return tldValidation; + } + + + /** + * Get the server.xml <host> attribute's xmlNamespaceAware. + * @return true if namespace awarenes is enabled. + */ + public boolean getTldNamespaceAware(){ + return tldNamespaceAware; + } + + + /** + * Set the namespace aware feature of the XML parser used when + * parsing xml instances. + * @param xmlNamespaceAware true to enable namespace awareness + */ + public void setTldNamespaceAware(boolean tldNamespaceAware){ + this.tldNamespaceAware= tldNamespaceAware; + } + + + /** + * Support for "stateManageable" JSR77 */ public boolean isStateManageable() { return true; 1.23 +33 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java Index: MBeanFactory.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- MBeanFactory.java 27 Feb 2004 14:58:45 -0000 1.22 +++ MBeanFactory.java 24 Mar 2004 20:00:22 -0000 1.23 @@ -739,8 +739,8 @@ return (oname.toString()); } - - + + /** * Create a new StandardContext. * @@ -750,15 +750,44 @@ * * @exception Exception if an MBean cannot be created or registered */ - public String createStandardContext(String parent, String path, + public String createStandardContext(String parent, + String path, String docBase) throws Exception { + + // XXX for backward compatibility. Remove it once supported by the admin + return + createStandardContext(parent,path,docBase,false,false,false,false); + } + + /** + * Create a new StandardContext. + * + * @param parent MBean Name of the associated parent component + * @param path The context path for this Context + * @param docBase Document base directory (or WAR) for this Context + * + * @exception Exception if an MBean cannot be created or registered + */ + public String createStandardContext(String parent, + String path, + String docBase, + boolean xmlValidation, + boolean xmlNamespaceAware, + boolean tldValidation, + boolean tldNamespaceAware) + throws Exception { // Create a new StandardContext instance StandardContext context = new StandardContext(); path = getPathStr(path); context.setPath(path); context.setDocBase(docBase); + context.setXmlValidation(xmlValidation); + context.setXmlNamespaceAware(xmlNamespaceAware); + context.setTldValidation(tldValidation); + context.setTldNamespaceAware(tldNamespaceAware); + ContextConfig contextConfig = new ContextConfig(); context.addLifecycleListener(contextConfig); 1.42 +14 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java Index: ContextConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- ContextConfig.java 27 Feb 2004 14:58:48 -0000 1.41 +++ ContextConfig.java 24 Mar 2004 20:00:22 -0000 1.42 @@ -251,7 +251,6 @@ if (context instanceof StandardContext) { ((StandardContext) context).setReplaceWelcomeFiles(true); } - webDigester.setUseContextClassLoader(false); webDigester.push(context); webDigester.parse(is); } else { @@ -582,8 +581,19 @@ if( !context.getOverride() ) { if( container instanceof Host ) { ((Host)container).importDefaultContext(context); - xmlValidation = ((Host)container).getXmlValidation(); - xmlNamespaceAware = ((Host)container).getXmlNamespaceAware(); + + // Reset the value only if the attribute wasn't + // set on the context. + xmlValidation = context.getXmlValidation(); + if (!xmlValidation) { + xmlValidation = ((Host)container).getXmlValidation(); + } + + xmlNamespaceAware = context.getXmlNamespaceAware(); + if (!xmlNamespaceAware){ + xmlNamespaceAware + = ((Host)container).getXmlNamespaceAware(); + } container = container.getParent(); } 1.37 +14 -14 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/TldConfig.java Index: TldConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/TldConfig.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- TldConfig.java 27 Feb 2004 14:58:49 -0000 1.36 +++ TldConfig.java 24 Mar 2004 20:00:22 -0000 1.37 @@ -148,15 +148,15 @@ /** - * Attribute value used to turn on/off XML validation + * Attribute value used to turn on/off TLD validation */ - private static boolean xmlValidation = false; + private static boolean tldValidation = false; /** - * Attribute value used to turn on/off XML namespace awarenes. + * Attribute value used to turn on/off TLD namespace awarenes. */ - private static boolean xmlNamespaceAware = false; + private static boolean tldNamespaceAware = false; private boolean rescan=true; @@ -185,8 +185,8 @@ * parsing xml instances. * @param xmlValidation true to enable xml instance validation */ - public void setXmlValidation(boolean xmlValidation){ - TldConfig.xmlValidation = xmlValidation; + public void setTldValidation(boolean tldValidation){ + this.tldValidation = tldValidation; } /** @@ -194,8 +194,8 @@ * @return true if validation is enabled. * */ - public boolean getXmlValidation(){ - return xmlValidation; + public boolean getTldValidation(){ + return tldValidation; } /** @@ -203,8 +203,8 @@ * @return true if namespace awarenes is enabled. * */ - public boolean getXmlNamespaceAware(){ - return xmlNamespaceAware; + public boolean getTldNamespaceAware(){ + return tldNamespaceAware; } @@ -213,8 +213,8 @@ * parsing xml instances. * @param xmlNamespaceAware true to enable namespace awareness */ - public void setXmlNamespaceAware(boolean xmlNamespaceAware){ - TldConfig.xmlNamespaceAware = xmlNamespaceAware; + public void setTldNamespaceAware(boolean tldNamespaceAware){ + this.tldNamespaceAware = tldNamespaceAware; } @@ -404,8 +404,8 @@ */ private static Digester createTldDigester() { - return DigesterFactory.newDigester(xmlValidation, - xmlNamespaceAware, + return DigesterFactory.newDigester(tldValidation, + tldNamespaceAware, new TldRuleSet()); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]