tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1387216 - in /tomcat/sandbox/trunk-resources: ./ java/org/apache/catalina/ java/org/apache/catalina/startup/ java/org/apache/catalina/webresources/ test/javax/el/ test/org/apache/catalina/core/ test/org/apache/catalina/loader/ test/org/apa...
Date Tue, 18 Sep 2012 15:34:25 GMT
Author: markt
Date: Tue Sep 18 15:34:25 2012
New Revision: 1387216

URL: http://svn.apache.org/viewvc?rev=1387216&view=rev
Log:
A little refactoring with extensions in mind. Not every WebResourceSet will be file base

Modified:
    tomcat/sandbox/trunk-resources/   (props changed)
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
    tomcat/sandbox/trunk-resources/test/javax/el/TestCompositeELResolver.java
    tomcat/sandbox/trunk-resources/test/org/apache/catalina/core/TestStandardContextAliases.java
    tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
    tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualWebappLoader.java
    tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
    tomcat/sandbox/trunk-resources/test/org/apache/jasper/compiler/TestGenerator.java

Propchange: tomcat/sandbox/trunk-resources/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1385351-1386494

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java Tue Sep 18
15:34:25 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina;
 
-import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Set;
@@ -207,13 +206,13 @@ public interface WebResourceRoot extends
      * based on the provided parameters.
      *
      * @param type          The type of {@link WebResourceSet} to create
-     * @param file          The resource (must be a JAR, file or directory)
+     * @param base          The location of the resources
      * @param webAppMount   The path within the web application that the
      *                          resources should be published at
      * @param internalPath  The path within the resource where the content is to
      *                          be found.
      */
-    void createWebResourceSet(ResourceSetType type, File file,
+    void createWebResourceSet(ResourceSetType type, String base,
             String webAppMount, String internalPath);
 
     /**

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/ContextConfig.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/ContextConfig.java Tue
Sep 18 15:34:25 2012
@@ -1570,7 +1570,7 @@ public class ContextConfig implements Li
                     if (resources.isDirectory()) {
                         context.getResources().createWebResourceSet(
                                 WebResourceRoot.ResourceSetType.RESOURCE_JAR,
-                                file, "", "");
+                                file.getAbsolutePath(), "", "");
                     }
                 }
             } catch (IOException ioe) {

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java
Tue Sep 18 15:34:25 2012
@@ -85,9 +85,10 @@ public class DirResourceSet extends Abst
             WebResource unpackedResourceJar =
                     getResource("/WEB-INF/classes/META-INF/resources");
             if (unpackedResourceJar.exists()) {
+                File f = ((FileResource)
+                        unpackedResourceJar).getResourceInternal();
                 root.createWebResourceSet(ResourceSetType.RESOURCE_JAR,
-                        ((FileResource) unpackedResourceJar).getResourceInternal() ,
-                        "", "");
+                         f.getAbsolutePath(), "", "");
             }
         }
     }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
Tue Sep 18 15:34:25 2012
@@ -37,9 +37,16 @@ import org.apache.catalina.util.Lifecycl
 import org.apache.tomcat.util.res.StringManager;
 
 /**
+ * <p>
  * Provides the resources implementation for a web application. The
  * {@link org.apache.catalina.Lifecycle} of this class should be aligned with
  * that of the associated {@link Context}.
+ * </p><p>
+ * This implementation assumes that the base attribute supplied to {@link
+ * StandardRoot#createWebResourceSet(
+ * org.apache.catalina.WebResourceRoot.ResourceSetType, String, String, String)
+ * represents the absolute path to a file.
+ * </p>
  */
 public class StandardRoot extends LifecycleMBeanBase
         implements WebResourceRoot {
@@ -196,11 +203,11 @@ public class StandardRoot extends Lifecy
     @Override
     public void createWebResourceSet(ResourceSetType type, URL url,
             String webAppPath, String internalPath) {
-        createWebResourceSet(type, toFile(url), webAppPath, internalPath);
+        createWebResourceSet(type, toBase(url), webAppPath, internalPath);
     }
 
     @Override
-    public void createWebResourceSet(ResourceSetType type, File file,
+    public void createWebResourceSet(ResourceSetType type, String base,
             String webAppPath, String internalPath) {
 
         ArrayList<WebResourceSet> resourceList;
@@ -221,6 +228,10 @@ public class StandardRoot extends Lifecy
                         sm.getString("standardRoot.createUnknownType", type));
         }
 
+        // This implementation assumes that the base for all resources will be a
+        // file.
+        File file = new File(base);
+
         if (file.isFile()) {
             if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
                 resourceSet = new JarResourceSet(this, file, webAppPath,
@@ -267,7 +278,7 @@ public class StandardRoot extends Lifecy
         }
     }
 
-    private File toFile(URL url) {
+    protected String toBase(URL url) {
         File f = null;
 
         if ("jar".equals(url.getProtocol())) {
@@ -285,7 +296,7 @@ public class StandardRoot extends Lifecy
                 throw new IllegalArgumentException(e);
             }
         }
-        return f;
+        return f.getAbsolutePath();
     }
 
     // ----------------------------------------------------------- JMX Lifecycle

Modified: tomcat/sandbox/trunk-resources/test/javax/el/TestCompositeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/javax/el/TestCompositeELResolver.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/javax/el/TestCompositeELResolver.java (original)
+++ tomcat/sandbox/trunk-resources/test/javax/el/TestCompositeELResolver.java Tue Sep 18 15:34:25
2012
@@ -46,7 +46,8 @@ public class TestCompositeELResolver ext
         File lib = new File("webapps/examples/WEB-INF/lib");
         ctxt.setResources(new StandardRoot(ctxt));
         ctxt.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, lib, "/WEB-INF/lib", "");
+                WebResourceRoot.ResourceSetType.POST, lib.getAbsolutePath(),
+                "/WEB-INF/lib", "");
 
         tomcat.start();
 

