On 08/12/2014 09:04, violet...@apache.org wrote:
> Author: violetagg
> Date: Mon Dec  8 09:04:56 2014
> New Revision: 1643766
> 
> URL: http://svn.apache.org/r1643766
> Log:
> Extract several "protected" methods in order to make StandardRoot easier for 
> extending.
> 
> Modified:
>     tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
> 
> 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=1643766&r1=1643765&r2=1643766&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java 
> (original)
> +++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Mon 
> Dec  8 09:04:56 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;

What is the use case for this one? classResources was intended to be
internal to StandardRoot.

> @@ -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();
> +    }
> +

I can see the use case for these two. +1.


>      @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;
> +    }
> +

I'm curious about the use case for this too.

Mark


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

Reply via email to