Author: violetagg Date: Mon Dec 8 09:28:22 2014 New Revision: 1643768 URL: http://svn.apache.org/r1643768 Log: Merged revision 1643766 from tomcat/trunk: Extract several "protected" methods in order to make StandardRoot easier for extending.
Modified: tomcat/tc8.0.x/trunk/ (props changed) tomcat/tc8.0.x/trunk/java/org/apache/catalina/webresources/StandardRoot.java tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc8.0.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Dec 8 09:28:22 2014 @@ -1 +1 @@ -/tomcat/trunk:1636524,1637156,1637176,1637188,1637331,1637684,1637695,1638720-1638725,1639653,1640010,1640084,1640088,1640275,1640322,1640347,1640361,1640365,1640403,1640410,1640652,1640655-1640658,1640688,1640700-1640883,1640903,1640976,1640978,1641000,1641026,1641038-1641039,1641051-1641052,1641058,1641064,1641300,1641369,1641374,1641380,1641486,1641634,1641656-1641692,1641704,1641707-1641718,1641720-1641722,1641735,1641981,1642554,1642564,1642595,1642606,1642668,1642679,1642697,1642699,1643002,1643045,1643054-1643055,1643066,1643121,1643206,1643209-1643210,1643216,1643249,1643270,1643283,1643309-1643310,1643323,1643365-1643366,1643370-1643371,1643465,1643474,1643570,1643634,1643649,1643651,1643654,1643675,1643731,1643733-1643734,1643761 +/tomcat/trunk:1636524,1637156,1637176,1637188,1637331,1637684,1637695,1638720-1638725,1639653,1640010,1640084,1640088,1640275,1640322,1640347,1640361,1640365,1640403,1640410,1640652,1640655-1640658,1640688,1640700-1640883,1640903,1640976,1640978,1641000,1641026,1641038-1641039,1641051-1641052,1641058,1641064,1641300,1641369,1641374,1641380,1641486,1641634,1641656-1641692,1641704,1641707-1641718,1641720-1641722,1641735,1641981,1642554,1642564,1642595,1642606,1642668,1642679,1642697,1642699,1643002,1643045,1643054-1643055,1643066,1643121,1643206,1643209-1643210,1643216,1643249,1643270,1643283,1643309-1643310,1643323,1643365-1643366,1643370-1643371,1643465,1643474,1643570,1643634,1643649,1643651,1643654,1643675,1643731,1643733-1643734,1643761,1643766 Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/webresources/StandardRoot.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1643768&r1=1643767&r2=1643768&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/catalina/webresources/StandardRoot.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/webresources/StandardRoot.java Mon Dec 8 09:28:22 2014 @@ -457,6 +457,10 @@ public class StandardRoot extends Lifecy return postResources.toArray(new WebResourceSet[0]); } + protected WebResourceSet[] getClassResources() { + return classResources.toArray(new WebResourceSet[0]); + } + @Override public void setAllowLinking(boolean allowLinking) { this.allowLinking = allowLinking; @@ -633,9 +637,7 @@ public class StandardRoot extends Lifecy cacheJmxName = register(cache, getObjectNameKeyProperties() + ",name=Cache"); - // Ensure support for jar:war:file:/ URLs will be available (required - // for resource JARs in packed WAR files). - TomcatURLStreamHandlerFactory.register(); + registerURLStreamHandlerFactory(); if (context == null) { throw new IllegalStateException( @@ -649,29 +651,17 @@ public class StandardRoot extends Lifecy } } + protected void registerURLStreamHandlerFactory() { + // Ensure support for jar:war:file:/ URLs will be available (required + // for resource JARs in packed WAR files). + TomcatURLStreamHandlerFactory.register(); + } + @Override protected void startInternal() throws LifecycleException { - String docBase = context.getDocBase(); - mainResources.clear(); - if (docBase == null) { - main = new EmptyResourceSet(this); - } else { - File f = new File(docBase); - if (!f.isAbsolute()) { - f = new File(((Host)context.getParent()).getAppBaseFile(), f.getPath()); - } - if (f.isDirectory()) { - main = new DirResourceSet(this, "/", f.getAbsolutePath(), "/"); - } else if(f.isFile() && docBase.endsWith(".war")) { - main = new JarResourceSet(this, "/", f.getAbsolutePath(), "/"); - } else { - throw new IllegalArgumentException( - sm.getString("standardRoot.startInvalidMain", - f.getAbsolutePath())); - } - } + main = createMainResourceSet(); mainResources.add(main); @@ -694,6 +684,31 @@ public class StandardRoot extends Lifecy setState(LifecycleState.STARTING); } + protected WebResourceSet createMainResourceSet() { + String docBase = context.getDocBase(); + + WebResourceSet mainResourceSet; + if (docBase == null) { + mainResourceSet = new EmptyResourceSet(this); + } else { + File f = new File(docBase); + if (!f.isAbsolute()) { + f = new File(((Host)context.getParent()).getAppBaseFile(), f.getPath()); + } + if (f.isDirectory()) { + mainResourceSet = new DirResourceSet(this, "/", f.getAbsolutePath(), "/"); + } else if(f.isFile() && docBase.endsWith(".war")) { + mainResourceSet = new JarResourceSet(this, "/", f.getAbsolutePath(), "/"); + } else { + throw new IllegalArgumentException( + sm.getString("standardRoot.startInvalidMain", + f.getAbsolutePath())); + } + } + + return mainResourceSet; + } + @Override protected void stopInternal() throws LifecycleException { for (ArrayList<WebResourceSet> list : allResources) { Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1643768&r1=1643767&r2=1643768&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Mon Dec 8 09:28:22 2014 @@ -138,6 +138,10 @@ Prevent file descriptors leak and ensure that files are closed after retrieving the last modification time. (violetagg) </fix> + <update> + Make <code>o.a.catalina.webresources.StandardRoot</code> easier for + extending. (violetagg) + </update> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org