Modified: tomcat/sandbox/trunk-resources/test/org/apache/catalina/core/TestStandardContextAliases.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/core/TestStandardContextAliases.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/catalina/core/TestStandardContextAliases.java
(original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/core/TestStandardContextAliases.java
Tue Sep 18 15:34:25 2012
@@ -51,7 +51,8 @@ public class TestStandardContextAliases 
         File lib = new File("webapps/examples/WEB-INF/lib");
         ctx.setResources(new StandardRoot(ctx));
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, lib, "/WEB-INF/lib", "");
+                WebResourceRoot.ResourceSetType.POST, lib.getAbsolutePath(),
+                "/WEB-INF/lib", "");
 
 
         Tomcat.addServlet(ctx, "test", new TestServlet());

Modified: tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
(original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
Tue Sep 18 15:34:25 2012
@@ -77,17 +77,23 @@ public class TestVirtualContext extends 
         File f5 = new File("test/webapp-3.0-virtual-webapp/src/main/misc");
         File f6 = new File("test/webapp-3.0-virtual-webapp/src/main/webapp2");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f1.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f2, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f2.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f3, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f3.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f4, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f4.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f5, "/other", "");
+                WebResourceRoot.ResourceSetType.POST, f5.getAbsolutePath(),
+                "/other", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f6, "", "");
+                WebResourceRoot.ResourceSetType.POST, f6.getAbsolutePath(),
+                "", "");
 
         StandardJarScanner jarScanner = new StandardJarScanner();
         jarScanner.setScanAllDirectories(true);
@@ -274,9 +280,11 @@ public class TestVirtualContext extends 
         File f1 = new File("test/webapp-3.0-virtual-webapp/target/classes");
         File f2 = new File("test/webapp-3.0-virtual-library/target/classes");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f1.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f2, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f2.getAbsolutePath(),
+                "/WEB-INF/classes", "");
 
         tomcat.start();
         // first test that without the setting on StandardContext the annotated
@@ -289,11 +297,14 @@ public class TestVirtualContext extends 
         // path, the servlet is detected
         ctx.setResources(new StandardRoot(ctx));
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f1.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f2, "/WEB-INF/classes", "");
+                WebResourceRoot.ResourceSetType.POST, f2.getAbsolutePath(),
+                "/WEB-INF/classes", "");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, additionWebInfClasses,
+                WebResourceRoot.ResourceSetType.POST,
+                additionWebInfClasses.getAbsolutePath(),
                 "/WEB-INF/classes", "");
 
         tomcat.start();

Modified: tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualWebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualWebappLoader.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualWebappLoader.java
(original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualWebappLoader.java
Tue Sep 18 15:34:25 2012
@@ -58,7 +58,8 @@ public class TestVirtualWebappLoader ext
 
         File f1 = new File("test/webapp-3.0-fragments/WEB-INF/lib");
         ctx.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/lib", "");
+                WebResourceRoot.ResourceSetType.POST, f1.getAbsolutePath(),
+                "/WEB-INF/lib", "");
 
         loader.start();
         String[] repos = loader.getLoaderRepositories();

Modified: tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
(original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
Tue Sep 18 15:34:25 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina.webresources;
 
-import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Set;
@@ -124,7 +123,7 @@ public class TesterWebResourceRoot imple
     }
 
     @Override
-    public void createWebResourceSet(ResourceSetType type, File file,
+    public void createWebResourceSet(ResourceSetType type, String base,
             String webAppMount, String internalPath) {
         // NO-OP
     }

Modified: tomcat/sandbox/trunk-resources/test/org/apache/jasper/compiler/TestGenerator.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/jasper/compiler/TestGenerator.java?rev=1387216&r1=1387215&r2=1387216&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/jasper/compiler/TestGenerator.java (original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/jasper/compiler/TestGenerator.java Tue
Sep 18 15:34:25 2012
@@ -121,7 +121,8 @@ public class TestGenerator extends Tomca
         File lib = new File("webapps/examples/WEB-INF/lib");
         ctxt.setResources(new StandardRoot(ctxt));
         ctxt.getResources().createWebResourceSet(
-                WebResourceRoot.ResourceSetType.POST, lib, "/WEB-INF/lib", "");
+                WebResourceRoot.ResourceSetType.POST, lib.getAbsolutePath(),
+                "/WEB-INF/lib", "");
 
         tomcat.start();
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message