Author: markt
Date: Tue Jan 8 13:52:45 2013
New Revision: 1430285
URL: http://svn.apache.org/viewvc?rev=1430285&view=rev
Log:
Improve consistency within new resources implementation.
s/webAppPath/webAppMount/
Place same requirements on webAppMount as for path (although internal
representation is different).
Add necessary plumbing to do the same for internalPath
Modified:
tomcat/trunk/java/org/apache/catalina/WebResourceRoot.java
tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/trunk/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
tomcat/trunk/java/org/apache/catalina/webresources/AbstractResourceSet.java
tomcat/trunk/java/org/apache/catalina/webresources/DirResourceSet.java
tomcat/trunk/java/org/apache/catalina/webresources/JarResourceSet.java
tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSet.java
tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSetInternal.java
tomcat/trunk/test/org/apache/catalina/webresources/TestFileResourceSet.java
tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSet.java
tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSetInternal.java
tomcat/trunk/webapps/docs/config/resources.xml
Modified: tomcat/trunk/java/org/apache/catalina/WebResourceRoot.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/WebResourceRoot.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/WebResourceRoot.java (original)
+++ tomcat/trunk/java/org/apache/catalina/WebResourceRoot.java Tue Jan 8
13:52:45 2013
@@ -181,12 +181,13 @@ public interface WebResourceRoot extends
* @param type The type of {@link WebResourceSet} to create
* @param url The URL of the resource (must locate a JAR, file or
* directory)
- * @param webAppPath The path within the web application that the
- * resources should be published at
+ * @param webAppMount The path within the web application that the
+ * resources should be published at. It must start
+ * with '/'.
* @param internalPath The path within the resource where the content is
to
* be found.
*/
- void createWebResourceSet(ResourceSetType type, URL url, String webAppPath,
+ void createWebResourceSet(ResourceSetType type, URL url, String
webAppMount,
String internalPath);
/**
@@ -196,7 +197,8 @@ public interface WebResourceRoot extends
* @param type The type of {@link WebResourceSet} to create
* @param base The location of the resources
* @param webAppMount The path within the web application that the
- * resources should be published at
+ * resources should be published at. It must start
+ * with '/'.
* @param internalPath The path within the resource where the content is
to
* be found.
*/
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Tue Jan 8
13:52:45 2013
@@ -4786,7 +4786,7 @@ public class StandardContext extends Con
if (webinfClassesResource.isDirectory()) {
getResources().createWebResourceSet(
WebResourceRoot.ResourceSetType.RESOURCE_JAR,
- webinfClassesResource.getURL(), "", "");
+ webinfClassesResource.getURL(), "/", "");
}
}
Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Tue Jan 8
13:52:45 2013
@@ -1560,7 +1560,7 @@ public class ContextConfig implements Li
if (entryName.startsWith("META-INF/resources/")) {
context.getResources().createWebResourceSet(
WebResourceRoot.ResourceSetType.RESOURCE_JAR,
- url, "", "META-INF/resources");
+ url, "/", "META-INF/resources");
break;
}
jar.nextEntry();
@@ -1572,7 +1572,7 @@ public class ContextConfig implements Li
if (resources.isDirectory()) {
context.getResources().createWebResourceSet(
WebResourceRoot.ResourceSetType.RESOURCE_JAR,
- file.getAbsolutePath(), "", "");
+ file.getAbsolutePath(), "/", "");
}
}
} catch (IOException ioe) {
Modified:
tomcat/trunk/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/AbstractFileResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
(original)
+++
tomcat/trunk/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
Tue Jan 8 13:52:45 2013
@@ -32,7 +32,7 @@ public abstract class AbstractFileResour
protected String canonicalBase;
protected AbstractFileResourceSet(String internalPath) {
- this.internalPath = internalPath;
+ this.internalPath = checkInternalPath(internalPath);
}
protected File file(String name, boolean mustExist) {
Modified:
tomcat/trunk/java/org/apache/catalina/webresources/AbstractResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/AbstractResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/AbstractResourceSet.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/AbstractResourceSet.java
Tue Jan 8 13:52:45 2013
@@ -40,6 +40,11 @@ public abstract class AbstractResourceSe
}
}
+ protected final String checkInternalPath(String internalPath) {
+ //checkPath(internalPath);
+ return internalPath;
+ }
+
@Override
public final void setRoot(WebResourceRoot root) {
this.root = root;
@@ -50,7 +55,13 @@ public abstract class AbstractResourceSe
}
public final void setWebAppMount(String webAppMount) {
- this.webAppMount = webAppMount;
+ checkPath(webAppMount);
+ // Optimise internal processing
+ if (webAppMount.equals("/")) {
+ this.webAppMount = "";
+ } else {
+ this.webAppMount = webAppMount;
+ }
}
public final String getWebAppMount() {
Modified: tomcat/trunk/java/org/apache/catalina/webresources/DirResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/DirResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/DirResourceSet.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/DirResourceSet.java Tue
Jan 8 13:52:45 2013
@@ -54,7 +54,7 @@ public class DirResourceSet extends Abst
* {@link org.apache.catalina.WebResourceSet} will
* be mounted. For example, to add a directory of
* JARs to a web application, the directory would
- * be mounted at "WEB-INF/lib/"
+ * be mounted at "/WEB-INF/lib/"
* @param internalPath The path within this new {@link
* org.apache.catalina.WebResourceSet} where
* resources will be served from.
@@ -72,7 +72,7 @@ public class DirResourceSet extends Abst
if (f.isDirectory()) {
root.createWebResourceSet(ResourceSetType.RESOURCE_JAR,
- f.getAbsolutePath(), "", "");
+ f.getAbsolutePath(), "/", "");
}
}
Modified: tomcat/trunk/java/org/apache/catalina/webresources/JarResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/JarResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/JarResourceSet.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/JarResourceSet.java Tue
Jan 8 13:52:45 2013
@@ -62,7 +62,7 @@ public class JarResourceSet extends Abst
setRoot(root);
setBase(base);
setWebAppMount(webAppMount);
- this.internalPath = internalPath;
+ this.internalPath = checkInternalPath(internalPath);
if (getRoot().getState().isAvailable()) {
try {
Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Tue
Jan 8 13:52:45 2013
@@ -223,13 +223,13 @@ public class StandardRoot extends Lifecy
@Override
public void createWebResourceSet(ResourceSetType type, URL url,
- String webAppPath, String internalPath) {
- createWebResourceSet(type, toBase(url), webAppPath, internalPath);
+ String webAppMount, String internalPath) {
+ createWebResourceSet(type, toBase(url), webAppMount, internalPath);
}
@Override
public void createWebResourceSet(ResourceSetType type, String base,
- String webAppPath, String internalPath) {
+ String webAppMount, String internalPath) {
ArrayList<WebResourceSet> resourceList;
WebResourceSet resourceSet;
@@ -255,15 +255,15 @@ public class StandardRoot extends Lifecy
if (file.isFile()) {
if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
- resourceSet = new JarResourceSet(this, base, webAppPath,
+ resourceSet = new JarResourceSet(this, base, webAppMount,
internalPath);
} else {
- resourceSet = new FileResourceSet(this, base, webAppPath,
+ resourceSet = new FileResourceSet(this, base, webAppMount,
internalPath);
}
} else if (file.isDirectory()) {
resourceSet =
- new DirResourceSet(this, base, webAppPath, internalPath);
+ new DirResourceSet(this, base, webAppMount, internalPath);
} else {
throw new IllegalArgumentException(
sm.getString("standardRoot.createInvalidFile", file));
Modified:
tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSet.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSet.java
Tue Jan 8 13:52:45 2013
@@ -29,7 +29,7 @@ public class TestDirResourceSet extends
TesterWebResourceRoot root = new TesterWebResourceRoot();
WebResourceSet webResourceSet =
new DirResourceSet(new TesterWebResourceRoot(),
- f.getAbsolutePath(), "", "");
+ f.getAbsolutePath(), "/", "");
root.setWebResourceSet(webResourceSet);
return root;
}
Modified:
tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSetInternal.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSetInternal.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
---
tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSetInternal.java
(original)
+++
tomcat/trunk/test/org/apache/catalina/webresources/TestDirResourceSetInternal.java
Tue Jan 8 13:52:45 2013
@@ -29,7 +29,7 @@ public class TestDirResourceSetInternal
TesterWebResourceRoot root = new TesterWebResourceRoot();
WebResourceSet webResourceSet =
new DirResourceSet(new TesterWebResourceRoot(),
- f.getAbsolutePath(), "", "webresources/dir1");
+ f.getAbsolutePath(), "/", "webresources/dir1");
root.setWebResourceSet(webResourceSet);
return root;
}
Modified:
tomcat/trunk/test/org/apache/catalina/webresources/TestFileResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/webresources/TestFileResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/webresources/TestFileResourceSet.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/webresources/TestFileResourceSet.java
Tue Jan 8 13:52:45 2013
@@ -29,7 +29,7 @@ public class TestFileResourceSet extends
TesterWebResourceRoot root = new TesterWebResourceRoot();
WebResourceSet webResourceSet =
new DirResourceSet(new TesterWebResourceRoot(),
- f.getAbsolutePath(), "", "");
+ f.getAbsolutePath(), "/", "");
root.setWebResourceSet(webResourceSet);
WebResourceSet f1 = new FileResourceSet(root,
Modified:
tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSet.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSet.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSet.java
Tue Jan 8 13:52:45 2013
@@ -28,7 +28,7 @@ public class TestJarResourceSet extends
File f = new File("test/webresources/dir1.jar");
TesterWebResourceRoot root = new TesterWebResourceRoot();
WebResourceSet webResourceSet =
- new JarResourceSet(root, f.getAbsolutePath(), "", "");
+ new JarResourceSet(root, f.getAbsolutePath(), "/", "");
root.setWebResourceSet(webResourceSet);
return root;
}
Modified:
tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSetInternal.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSetInternal.java?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
---
tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSetInternal.java
(original)
+++
tomcat/trunk/test/org/apache/catalina/webresources/TestJarResourceSetInternal.java
Tue Jan 8 13:52:45 2013
@@ -28,7 +28,7 @@ public class TestJarResourceSetInternal
File f = new File("test/webresources/dir1-internal.jar");
TesterWebResourceRoot root = new TesterWebResourceRoot();
WebResourceSet webResourceSet =
- new JarResourceSet(root, f.getAbsolutePath(), "", "/dir1");
+ new JarResourceSet(root, f.getAbsolutePath(), "/", "/dir1");
root.setWebResourceSet(webResourceSet);
return root;
}
Modified: tomcat/trunk/webapps/docs/config/resources.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/resources.xml?rev=1430285&r1=1430284&r2=1430285&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/resources.xml (original)
+++ tomcat/trunk/webapps/docs/config/resources.xml Tue Jan 8 13:52:45 2013
@@ -138,10 +138,11 @@
<attribute name="webAppMount" required="false">
<p>Identifies the path within the web application that these resources
- will be made available. This attribute is required by the
+ will be made available. For the
<code>org.apache.catalina.WebResourceSet</code> implementations provided
- by Tomcat. Custom implementations may not require it. If not specified,
- the default value of the empty string will be used.</p>
+ by Tomcat, this attribute is required and must start with '/'. Custom
+ implementations may not require it. If not specified, the default value
of
+ "/" will be used.</p>
</attribute>
</attributes>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]