From: markt Date: Fri, 11 Sep 2009 12:50:44 +0000 (+0000) Subject: No functional change. Add new classes that will be used to store the results of parsi... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dd8217b7bb838bd2ba3d2a1a6f6d9cff8f249ab9;p=tomcat7.0 No functional change. Add new classes that will be used to store the results of parsing web.xml and web-fragment.xml files. The merging and ordering rules can't be handled in the digester so we now have to parse to a temporary store and then merge. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@813815 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/TOMCAT-7-RELEASE-PLAN.txt b/TOMCAT-7-RELEASE-PLAN.txt index 74824a24b..deae6526f 100644 --- a/TOMCAT-7-RELEASE-PLAN.txt +++ b/TOMCAT-7-RELEASE-PLAN.txt @@ -28,13 +28,23 @@ $Id: $ - Done 3. Implement all the new Servlet 3 features - - Sections 1 to 6 - not checked + - Sections 1 to 6 - not checked - Section 7 - in progress 7.1, 7.2, 7.3, 7.4, 7.5, 7.6 - Compliant 7.7.1 - Compliant 7.7.2 - When is IAE thrown? 7.7.3 - Compliant - - Sections 8 onwards - not checked + - Section 8 - in progress + 8.1 - not checked + 8.2 - in progress, plan as follows + - modify digester to parse to new classes + - configure Context & Jasper from new classes + - fragment scanning / parsing + - fragment ordering + - web(-fragment).xml merging code + - annotation scanning + 8.3 - not checked + - Sections 9 onwards - not checked 4. Do an alpha release (from trunk) - Create tc7.0.x\tags to hold release tags diff --git a/java/org/apache/catalina/startup/LocalStrings.properties b/java/org/apache/catalina/startup/LocalStrings.properties index 164385d34..4dc0cad5b 100644 --- a/java/org/apache/catalina/startup/LocalStrings.properties +++ b/java/org/apache/catalina/startup/LocalStrings.properties @@ -110,3 +110,10 @@ userConfig.deploying=Deploying user web applications userConfig.error=Error deploying web application for user {0} userConfig.start=UserConfig: Processing START userConfig.stop=UserConfig: Processing STOP +webXmlCommon.duplicateEnvEntry=Duplicate env-entry name +webXmlCommon.duplicateFilter=Duplicate filter name +webXmlCommon.duplicateMessageDestination=Duplicate message-destination name +webXmlCommon.duplicateMessageDestinationRef=Duplicate message-destination-ref name +webXmlCommon.duplicateResourceEnvRef=Duplicate resource-env-ref name +webXmlCommon.duplicateResourceRef=Duplicate resource-ref name +webXmlFragment.multipleOther=Multiple others entries in ordering diff --git a/java/org/apache/catalina/startup/WebXml.java b/java/org/apache/catalina/startup/WebXml.java new file mode 100644 index 000000000..a1e67cee5 --- /dev/null +++ b/java/org/apache/catalina/startup/WebXml.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.catalina.startup; + +import java.util.LinkedHashSet; +import java.util.Set; + +public class WebXml extends WebXmlCommon { + + // Absolute Ordering + private Set absoluteOrdering = new LinkedHashSet(); + public void addAbsoluteOrdering(String name) { + absoluteOrdering.add(name); + } + public void addAbsoluteOrderingOthers() { + absoluteOrdering.add(ORDER_OTHERS); + } + +} diff --git a/java/org/apache/catalina/startup/WebXmlCommon.java b/java/org/apache/catalina/startup/WebXmlCommon.java new file mode 100644 index 000000000..3dfe53c5c --- /dev/null +++ b/java/org/apache/catalina/startup/WebXmlCommon.java @@ -0,0 +1,350 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.catalina.startup; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.catalina.Wrapper; +import org.apache.catalina.deploy.ContextEjb; +import org.apache.catalina.deploy.ContextEnvironment; +import org.apache.catalina.deploy.ContextLocalEjb; +import org.apache.catalina.deploy.ContextResource; +import org.apache.catalina.deploy.ContextResourceEnvRef; +import org.apache.catalina.deploy.ContextService; +import org.apache.catalina.deploy.ErrorPage; +import org.apache.catalina.deploy.FilterDef; +import org.apache.catalina.deploy.FilterMap; +import org.apache.catalina.deploy.LoginConfig; +import org.apache.catalina.deploy.MessageDestination; +import org.apache.catalina.deploy.MessageDestinationRef; +import org.apache.catalina.deploy.SecurityConstraint; +import org.apache.jasper.compiler.JspConfig; +import org.apache.tomcat.util.res.StringManager; + +/** + * Representation of common elements of web.xml and web-fragment.xml. Provides + * a repository for parsed data before the elements are merged. + * Validation is spread between multiple classes: + * The digester checks for structural correctness (eg single login-config) + * This class checks for invalid duplicates (eg filter/servlet names) + * StandardContext will check validity of values (eg URL formats etc) + */ +public abstract class WebXmlCommon { + + protected static final String ORDER_OTHERS = + "org.apache.catalina.order.others"; + + protected static final StringManager sm = + StringManager.getManager(Constants.Package); + + // Required attribute of web-app element + private String version = null; + public String getVersion() { return version; } + public void setVersion(String version) { this.version = version; } + + // Optional metadata-complete attribute + private boolean metadataComplete = false; + public boolean getMetadataComplete() { return metadataComplete; } + public void setMetadataComplete(boolean metadataComplete) { + this.metadataComplete = metadataComplete; } + + // Optional name element + private String name = null; + public String getName() { return name; } + public void setName(String name) { this.name = name; } + + // web-app elements + // TODO: Ignored elements: + // - description + // - icon + + // display-name - TODO should support multiple with language + private String displayName = null; + public String getDisplayName() { return displayName; } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + // distributable + private boolean distributable = false; + public boolean getDistributable() { return distributable; } + public void setDistributable(boolean distributable) { + this.distributable = distributable; + } + + // context-param + // TODO: description (multiple with language) is ignored + private Map contextParams = new HashMap(); + public void addContextParam(String name, String value) { + contextParams.put(name, value); + } + public Map getContextParams() { return contextParams; } + + // filter + // TODO: Should support multiple description elements with language + // TODO: Should support multiple display-name elements with language + // TODO: Should support multiple icon elements + // TODO: Description for init-param is ignored + private Map filters = new HashMap(); + public void addFilter(FilterDef filter) { + if (filters.containsKey(filter.getFilterName())) { + // Filter names must be unique within a web(-fragment).xml + throw new IllegalArgumentException( + sm.getString("webXmlCommon.duplicateFilter")); + } + filters.put(filter.getFilterName(), filter); + } + public Map getFilters() { return filters; } + + // filter-mapping + private Map filterMaps = new HashMap(); + public void addFilterMapping(FilterMap filterMap) { + filterMaps.put(filterMap.getFilterName(), filterMap); + } + public Map getFilterMappings() { return filterMaps; } + + // listener + // TODO: description (multiple with language) is ignored + // TODO: display-name (multiple with language) is ignored + // TODO: icon (multiple) is ignored + private Set listeners = new LinkedHashSet(); + public void addListener(String className) { + listeners.add(className); + } + public Set getListeners() { return listeners; } + + // servlet + // TODO: description (multiple with language) is ignored + // TODO: display-name (multiple with language) is ignored + // TODO: icon (multiple) is ignored + // TODO: init-param/description (multiple with language) is ignored + // TODO: security-role-ref/description (multiple with language) is ignored + private Map servlets = new HashMap(); + public void addServlet(Wrapper wrapper) { + servlets.put(wrapper.getName(), wrapper); + } + public Map getServlets() { return servlets; } + + // servlet-mapping + private Map servletMappings = new HashMap(); + public void addServletMapping(String servletName, String urlPattern) { + servletMappings.put(servletName, urlPattern); + } + public Map getServletMappings() { return servletMappings; } + + // session-config/session-timeout + // Digester will check there is only one of these + private Integer sessionTimeout = null; + public void setSessionTimeout(String timeout) { + sessionTimeout = Integer.valueOf(timeout); + } + public Integer getSessionTimeout() { return sessionTimeout; } + + // mime-mapping + private Map mimeMappings = new HashMap(); + public void addMimeMapping(String extension, String mimeType) { + mimeMappings.put(extension, mimeType); + } + public Map getMimeMappings() { return mimeMappings; } + + // welcome-file-list + private Set welcomeFiles = new LinkedHashSet(); + public void addWelcomeFile(String welcomeFile) { + welcomeFiles.add(welcomeFile); + } + + // error-page + private Set errorPages = new HashSet(); + public void addErrorPage(ErrorPage errorPage) { + errorPages.add(errorPage); + } + public Set getErrorPages() { return errorPages; } + + // Digester will check there is only one jsp-config + // jsp-config/taglib or taglib (2.3 and earlier) + private Map taglibs = new HashMap(); + public void addTaglib(String uri, String location) { + taglibs.put(uri, location); + } + public Map getTaglibs() { return taglibs; } + + // jsp-config/jsp-property-group + private Set jspPropertyGroups = + new HashSet(); + public void addJspPropertyGroup(JspConfig.JspPropertyGroup propertyGroup) { + jspPropertyGroups.add(propertyGroup); + } + public Set getJspPropertyGroups() { + return jspPropertyGroups; + } + + // security-constraint + // TODO: Should support multiple display-name elements with language + // TODO: Should support multiple description elements with language + private Set securityConstraints = + new HashSet(); + public void addSecurityConstraint(SecurityConstraint securityConstraint) { + securityConstraints.add(securityConstraint); + } + public Set getSecurityConstraints() { + return securityConstraints; + } + + // login-config + // Digester will check there is only one of these + private LoginConfig loginConfig = null; + public void setLoginConfig(LoginConfig loginConfig) { + this.loginConfig = loginConfig; + } + public LoginConfig getLoginConfig() { return loginConfig; } + + // security-role + // TODO: description (multiple with language) is ignored + private Set securityRoles = new HashSet(); + public void addSecurityRole(String securityRole) { + securityRoles.add(securityRole); + } + public Set getSecurityRoles() { return securityRoles; } + + // env-entry + // TODO: Should support multiple description elements with language + private Map envEntries = + new HashMap(); + public void addEnvEntry(ContextEnvironment envEntry) { + if (envEntries.containsKey(envEntry.getName())) { + // env-entry names must be unique within a web(-fragment).xml + throw new IllegalArgumentException( + sm.getString("webXmlCommon.duplicateEnvEntry")); + } + envEntries.put(envEntry.getName(),envEntry); + } + public Map getEnvEntries() { return envEntries; } + + // ejb-ref + // TODO: Should support multiple description elements with language + private Set ejbRefs = new HashSet(); + public void addEjbRef(ContextEjb ejbRef) { ejbRefs.add(ejbRef); } + public Set getEjbRefs() { return ejbRefs; } + + // ejb-local-ref + // TODO: Should support multiple description elements with language + private Set ejbLocalRefs = new HashSet(); + public void addEjbLocalRef(ContextLocalEjb ejbLocalRef) { + ejbLocalRefs.add(ejbLocalRef); + } + public Set getEjbLocalRefs() { return ejbLocalRefs; } + + // service-ref + // TODO: Should support multiple description elements with language + // TODO: Should support multiple display-names elements with language + // TODO: Should support multiple icon elements ??? + private Set serviceRefs = new HashSet(); + public void addServiceRef(ContextService serviceRef) { + serviceRefs.add(serviceRef); + } + public Set getServiceRefs() { return serviceRefs; } + + // resource-ref + // TODO: Should support multiple description elements with language + private Map resourceRefs = + new HashMap(); + public void addResourceRef(ContextResource resourceRef) { + if (resourceRefs.containsKey(resourceRef.getName())) { + // resource-ref names must be unique within a web(-fragment).xml + throw new IllegalArgumentException( + sm.getString("webXmlCommon.duplicateResourceRef")); + } + resourceRefs.put(resourceRef.getName(), resourceRef); + } + public Map getResourceRefs() { + return resourceRefs; + } + + // resource-env-ref + // TODO: Should support multiple description elements with language + private Map resourceEnvRefs = + new HashMap(); + public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) { + if (resourceEnvRefs.containsKey(resourceEnvRef.getName())) { + // resource-env-ref names must be unique within a web(-fragment).xml + throw new IllegalArgumentException( + sm.getString("webXmlCommon.duplicateResourceEnvRef")); + } + resourceEnvRefs.put(resourceEnvRef.getName(), resourceEnvRef); + } + public Map getResourceEnvRefs() { + return resourceEnvRefs; + } + + // message-destination-ref + // TODO: Should support multiple description elements with language + private Map messageDestinationRefs = + new HashMap(); + public void addMessageDestinationRef( + MessageDestinationRef messageDestinationRef) { + if (messageDestinationRefs.containsKey( + messageDestinationRef.getName())) { + // message-destination-ref names must be unique within a + // web(-fragment).xml + throw new IllegalArgumentException(sm.getString( + "webXmlCommon.duplicateMessageDestinationRef")); + } + messageDestinationRefs.put(messageDestinationRef.getName(), + messageDestinationRef); + } + public Map getMessageDestinationRefs() { + return messageDestinationRefs; + } + + // message-destination + // TODO: Should support multiple description elements with language + // TODO: Should support multiple display-names elements with language + // TODO: Should support multiple icon elements ??? + private Map messageDestinations = + new HashMap(); + public void addMessageDestination( + MessageDestination messageDestination) { + if (messageDestinations.containsKey( + messageDestination.getName())) { + // message-destination names must be unique within a + // web(-fragment).xml + throw new IllegalArgumentException( + sm.getString("webXmlCommon.duplicateMessageDestination")); + } + messageDestinations.put(messageDestination.getName(), + messageDestination); + } + public Map getMessageDestinations() { + return messageDestinations; + } + + // locale-encoging-mapping-list + private Map localeEncodingMappings = + new HashMap(); + public void addLocaleEncodingMapping(String locale, String encoding) { + localeEncodingMappings.put(locale, encoding); + } + public Map getLocalEncodingMappings() { + return localeEncodingMappings; + } +} diff --git a/java/org/apache/catalina/startup/WebXmlFragment.java b/java/org/apache/catalina/startup/WebXmlFragment.java new file mode 100644 index 000000000..32f044671 --- /dev/null +++ b/java/org/apache/catalina/startup/WebXmlFragment.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.catalina.startup; + +import java.util.LinkedHashSet; +import java.util.Set; + +public class WebXmlFragment extends WebXmlCommon { + + // Relative ordering + private Set after = new LinkedHashSet(); + public void addAfterOrdering(String name) { + after.add(name); + } + public void addAfterOrderingOthers() { + if (before.contains(ORDER_OTHERS)) { + throw new IllegalArgumentException(sm.getString( + "webXmlFragment.multipleOther")); + } + after.add(ORDER_OTHERS); + } + private Set before = new LinkedHashSet(); + public void addBeforeOrdering(String name) { + before.add(name); + } + public void addBeforeOrderingOthers() { + if (after.contains(ORDER_OTHERS)) { + throw new IllegalArgumentException(sm.getString( + "webXmlFragment.multipleOther")); + } + before.add(ORDER_OTHERS); + } +} diff --git a/java/org/apache/jasper/compiler/JspConfig.java b/java/org/apache/jasper/compiler/JspConfig.java index 8982a25d4..0c44a737e 100644 --- a/java/org/apache/jasper/compiler/JspConfig.java +++ b/java/org/apache/jasper/compiler/JspConfig.java @@ -448,7 +448,7 @@ public class JspConfig { return false; } - static class JspPropertyGroup { + public static class JspPropertyGroup { private String path; private String extension; private JspProperty jspProperty;