JBossWeb SVN: r1062 - trunk.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-25 10:32:57 -0400 (Mon, 25 May 2009)
New Revision: 1062
Modified:
trunk/build.xml
trunk/dist.xml
Log:
- Some encoding tweaks.
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2009-05-25 14:32:03 UTC (rev 1061)
+++ trunk/build.xml 2009-05-25 14:32:57 UTC (rev 1062)
@@ -337,7 +337,7 @@
</copy>
<filter token="VERSION" value="${version}"/>
<copy tofile="${tomcat.build}/webapps/docs/RELEASE-NOTES.txt" file="RELEASE-NOTES"
- filtering="true" />
+ filtering="true" encoding="ISO-8859-1" />
<copy tofile="${tomcat.build}/webapps/docs/appdev/sample/build.xml"
file="webapps/docs/appdev/build.xml.txt"/>
@@ -573,7 +573,7 @@
<filter token="VERSION" value="${version}"/>
<copy tofile="${tomcat.build}/webapps/ROOT/RELEASE-NOTES.txt" file="RELEASE-NOTES"
- filtering="true" />
+ filtering="true" encoding="ISO-8859-1" />
<copy file="${tomcat-dbcp.jar}" todir="${tomcat.build}/lib" />
<copy file="${jasper-jdt.jar}" todir="${tomcat.build}/lib" />
Modified: trunk/dist.xml
===================================================================
--- trunk/dist.xml 2009-05-25 14:32:03 UTC (rev 1061)
+++ trunk/dist.xml 2009-05-25 14:32:57 UTC (rev 1062)
@@ -128,8 +128,8 @@
<touch file="${tomcat.dist}/temp/safeToDelete.tmp" />
<!-- Correct permissions and line endings on "bin" scripts -->
- <fixcrlf srcdir="${tomcat.dist}/bin" includes="*.sh" eol="lf"/>
- <fixcrlf srcdir="${tomcat.dist}/bin" includes="*.bat" eol="crlf"/>
+ <fixcrlf srcdir="${tomcat.dist}/bin" includes="*.sh" eol="lf" encoding="ISO-8859-1" fixlast="false"/>
+ <fixcrlf srcdir="${tomcat.dist}/bin" includes="*.bat" eol="crlf" encoding="ISO-8859-1" fixlast="false"/>
<chmod dir="${tomcat.dist}/bin" includes="*.sh" perm="+x"/>
</target>
@@ -141,7 +141,7 @@
author="true" version="true"
windowtitle="JBoss Web API Documentation"
doctitle="JBoss Web API"
- bottom="Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved."
+ bottom="Copyright &#169; 2000-${year} Apache Software Foundation. All Rights Reserved."
additionalparam="-breakiterator"
maxmemory="256m" >
</javadoc>
@@ -406,8 +406,8 @@
<!-- Packages the core tar.gz distro -->
<target name="package-tgz">
- <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="lf"/>
- <fixcrlf srcdir="${tomcat.dist}/conf" eol="lf"/>
+ <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="lf" encoding="ISO-8859-1" fixlast="false"/>
+ <fixcrlf srcdir="${tomcat.dist}/conf" eol="lf" encoding="ISO-8859-1" fixlast="false"/>
<tar longfile="gnu" compression="gzip"
tarfile="${tomcat.release}/v${version}/bin/${final.name}.tar.gz">
<tarfileset dir="${tomcat.dist}" mode="755" prefix="${final.name}">
@@ -471,8 +471,8 @@
<!-- Packages the deployer Tomcat distro in tar.gz format -->
<target name="package-deployer-tgz">
<fixcrlf srcdir="${tomcat.dist}"
- includes="*.txt,LICENSE,NOTICE" eol="lf"/>
- <fixcrlf srcdir="${tomcat.deployer}" includes="*.xml" eol="lf"/>
+ includes="*.txt,LICENSE,NOTICE" eol="lf" encoding="ISO-8859-1" fixlast="false"/>
+ <fixcrlf srcdir="${tomcat.deployer}" includes="*.xml" eol="lf" encoding="ISO-8859-1" fixlast="false"/>
<tar longfile="gnu" compression="gzip"
tarfile="${tomcat.release}/v${version}/bin/${final.name}-deployer.tar.gz">
@@ -497,7 +497,7 @@
<target name="package-docs-tgz">
<!-- Package gocs -->
- <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="lf"/>
+ <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="lf" encoding="ISO-8859-1" fixlast="false"/>
<tar longfile="gnu" compression="gzip"
tarfile="${tomcat.release}/v${version}/bin/${final.name}-fulldocs.tar.gz">
@@ -533,7 +533,8 @@
<!-- Packages the source code distribution in tar.gz format -->
<target name="package-src-tgz">
<fixcrlf srcdir="${tomcat.dist}/src"
- excludes="**/*.jar,**/*.gif,**/*.bmp,**/*.jpg,**/*.ico,**/*.war,**/*.exe,**/*.pdf,**/*.bin,**/*.dia" eol="lf"/>
+ excludes="**/*.jar,**/*.gif,**/*.bmp,**/*.jpg,**/*.ico,**/*.war,**/*.exe,**/*.pdf,**/*.bin,**/*.dia" eol="lf"
+ encoding="ISO-8859-1" fixlast="false"/>
<tar longfile="gnu" compression="gzip"
tarfile="${tomcat.release}/v${version}/src/${final-src.name}.tar.gz">
<tarfileset dir="${tomcat.dist}/src" prefix="${final-src.name}" />
15 years, 7 months
JBossWeb SVN: r1061 - trunk/java/org/apache/catalina/loader.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-25 10:32:03 -0400 (Mon, 25 May 2009)
New Revision: 1061
Modified:
trunk/java/org/apache/catalina/loader/WebappClassLoader.java
Log:
- Fix bad stream close.
Modified: trunk/java/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-05-25 14:31:46 UTC (rev 1060)
+++ trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-05-25 14:32:03 UTC (rev 1061)
@@ -2064,13 +2064,13 @@
break;
pos += n;
}
- binaryStream.close();
} catch (IOException e) {
- e.printStackTrace();
+ log.error(sm.getString("webappClassLoader.readError", name), e);
return null;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
+ } finally {
+ try {
+ binaryStream.close();
+ } catch (IOException e) {}
}
if (fileNeedConvert) {
15 years, 7 months
JBossWeb SVN: r1060 - trunk/java/org/apache/jasper/el.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-25 10:31:46 -0400 (Mon, 25 May 2009)
New Revision: 1060
Modified:
trunk/java/org/apache/jasper/el/ELResolverImpl.java
Log:
- Clean up casts.
Modified: trunk/java/org/apache/jasper/el/ELResolverImpl.java
===================================================================
--- trunk/java/org/apache/jasper/el/ELResolverImpl.java 2009-05-25 14:31:35 UTC (rev 1059)
+++ trunk/java/org/apache/jasper/el/ELResolverImpl.java 2009-05-25 14:31:46 UTC (rev 1060)
@@ -148,12 +148,12 @@
public static ELResolver getDefaultResolver() {
if (Constants.IS_SECURITY_ENABLED) {
- ELResolver defaultResolver = new CompositeELResolver();
- ((CompositeELResolver) defaultResolver).add(new MapELResolver());
- ((CompositeELResolver) defaultResolver).add(new ResourceBundleELResolver());
- ((CompositeELResolver) defaultResolver).add(new ListELResolver());
- ((CompositeELResolver) defaultResolver).add(new ArrayELResolver());
- ((CompositeELResolver) defaultResolver).add(new BeanELResolver());
+ CompositeELResolver defaultResolver = new CompositeELResolver();
+ defaultResolver.add(new MapELResolver());
+ defaultResolver.add(new ResourceBundleELResolver());
+ defaultResolver.add(new ListELResolver());
+ defaultResolver.add(new ArrayELResolver());
+ defaultResolver.add(new BeanELResolver());
return defaultResolver;
} else {
return DefaultResolver;
15 years, 7 months
JBossWeb SVN: r1059 - trunk/java/org/apache/jasper/compiler.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-25 10:31:35 -0400 (Mon, 25 May 2009)
New Revision: 1059
Modified:
trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java
Log:
- Revert at begin patch.
Modified: trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java 2009-05-25 13:05:31 UTC (rev 1058)
+++ trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java 2009-05-25 14:31:35 UTC (rev 1059)
@@ -68,7 +68,7 @@
public void visit(Node.CustomTag n) throws JasperException {
setScriptingVars(n, VariableInfo.AT_BEGIN);
setScriptingVars(n, VariableInfo.NESTED);
- new ScriptingVariableVisitor(err).visitBody(n);
+ visitBody(n);
setScriptingVars(n, VariableInfo.AT_END);
}
15 years, 7 months
JBossWeb SVN: r1058 - in trunk/java/org/apache/catalina: startup and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-25 09:05:31 -0400 (Mon, 25 May 2009)
New Revision: 1058
Added:
trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java
Modified:
trunk/java/org/apache/catalina/startup/WebRuleSet.java
Log:
- Add jsp-prop-group bean.
- Add a rule to parse the taglib element.
Added: trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java (rev 0)
+++ trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java 2009-05-25 13:05:31 UTC (rev 1058)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.apache.catalina.deploy;
+
+import java.io.Serializable;
+
+public class JspPropertyGroup implements Serializable {
+
+ protected String urlPattern = null;
+ protected boolean elIgnored = false;
+ protected String pageEncoding = null;
+ protected boolean scriptingInvalid = false;
+ protected boolean isXml = false;
+ protected String includePrelude = null;
+ protected String includeCoda = null;
+ protected boolean deferredSyntaxAllowedAsLiteral = false;
+ protected boolean trimDirectiveWhitespaces = false;
+ protected String defaultContentType = null;
+ protected String buffer = null;
+ protected boolean errorOnUndeclaredNamespace = false;
+
+ public String getUrlPattern() {
+ return urlPattern;
+ }
+ public void setUrlPattern(String urlPattern) {
+ this.urlPattern = urlPattern;
+ }
+ public boolean isElIgnored() {
+ return elIgnored;
+ }
+ public void setElIgnored(boolean elIgnored) {
+ this.elIgnored = elIgnored;
+ }
+ public String getPageEncoding() {
+ return pageEncoding;
+ }
+ public void setPageEncoding(String pageEncoding) {
+ this.pageEncoding = pageEncoding;
+ }
+ public boolean isScriptingInvalid() {
+ return scriptingInvalid;
+ }
+ public void setScriptingInvalid(boolean scriptingInvalid) {
+ this.scriptingInvalid = scriptingInvalid;
+ }
+ public boolean isXml() {
+ return isXml;
+ }
+ public void setXml(boolean isXml) {
+ this.isXml = isXml;
+ }
+ public String getIncludePrelude() {
+ return includePrelude;
+ }
+ public void setIncludePrelude(String includePrelude) {
+ this.includePrelude = includePrelude;
+ }
+ public String getIncludeCoda() {
+ return includeCoda;
+ }
+ public void setIncludeCoda(String includeCoda) {
+ this.includeCoda = includeCoda;
+ }
+ public boolean isDeferredSyntaxAllowedAsLiteral() {
+ return deferredSyntaxAllowedAsLiteral;
+ }
+ public void setDeferredSyntaxAllowedAsLiteral(
+ boolean deferredSyntaxAllowedAsLiteral) {
+ this.deferredSyntaxAllowedAsLiteral = deferredSyntaxAllowedAsLiteral;
+ }
+ public boolean isTrimDirectiveWhitespaces() {
+ return trimDirectiveWhitespaces;
+ }
+ public void setTrimDirectiveWhitespaces(boolean trimDirectiveWhitespaces) {
+ this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
+ }
+ public String getDefaultContentType() {
+ return defaultContentType;
+ }
+ public void setDefaultContentType(String defaultContentType) {
+ this.defaultContentType = defaultContentType;
+ }
+ public String getBuffer() {
+ return buffer;
+ }
+ public void setBuffer(String buffer) {
+ this.buffer = buffer;
+ }
+ public boolean isErrorOnUndeclaredNamespace() {
+ return errorOnUndeclaredNamespace;
+ }
+ public void setErrorOnUndeclaredNamespace(boolean errorOnUndeclaredNamespace) {
+ this.errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
+ }
+
+}
Modified: trunk/java/org/apache/catalina/startup/WebRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-05-19 16:56:51 UTC (rev 1057)
+++ trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-05-25 13:05:31 UTC (rev 1058)
@@ -239,6 +239,11 @@
digester.addRule(prefix + elementName + "/jsp-config",
jspConfig);
+ digester.addCallMethod(prefix + elementName + "/jsp-config/taglib",
+ "addTaglib", 2);
+ digester.addCallParam(prefix + elementName + "/jsp-config/taglib/taglib-location", 1);
+ digester.addCallParam(prefix + elementName + "/jsp-config/taglib/taglib-uri", 0);
+
digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/url-pattern",
"addJspMapping", 0);
15 years, 7 months
JBossWeb SVN: r1057 - in trunk: java/org/apache/catalina and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-19 12:56:51 -0400 (Tue, 19 May 2009)
New Revision: 1057
Modified:
trunk/ROADMAP.txt
trunk/java/org/apache/catalina/Globals.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/LocalStrings.properties
trunk/java/org/apache/catalina/startup/WebRuleSet.java
trunk/java/org/apache/naming/resources/JARDirContext.java
trunk/java/org/apache/naming/resources/ProxyDirContext.java
Log:
- Add first pass at overlay support.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/ROADMAP.txt 2009-05-19 16:56:51 UTC (rev 1057)
@@ -1,7 +1,6 @@
Roadmap for JBoss Web 3.0
Standalone:
-- Resources overlay implementation
- Jasper plugins for TLD metadata and web.xml metadata
- Access control annotations
- Update digester XML parsing rules for web.xml updates (session tracking-mode, cookie-config, servlet enabled,
Modified: trunk/java/org/apache/catalina/Globals.java
===================================================================
--- trunk/java/org/apache/catalina/Globals.java 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/java/org/apache/catalina/Globals.java 2009-05-19 16:56:51 UTC (rev 1057)
@@ -343,7 +343,7 @@
* The folder used for JAR overlays.
*/
public static final String OVERLAY_PATH =
- System.getProperty("org.apache.catalina.OVERLAY_PATH", "/META-INF/resources/");
+ System.getProperty("org.apache.catalina.OVERLAY_PATH", "/META-INF/resources");
/**
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-19 16:56:51 UTC (rev 1057)
@@ -109,6 +109,8 @@
import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.WebOrdering;
import org.apache.catalina.util.StringManager;
+import org.apache.naming.resources.JARDirContext;
+import org.apache.naming.resources.ProxyDirContext;
import org.apache.tomcat.WarComponents;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
@@ -588,7 +590,11 @@
}
- // FIXME: Do TLD parsing when found ? (clarification from EG states there's no order)
+
+ /**
+ * Parse TLDs. This is separate, and is not subject to the order defined. Also,
+ * all TLDs from all JARs are parsed.
+ */
protected void applicationTldConfig() {
// Add all TLDs from explicit web config
@@ -1155,13 +1161,11 @@
scanClasses(explodedJars[i], "", !context.getIgnoreAnnotations());
}
+ // Parse web fragment according to order
Iterator<String> orderIterator = order.iterator();
while (orderIterator.hasNext()) {
String jar = orderIterator.next();
JarFile jarFile = jarRepository.findJar(jar);
-
- // Parse web fragment according to order
- // FIXME: Merging rules
InputStream is = null;
ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
if (entry != null) {
@@ -1196,14 +1200,15 @@
}
}
}
-
+ // Scan the JAR for TLDs and annotations
scanJar(jarFile, true);
}
- // Process any Jar not in the order, without annotations
+ // Process any Jar not in the order
JarFile[] jarFiles = jarRepository.findJars();
for (int i = 0; i < jarFiles.length; i++) {
if (!order.contains(jarFiles[i].getName())) {
+ // Scan the JAR for TLDs only
scanJar(jarFiles[i], false);
}
}
@@ -1831,18 +1836,28 @@
authenticatorConfig();
}
- // Find and configure webapp overlays
+ // Find and configure overlays
if (ok) {
JarRepository jarRepository = context.getJarRepository();
JarFile[] jars = jarRepository.findJars();
for (int i = 0; i < jars.length; i++) {
if (jars[i].getEntry(Globals.OVERLAY_PATH) != null) {
+ if (context.getResources() instanceof ProxyDirContext) {
+ ProxyDirContext resources = (ProxyDirContext) context.getResources();
+ JARDirContext overlay = new JARDirContext();
+ overlay.setJarFile(jars[i], Globals.OVERLAY_PATH);
+ resources.addOverlay(overlay);
+ } else {
+ // Error, overlays need a ProxyDirContext to compose results
+ log.error(sm.getString("contextConfig.noOverlay", jars[i].getName()));
+ ok = false;
+ }
overlays.add(jars[i].getName());
}
}
}
- // Make our application available if no problems were encountered
+ // Make our application unavailable if problems were encountered
if (!ok) {
log.error(sm.getString("contextConfig.unavailable"));
context.setConfigured(false);
Modified: trunk/java/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-19 16:56:51 UTC (rev 1057)
@@ -24,6 +24,7 @@
contextConfig.init=ContextConfig: Initializing
contextConfig.invalidAbsoluteOrder=Invalid absolute order
contextConfig.missingRealm=No Realm has been configured to authenticate against
+contextConfig.noOverlay=Overlay used in {0} requires a ProxyDirContext in the context
contextConfig.role.auth=WARNING: Security role name {0} used in an <auth-constraint> without being defined in a <security-role>
contextConfig.role.link=WARNING: Security role name {0} used in a <role-link> without being defined in a <security-role>
contextConfig.role.runas=WARNING: Security role name {0} used in a <run-as> without being defined in a <security-role>
Modified: trunk/java/org/apache/catalina/startup/WebRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-05-19 16:56:51 UTC (rev 1057)
@@ -1,18 +1,46 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*
- * 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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.
*/
@@ -44,6 +72,7 @@
*
* @author Craig R. McClanahan
* @version $Revision$ $Date$
+ * FIXME: this needs to implement merging rules
*/
public class WebRuleSet extends RuleSetBase {
Modified: trunk/java/org/apache/naming/resources/JARDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/JARDirContext.java 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/java/org/apache/naming/resources/JARDirContext.java 2009-05-19 16:56:51 UTC (rev 1057)
@@ -148,11 +148,6 @@
* Set the JAR file from which data will be read.
*
* @param jarFile The JAR file
- *
- * @exception IllegalArgumentException if the specified value is not
- * supported by this implementation
- * @exception IllegalArgumentException if this would create a
- * malformed URL
*/
public void setJarFile(JarFile jarFile, String prefix) {
@@ -162,6 +157,9 @@
(sm.getString("resources.null"));
this.prefix = prefix;
+ if (prefix.startsWith("/")) {
+ this.prefix = prefix.substring(1);
+ }
this.base = jarFile;
loadEntries();
@@ -214,8 +212,6 @@
*/
public Object lookup(Name name)
throws NamingException {
- //if (prefixName != null)
- // name.addAll(0, prefixName);
if (name.isEmpty())
return this;
Entry entry = treeLookup(name);
@@ -301,8 +297,6 @@
*/
public NamingEnumeration list(Name name)
throws NamingException {
- //if (prefixName != null)
- // name.addAll(0, prefixName);
if (name.isEmpty())
return new NamingContextEnumeration(list(entries).iterator());
Entry entry = treeLookup(name);
@@ -347,8 +341,6 @@
*/
public NamingEnumeration listBindings(Name name)
throws NamingException {
- //if (prefixName != null)
- // name.addAll(0, prefixName);
if (name.isEmpty())
return new NamingContextBindingsEnumeration(list(entries).iterator(),
this);
@@ -464,9 +456,6 @@
public Attributes getAttributes(Name name, String[] attrIds)
throws NamingException {
- //if (prefixName != null)
- // name.addAll(0, prefixName);
-
Entry entry = null;
if (name.isEmpty())
entry = entries;
@@ -741,37 +730,6 @@
/**
- * Add a prefix.
- */
- protected String prefix(String path) {
- if (prefix == null) {
- return path;
- } else if (path.startsWith("/")) {
- return prefix + path;
- } else {
- return prefix + "/" + path;
- }
- }
-
-
- /**
- * Remove a prefix.
- */
- protected String unprefix(String path) {
- if (prefix == null) {
- return path;
- } else if (path.startsWith("/")) {
- if (path.startsWith(prefix)) {
-
- }
- return prefix + path;
- } else {
- return prefix + "/" + path;
- }
- }
-
-
- /**
* Normalize the name of an entry read from the Zip.
*/
protected String normalize(ZipEntry entry) {
@@ -803,7 +761,6 @@
// Don't create entries for everything in the JAR if there is a prefix
continue;
}
- name = name.substring(prefix.length());
int pos = name.lastIndexOf('/');
// Check that parent entries exist and, if not, create them.
// This fixes a bug for war files that don't record separate
@@ -811,8 +768,8 @@
int currentPos = -1;
int lastPos = 0;
while ((currentPos = name.indexOf('/', lastPos)) != -1) {
- Name parentName = new CompositeName(name.substring(0, lastPos));
- Name childName = new CompositeName(name.substring(0, currentPos));
+ Name parentName = new CompositeName(name.substring(prefix.length(), lastPos));
+ Name childName = new CompositeName(name.substring(prefix.length(), currentPos));
String entryName = name.substring(lastPos, currentPos);
// Parent should have been created in last cycle through
// this loop
@@ -824,7 +781,7 @@
// normalize method and add '/' character to end to
// signify that it is a directory entry
String zipName = name.substring(1, currentPos) + "/";
- child = new Entry(entryName, new JarEntry(prefix + zipName));
+ child = new Entry(entryName, new JarEntry(zipName));
if (parent != null)
parent.addChild(child);
}
Modified: trunk/java/org/apache/naming/resources/ProxyDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-15 16:25:46 UTC (rev 1056)
+++ trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-19 16:56:51 UTC (rev 1057)
@@ -49,22 +49,32 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.HashMap;
import java.util.Hashtable;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
+import javax.naming.NameAlreadyBoundException;
import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.AttributeModificationException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributesException;
+import javax.naming.directory.InvalidSearchControlsException;
+import javax.naming.directory.InvalidSearchFilterException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
+import org.apache.naming.NamingContextBindingsEnumeration;
+import org.apache.naming.NamingContextEnumeration;
import org.apache.naming.StringManager;
/**
@@ -149,7 +159,7 @@
/**
* Overlay DirContexts.
*/
- protected DirContext[] overlayDirContexts;
+ protected DirContext[] overlays = null;
/**
@@ -247,6 +257,20 @@
return this.contextName;
}
+
+ /**
+ * Add overlay.
+ */
+ public void addOverlay(DirContext overlay) {
+ if (overlays == null) {
+ overlays = new DirContext[0];
+ }
+ DirContext[] result = new DirContext[overlays.length + 1];
+ System.arraycopy(overlays, 0, result, 0, overlays.length);
+ result[overlays.length] = overlay;
+ overlays = result;
+ }
+
// -------------------------------------------------------- Context Methods
@@ -474,10 +498,53 @@
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- // FIXME: Should use overlays
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
- return dirContext.list(parseName(name));
+ if (overlays == null) {
+ return dirContext.list(parseName(name));
+ } else {
+ NamingException notFound = null;
+ HashMap<String, NameClassPair> merged = null;
+ NamingEnumeration<NameClassPair> main = null;
+ try {
+ main = dirContext.list(parseName(name));
+ } catch (NamingException e) {
+ notFound = e;
+ }
+ for (int i = 0; i < overlays.length; i++) {
+ NamingEnumeration<NameClassPair> overlay = null;
+ try {
+ overlay = overlays[i].list(parseName(name));
+ } catch (NamingException e) {
+ // Ignore
+ }
+ if (main == null) {
+ main = overlay;
+ } else {
+ // Merge that into the merged set
+ if (merged == null) {
+ merged = new HashMap<String, NameClassPair>();
+ while (main.hasMore()) {
+ NameClassPair pair = main.next();
+ merged.put(pair.getName(), pair);
+ }
+ }
+ while (overlay.hasMore()) {
+ NameClassPair pair = overlay.next();
+ if (merged.get(pair.getName()) == null) {
+ merged.put(pair.getName(), pair);
+ }
+ }
+ }
+ }
+ if (main == null && merged == null) {
+ throw notFound;
+ } else if (merged != null) {
+ return new NamingContextEnumeration(merged.values().iterator());
+ } else {
+ return main;
+ }
+ }
}
@@ -490,10 +557,53 @@
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- // FIXME: Should use overlays
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
- return dirContext.list(parseName(name));
+ if (overlays == null) {
+ return dirContext.list(parseName(name));
+ } else {
+ NamingException notFound = null;
+ HashMap<String, NameClassPair> merged = null;
+ NamingEnumeration<NameClassPair> main = null;
+ try {
+ main = dirContext.list(parseName(name));
+ } catch (NamingException e) {
+ notFound = e;
+ }
+ for (int i = 0; i < overlays.length; i++) {
+ NamingEnumeration<NameClassPair> overlay = null;
+ try {
+ overlay = overlays[i].list(parseName(name));
+ } catch (NamingException e) {
+ // Ignore
+ }
+ if (main == null) {
+ main = overlay;
+ } else {
+ // Merge that into the merged set
+ if (merged == null) {
+ merged = new HashMap<String, NameClassPair>();
+ while (main.hasMore()) {
+ NameClassPair pair = main.next();
+ merged.put(pair.getName(), pair);
+ }
+ }
+ while (overlay.hasMore()) {
+ NameClassPair pair = overlay.next();
+ if (merged.get(pair.getName()) == null) {
+ merged.put(pair.getName(), pair);
+ }
+ }
+ }
+ }
+ if (main == null && merged == null) {
+ throw notFound;
+ } else if (merged != null) {
+ return new NamingContextEnumeration(merged.values().iterator());
+ } else {
+ return main;
+ }
+ }
}
@@ -510,10 +620,53 @@
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- // FIXME: Should use overlays
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
- return dirContext.listBindings(parseName(name));
+ if (overlays == null) {
+ return dirContext.listBindings(parseName(name));
+ } else {
+ NamingException notFound = null;
+ HashMap<String, Binding> merged = null;
+ NamingEnumeration<Binding> main = null;
+ try {
+ main = dirContext.listBindings(parseName(name));
+ } catch (NamingException e) {
+ notFound = e;
+ }
+ for (int i = 0; i < overlays.length; i++) {
+ NamingEnumeration<Binding> overlay = null;
+ try {
+ overlay = overlays[i].listBindings(parseName(name));
+ } catch (NamingException e) {
+ // Ignore
+ }
+ if (main == null) {
+ main = overlay;
+ } else {
+ // Merge that into the merged set
+ if (merged == null) {
+ merged = new HashMap<String, Binding>();
+ while (main.hasMore()) {
+ Binding pair = main.next();
+ merged.put(pair.getName(), pair);
+ }
+ }
+ while (overlay.hasMore()) {
+ Binding pair = overlay.next();
+ if (merged.get(pair.getName()) == null) {
+ merged.put(pair.getName(), pair);
+ }
+ }
+ }
+ }
+ if (main == null && merged == null) {
+ throw notFound;
+ } else if (merged != null) {
+ return new NamingContextBindingsEnumeration(merged.values().iterator(), this);
+ } else {
+ return main;
+ }
+ }
}
@@ -526,10 +679,53 @@
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- // FIXME: Should use overlays
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
- return dirContext.listBindings(parseName(name));
+ if (overlays == null) {
+ return dirContext.listBindings(parseName(name));
+ } else {
+ NamingException notFound = null;
+ HashMap<String, Binding> merged = null;
+ NamingEnumeration<Binding> main = null;
+ try {
+ main = dirContext.listBindings(parseName(name));
+ } catch (NamingException e) {
+ notFound = e;
+ }
+ for (int i = 0; i < overlays.length; i++) {
+ NamingEnumeration<Binding> overlay = null;
+ try {
+ overlay = overlays[i].listBindings(parseName(name));
+ } catch (NamingException e) {
+ // Ignore
+ }
+ if (main == null) {
+ main = overlay;
+ } else {
+ // Merge that into the merged set
+ if (merged == null) {
+ merged = new HashMap<String, Binding>();
+ while (main.hasMore()) {
+ Binding pair = main.next();
+ merged.put(pair.getName(), pair);
+ }
+ }
+ while (overlay.hasMore()) {
+ Binding pair = overlay.next();
+ if (merged.get(pair.getName()) == null) {
+ merged.put(pair.getName(), pair);
+ }
+ }
+ }
+ }
+ if (main == null && merged == null) {
+ throw notFound;
+ } else if (merged != null) {
+ return new NamingContextBindingsEnumeration(merged.values().iterator(), this);
+ } else {
+ return main;
+ }
+ }
}
@@ -1529,10 +1725,10 @@
/**
* Load entry into cache.
*/
- // FIXME: Should use overlays
protected void cacheLoad(CacheEntry entry) {
String name = entry.name;
+ DirContext currentContext = dirContext;
// Retrieve missing info
boolean exists = true;
@@ -1540,7 +1736,7 @@
// Retrieving attributes
if (entry.attributes == null) {
try {
- Attributes attributes = dirContext.getAttributes(entry.name);
+ Attributes attributes = currentContext.getAttributes(entry.name);
if (!(attributes instanceof ResourceAttributes)) {
entry.attributes =
new ResourceAttributes(attributes);
@@ -1551,11 +1747,30 @@
exists = false;
}
}
+
+ // Check overlays
+ if (overlays != null) {
+ for (int i = 0; (i < overlays.length) && !exists; i++) {
+ try {
+ Attributes attributes = overlays[i].getAttributes(entry.name);
+ if (!(attributes instanceof ResourceAttributes)) {
+ entry.attributes =
+ new ResourceAttributes(attributes);
+ } else {
+ entry.attributes = (ResourceAttributes) attributes;
+ }
+ currentContext = overlays[i];
+ exists = true;
+ } catch (NamingException e) {
+ // Ignore
+ }
+ }
+ }
// Retriving object
if ((exists) && (entry.resource == null) && (entry.context == null)) {
try {
- Object object = dirContext.lookup(name);
+ Object object = currentContext.lookup(name);
if (object instanceof InputStream) {
entry.resource = new Resource((InputStream) object);
} else if (object instanceof DirContext) {
@@ -1610,7 +1825,12 @@
entry.exists = exists;
// Set timestamp
- entry.timestamp = System.currentTimeMillis() + cacheTTL;
+ if (currentContext == dirContext) {
+ entry.timestamp = System.currentTimeMillis() + cacheTTL;
+ } else {
+ // Overlay cache never expire
+ entry.timestamp = Long.MAX_VALUE;
+ }
// Add new entry to cache
synchronized (cache) {
15 years, 7 months
JBossWeb SVN: r1056 - in trunk/java/org/apache/catalina: core and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-15 12:25:46 -0400 (Fri, 15 May 2009)
New Revision: 1056
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Fix the ordering fixmes. TLD processing should have no order.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-05-15 02:45:56 UTC (rev 1055)
+++ trunk/java/org/apache/catalina/Context.java 2009-05-15 16:25:46 UTC (rev 1056)
@@ -66,6 +66,13 @@
public static final String RELOAD_EVENT = "reload";
+ /**
+ * The LifecycleEvent type sent to complete the configuration
+ * (called after running all listeners and other init callbacks).
+ */
+ public static final String COMPLETE_CONFIG_EVENT = "complete-config";
+
+
// ------------------------------------------------------------- Properties
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-05-15 02:45:56 UTC (rev 1055)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-05-15 16:25:46 UTC (rev 1056)
@@ -4127,7 +4127,16 @@
}
}
- // Start manager
+ if (ok) {
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(COMPLETE_CONFIG_EVENT, null);
+ }
+
+ if (!getConfigured()) {
+ ok = false;
+ }
+
+ // Start manager
if (ok && (manager != null) && (manager instanceof Lifecycle)) {
ok = false;
((Lifecycle) getManager()).start();
@@ -4152,6 +4161,10 @@
loadOnStartup(findChildren());
}
+ } catch (Throwable t) {
+ // This can happen in rare cases with custom components
+ ok = false;
+ log.error(sm.getString("standardContext.startFailed", getName()), t);
} finally {
// Unbinding thread
unbindThread(oldCCL);
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-15 02:45:56 UTC (rev 1055)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-15 16:25:46 UTC (rev 1056)
@@ -385,6 +385,25 @@
context.setDocBase(originalDocBase);
originalDocBase = docBase;
}
+ // Invoke Servlet container initializer: instantiate and call onStartup
+ if (ok) {
+ Iterator<ServletContainerInitializerInfo> initializers =
+ getServletContainerInitializerInfo().values().iterator();
+ while (initializers.hasNext()) {
+ ServletContainerInitializerInfo service = initializers.next();
+ try {
+ ServletContainerInitializer servletContainerInitializer =
+ (ServletContainerInitializer) service.getServletContainerInitializer().newInstance();
+ servletContainerInitializer.onStartup(service.getStartupNotifySet(), context.getServletContext());
+ } catch (Throwable t) {
+ log.error(sm.getString("contextConfig.servletContainerInitializer",
+ service.getServletContainerInitializer().getName()), t);
+ ok = false;
+ }
+ }
+ }
+ } else if (event.getType().equals(Context.COMPLETE_CONFIG_EVENT)) {
+ completeConfig();
} else if (event.getType().equals(Lifecycle.STOP_EVENT)) {
if (originalDocBase != null) {
String docBase = context.getDocBase();
@@ -569,7 +588,7 @@
}
- // FIXME: Do TLD parsing when found
+ // FIXME: Do TLD parsing when found ? (clarification from EG states there's no order)
protected void applicationTldConfig() {
// Add all TLDs from explicit web config
@@ -1356,7 +1375,8 @@
}
servletContainerInitializerClassName = servletContainerInitializerClassName.trim();
} catch (Exception e) {
- // FIXME: error message or exception
+ log.warn(sm.getString("contextConfig.servletContainerInitializer", file.getName()), e);
+ return;
} finally {
try {
if (is != null) {
@@ -1378,7 +1398,8 @@
typesArray = handlesTypes.value();
}
} catch (Throwable t) {
- // FIXME: error message or exception
+ log.warn(sm.getString("contextConfig.servletContainerInitializer", file.getName()), t);
+ return;
}
}
// Add in jarService map, and add in the local map used to speed up lookups
@@ -1765,49 +1786,7 @@
if (ok) {
applicationTldConfig();
}
- // Scan all Servlet API related annotations
- if (ok && !context.getIgnoreAnnotations()) {
- // FIXME: Moved to after running all listeners, as they can add servlets or filters
- WebAnnotationSet.loadApplicationAnnotations(context);
- }
- if (ok) {
- validateSecurityRoles();
- }
- // Find webapp overlays
- if (ok) {
- JarRepository jarRepository = context.getJarRepository();
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- if (jars[i].getEntry(Globals.OVERLAY_PATH) != null) {
- overlays.add(jars[i].getName());
- }
- }
- }
-
- // Invoke Servlet container initializer: instantiate and call onStartup
- if (ok) {
- Iterator<ServletContainerInitializerInfo> initializers =
- getServletContainerInitializerInfo().values().iterator();
- while (initializers.hasNext()) {
- ServletContainerInitializerInfo service = initializers.next();
- try {
- ServletContainerInitializer servletContainerInitializer =
- (ServletContainerInitializer) service.getServletContainerInitializer().newInstance();
- servletContainerInitializer.onStartup(service.getStartupNotifySet(), context.getServletContext());
- } catch (Throwable t) {
- log.error(sm.getString("contextConfig.servletContainerInitializer",
- service.getServletContainerInitializer()), t);
- ok = false;
- }
- }
- }
-
- // Configure an authenticator if we need one
- if (ok) {
- authenticatorConfig();
- }
-
// Dump the contents of this pipeline if requested
if ((log.isDebugEnabled()) && (context instanceof ContainerBase)) {
log.debug("Pipeline Configuration:");
@@ -1833,7 +1812,44 @@
}
+ /**
+ * Process a "start" event for this Context.
+ */
+ protected void completeConfig() {
+ // Called from StandardContext.start()
+ // Scan all Servlet API related annotations
+ if (ok && !context.getIgnoreAnnotations()) {
+ WebAnnotationSet.loadApplicationAnnotations(context);
+ }
+ if (ok) {
+ validateSecurityRoles();
+ }
+
+ // Configure an authenticator if we need one
+ if (ok) {
+ authenticatorConfig();
+ }
+
+ // Find and configure webapp overlays
+ if (ok) {
+ JarRepository jarRepository = context.getJarRepository();
+ JarFile[] jars = jarRepository.findJars();
+ for (int i = 0; i < jars.length; i++) {
+ if (jars[i].getEntry(Globals.OVERLAY_PATH) != null) {
+ overlays.add(jars[i].getName());
+ }
+ }
+ }
+
+ // Make our application available if no problems were encountered
+ if (!ok) {
+ log.error(sm.getString("contextConfig.unavailable"));
+ context.setConfigured(false);
+ }
+
+ }
+
/**
* Process a "stop" event for this Context.
*/
15 years, 7 months
JBossWeb SVN: r1055 - trunk/java/org/apache/catalina/startup.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-14 22:45:56 -0400 (Thu, 14 May 2009)
New Revision: 1055
Modified:
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Fix the algorithm to also consider JARs that have no fragment in the order.
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-14 16:11:03 UTC (rev 1054)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-15 02:45:56 UTC (rev 1055)
@@ -998,64 +998,67 @@
*/
protected void createFragmentsOrder() {
+ WebAbsoluteOrdering absoluteOrdering = context.getWebAbsoluteOrdering();
+ List<WebOrdering> orderings = new ArrayList<WebOrdering>();
+ HashSet<String> jarsSet = new HashSet<String>();
+ boolean fragmentFound = false;
+
+ // Parse the ordering defined in web fragments
JarRepository jarRepository = context.getJarRepository();
JarFile[] jars = jarRepository.findJars();
for (int i = 0; i < jars.length; i++) {
// Find webapp descriptor fragments
- if (jars[i].getEntry(Globals.WEB_FRAGMENT_PATH) != null) {
- webFragments.add(jars[i].getName());
- }
- }
-
- // Read order from web.xml and fragments (note: if no fragments, skip)
- WebAbsoluteOrdering absoluteOrdering = context.getWebAbsoluteOrdering();
- List<WebOrdering> orderings = new ArrayList<WebOrdering>();
- Iterator<String> jarsWithWebFragments = webFragments.iterator();
- HashSet<String> jarsSet = new HashSet<String>();
-
- // Parse the ordering defined in web fragments
- while (jarsWithWebFragments.hasNext()) {
- String jar = jarsWithWebFragments.next();
- jarsSet.add(jar);
- JarFile jarFile = null;
+ jarsSet.add(jars[i].getName());
+ JarFile jarFile = jars[i];
InputStream is = null;
- try {
- jarFile = jarRepository.findJar(jar);
- ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
- if (entry != null) {
+ ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
+ if (entry != null) {
+ fragmentFound = true;
+ try {
+ webFragments.add(jars[i].getName());
is = jarFile.getInputStream(entry);
- InputSource input = new InputSource((new File(jar)).toURI().toURL().toExternalForm());
+ InputSource input = new InputSource((new File(jars[i].getName())).toURI().toURL().toExternalForm());
input.setByteStream(is);
synchronized (fragmentOrderingDigester) {
try {
fragmentOrderingDigester.parse(input);
WebOrdering ordering = (WebOrdering) fragmentOrderingDigester.peek();
if (ordering != null) {
- ordering.setJar(jar);
+ ordering.setJar(jars[i].getName());
orderings.add(ordering);
}
} finally {
fragmentOrderingDigester.reset();
}
}
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.fragmentOrderingParse", jar), e);
- ok = false;
- } finally {
- try {
- if (is != null) {
- is.close();
+ } catch (Exception e) {
+ log.error(sm.getString("contextConfig.fragmentOrderingParse", jars[i].getName()), e);
+ ok = false;
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ // Ignore
}
- } catch (IOException e) {
- // Ignore
}
+ } else {
+ // If there is no fragment, still consider it for ordering as a
+ // fragment specifying no name and no order
+ WebOrdering ordering = new WebOrdering();
+ ordering.setJar(jars[i].getName());
+ orderings.add(ordering);
}
}
-
+ if (!fragmentFound) {
+ // Drop the order as there is no fragment in the webapp
+ orderings.clear();
+ }
+
// Generate web fragments parsing order
if (absoluteOrdering != null) {
- // Absolute ordering from web.xml, any fragment ordering is ignored
+ // Absolute ordering from web.xml, any relative fragment ordering is ignored
List<String> fragmentNames = absoluteOrdering.getOrder();
int otherPos = -1;
for (int i = 0; i < fragmentNames.size(); i++) {
@@ -1141,9 +1144,9 @@
// Parse web fragment according to order
// FIXME: Merging rules
InputStream is = null;
- try {
- ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
- if (entry != null) {
+ ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
+ if (entry != null) {
+ try {
is = jarFile.getInputStream(entry);
InputSource input = new InputSource((new File(jar)).toURI().toURL().toExternalForm());
input.setByteStream(is);
@@ -1161,17 +1164,17 @@
parseException = null;
}
}
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.applicationParse", jar), e);
- ok = false;
- } finally {
- try {
- if (is != null) {
- is.close();
+ } catch (Exception e) {
+ log.error(sm.getString("contextConfig.applicationParse", jar), e);
+ ok = false;
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ // Ignore
}
- } catch (IOException e) {
- // Ignore
}
}
15 years, 7 months
JBossWeb SVN: r1054 - in trunk: java/org/apache/catalina/startup and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-14 12:11:03 -0400 (Thu, 14 May 2009)
New Revision: 1054
Modified:
trunk/ROADMAP.txt
trunk/java/org/apache/catalina/startup/OrderingResolver.java
Log:
- Test commit.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-05-14 14:46:16 UTC (rev 1053)
+++ trunk/ROADMAP.txt 2009-05-14 16:11:03 UTC (rev 1054)
@@ -2,7 +2,7 @@
Standalone:
- Resources overlay implementation
-- Jasper plugin for TLD metadata
+- Jasper plugins for TLD metadata and web.xml metadata
- Access control annotations
- Update digester XML parsing rules for web.xml updates (session tracking-mode, cookie-config, servlet enabled,
servlets and filters async-supported, http-method-omission)
Modified: trunk/java/org/apache/catalina/startup/OrderingResolver.java
===================================================================
--- trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-14 14:46:16 UTC (rev 1053)
+++ trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-14 16:11:03 UTC (rev 1054)
@@ -330,12 +330,12 @@
ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
resolveOrder(webOrderings, order);
- main1(args);
- main2(args);
- main3(args);
+ test1();
+ test2();
+ test3();
}
- public static void main1(String args[]) {
+ public static void test1() {
ArrayList<String> order = new ArrayList<String>();
ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
@@ -389,7 +389,7 @@
}
- public static void main2(String args[]) {
+ public static void test2() {
ArrayList<String> order = new ArrayList<String>();
ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
@@ -441,7 +441,7 @@
}
- public static void main3(String args[]) {
+ public static void test3() {
ArrayList<String> order = new ArrayList<String>();
ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
15 years, 7 months
JBossWeb SVN: r1052 - in trunk: java/org/apache/catalina/startup and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-13 21:33:54 -0400 (Wed, 13 May 2009)
New Revision: 1052
Modified:
trunk/ROADMAP.txt
trunk/java/org/apache/catalina/startup/OrderingResolver.java
Log:
- Some basic fixes to make the algorithm work (indexes, use of the wrong iterator, etc).
- Fix validate to actually validate the order.
- Add the main "tests" from the spec. The nice thing is that it avoids very problematic scenarios, so it works :)
- The test cases should be extracted and put in the test folder, eventually.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-05-13 23:10:37 UTC (rev 1051)
+++ trunk/ROADMAP.txt 2009-05-14 01:33:54 UTC (rev 1052)
@@ -1,7 +1,6 @@
Roadmap for JBoss Web 3.0
Standalone:
-- Web fragments ordering
- Resources overlay implementation
- Jasper plugin for TLD metadata
- Access control annotations
Modified: trunk/java/org/apache/catalina/startup/OrderingResolver.java
===================================================================
--- trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-13 23:10:37 UTC (rev 1051)
+++ trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-14 01:33:54 UTC (rev 1052)
@@ -56,19 +56,27 @@
protected boolean afterOthers = false;
protected boolean beforeOthers = false;
- public boolean validate() {
- try {
- isBefore(new Ordering());
- isAfter(new Ordering());
- } catch (IllegalStateException e) {
- return false;
- }
- return true;
+ public boolean addAfter(Ordering ordering) {
+ return after.add(ordering);
}
+ public boolean addBefore(Ordering ordering) {
+ return before.add(ordering);
+ }
+
+ public void validate() {
+ isBefore(new Ordering());
+ isAfter(new Ordering());
+ }
+
+ /**
+ * Check (recursively) if a fragment is before the specified fragment.
+ *
+ * @param ordering
+ * @return
+ */
public boolean isBefore(Ordering ordering) {
- Set<Ordering> checked = new HashSet<Ordering>();
- return isBeforeInternal(ordering, checked);
+ return isBeforeInternal(ordering, new HashSet<Ordering>());
}
protected boolean isBeforeInternal(Ordering ordering, Set<Ordering> checked) {
@@ -80,7 +88,7 @@
while (beforeIterator.hasNext()) {
Ordering check = beforeIterator.next();
if (checked.contains(check)) {
- throw new IllegalStateException();
+ throw new IllegalStateException(sm.getString("ordering.orderConflict", this.ordering.getJar()));
}
if (check.isBeforeInternal(ordering, checked)) {
return false;
@@ -96,8 +104,7 @@
* @return
*/
public boolean isAfter(Ordering ordering) {
- Set<Ordering> checked = new HashSet<Ordering>();
- return isAfterInternal(ordering, checked);
+ return isAfterInternal(ordering, new HashSet<Ordering>());
}
protected boolean isAfterInternal(Ordering ordering, Set<Ordering> checked) {
@@ -109,7 +116,7 @@
while (afterIterator.hasNext()) {
Ordering check = afterIterator.next();
if (checked.contains(check)) {
- throw new IllegalStateException();
+ throw new IllegalStateException(sm.getString("ordering.orderConflict", this.ordering.getJar()));
}
if (check.isAfterInternal(ordering, checked)) {
return false;
@@ -138,7 +145,7 @@
}
return false;
}
-
+
/**
* Check is a fragment marked as after others is before a fragment that is not.
*
@@ -198,14 +205,14 @@
Iterator<Ordering> workIterator2 = work.iterator();
boolean found = false;
while (workIterator2.hasNext()) {
- Ordering ordering2 = workIterator.next();
+ Ordering ordering2 = workIterator2.next();
if (name.equals(ordering2.ordering.getName())) {
if (found) {
// Duplicate name
throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar()));
}
- ordering.after.add(ordering2);
- ordering2.before.add(ordering);
+ ordering.addAfter(ordering2);
+ ordering2.addBefore(ordering);
found = true;
}
}
@@ -214,20 +221,20 @@
throw new IllegalStateException(sm.getString("ordering.unkonwnName", webOrdering.getJar()));
}
}
- Iterator<String> before = webOrdering.getAfter().iterator();
+ Iterator<String> before = webOrdering.getBefore().iterator();
while (before.hasNext()) {
String name = before.next();
Iterator<Ordering> workIterator2 = work.iterator();
boolean found = false;
while (workIterator2.hasNext()) {
- Ordering ordering2 = workIterator.next();
+ Ordering ordering2 = workIterator2.next();
if (name.equals(ordering2.ordering.getName())) {
if (found) {
// Duplicate name
throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar()));
}
- ordering.before.add(ordering2);
- ordering2.after.add(ordering);
+ ordering.addBefore(ordering2);
+ ordering2.addAfter(ordering);
found = true;
}
}
@@ -271,9 +278,9 @@
tempOrder.add(pos + 1, ordering);
} else if (ordering.afterOthers) {
// Insert at the last possible element
- int insertBefore = tempOrder.size() - 1;
+ int insertBefore = tempOrder.size();
boolean first = ordering.isFirstAfterOthers();
- int firstAfterOthers = tempOrder.size() - 1;
+ int firstAfterOthers = tempOrder.size();
for (int i = tempOrder.size() - 1; i >= 0; i--) {
if (ordering.isBefore(tempOrder.get(i))) {
insertBefore = i;
@@ -290,7 +297,7 @@
} else {
// Insert according to other already inserted elements
int insertAfter = -1;
- int insertBefore = tempOrder.size() - 1;
+ int insertBefore = tempOrder.size();
for (int i = 0; i < tempOrder.size(); i++) {
if (ordering.isAfter(tempOrder.get(i)) || tempOrder.get(i).beforeOthers) {
insertAfter = i;
@@ -318,4 +325,160 @@
}
+ public static void main(String args[]) {
+ ArrayList<String> order = new ArrayList<String>();
+ ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
+ resolveOrder(webOrderings, order);
+
+ main1(args);
+ main2(args);
+ main3(args);
+ }
+
+ public static void main1(String args[]) {
+
+ ArrayList<String> order = new ArrayList<String>();
+ ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
+
+ WebOrdering A = new WebOrdering();
+ A.setName("A");
+ A.setJar("A.jar");
+ A.setAfterOthers(true);
+ A.addAfter("C");
+ webOrderings.add(A);
+
+ WebOrdering B = new WebOrdering();
+ B.setName("B");
+ B.setJar("B.jar");
+ B.setBeforeOthers(true);
+ webOrderings.add(B);
+
+ WebOrdering C = new WebOrdering();
+ C.setName("C");
+ C.setJar("C.jar");
+ C.setAfterOthers(true);
+ webOrderings.add(C);
+
+ WebOrdering D = new WebOrdering();
+ D.setName("D");
+ D.setJar("D.jar");
+ webOrderings.add(D);
+
+ WebOrdering E = new WebOrdering();
+ E.setName("E");
+ E.setJar("E.jar");
+ webOrderings.add(E);
+
+ WebOrdering F = new WebOrdering();
+ F.setName("F");
+ F.setJar("F.jar");
+ F.setBeforeOthers(true);
+ F.addBefore("B");
+ webOrderings.add(F);
+
+ long n1 = System.nanoTime();
+ resolveOrder(webOrderings, order);
+ long n2 = System.nanoTime();
+
+ System.out.print("Result: ");
+ Iterator<String> orderIterator = order.iterator();
+ while (orderIterator.hasNext()) {
+ System.out.print(orderIterator.next() + " ");
+ }
+ System.out.println("ns: " + (n2 - n1));
+
+ }
+
+ public static void main2(String args[]) {
+
+ ArrayList<String> order = new ArrayList<String>();
+ ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
+
+ WebOrdering A = new WebOrdering();
+ A.setJar("noid.jar");
+ A.setAfterOthers(true);
+ A.addBefore("C");
+ webOrderings.add(A);
+
+ WebOrdering B = new WebOrdering();
+ B.setName("B");
+ B.setJar("B.jar");
+ B.setBeforeOthers(true);
+ webOrderings.add(B);
+
+ WebOrdering C = new WebOrdering();
+ C.setName("C");
+ C.setJar("C.jar");
+ webOrderings.add(C);
+
+ WebOrdering D = new WebOrdering();
+ D.setName("D");
+ D.setJar("D.jar");
+ D.setAfterOthers(true);
+ webOrderings.add(D);
+
+ WebOrdering E = new WebOrdering();
+ E.setName("E");
+ E.setJar("E.jar");
+ E.setBeforeOthers(true);
+ webOrderings.add(E);
+
+ WebOrdering F = new WebOrdering();
+ F.setName("F");
+ F.setJar("F.jar");
+ webOrderings.add(F);
+
+ long n1 = System.nanoTime();
+ resolveOrder(webOrderings, order);
+ long n2 = System.nanoTime();
+
+ System.out.print("Result: ");
+ Iterator<String> orderIterator = order.iterator();
+ while (orderIterator.hasNext()) {
+ System.out.print(orderIterator.next() + " ");
+ }
+ System.out.println("ns: " + (n2 - n1));
+
+ }
+
+ public static void main3(String args[]) {
+
+ ArrayList<String> order = new ArrayList<String>();
+ ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
+
+ WebOrdering A = new WebOrdering();
+ A.setName("A");
+ A.setJar("A.jar");
+ A.addAfter("B");
+ webOrderings.add(A);
+
+ WebOrdering B = new WebOrdering();
+ B.setName("B");
+ B.setJar("B.jar");
+ webOrderings.add(B);
+
+ WebOrdering C = new WebOrdering();
+ C.setName("C");
+ C.setJar("C.jar");
+ C.setBeforeOthers(true);
+ webOrderings.add(C);
+
+ WebOrdering D = new WebOrdering();
+ D.setName("D");
+ D.setJar("D.jar");
+ webOrderings.add(D);
+
+ long n1 = System.nanoTime();
+ resolveOrder(webOrderings, order);
+ long n2 = System.nanoTime();
+
+ System.out.print("Result: ");
+ Iterator<String> orderIterator = order.iterator();
+ while (orderIterator.hasNext()) {
+ System.out.print(orderIterator.next() + " ");
+ }
+ System.out.println("ns: " + (n2 - n1));
+
+ }
+
}
15 years, 7 months