Java 类org.apache.catalina.WebResourceSet 实例源码

项目:armeria    文件:ArmeriaWebResourceRoot.java   
@Override
protected WebResourceSet createMainResourceSet() {
    final Path docBase = config.docBase();
    assert docBase.isAbsolute();

    final String docBaseStr = docBase.toString();
    getContext().setDocBase(docBaseStr);

    if (Files.isDirectory(docBase)) {
        return new DirResourceSet(this, "/", docBaseStr, "/");
    }

    final Optional<String> jarRootOpt = config.jarRoot();
    if (jarRootOpt.isPresent()) { // If docBase is a JAR file
        final String jarRoot = jarRootOpt.get();
        if ("/".equals(jarRoot)) {
            return new JarResourceSet(this, "/", docBaseStr, "/");
        } else {
            return new JarSubsetResourceSet(this, "/", docBaseStr, "/", jarRoot);
        }
    }

    throw new IllegalArgumentException(sm.getString("standardRoot.startInvalidMain", docBaseStr));
}
项目:tomee    文件:TomEEWebappClassLoader.java   
@Override
public void setResources(final WebResourceRoot resources) {
    this.resources = resources;
    if (StandardRoot.class.isInstance(resources)) {
        final List<WebResourceSet> jars = (List<WebResourceSet>) Reflections.get(resources, "jarResources");
        if (jars != null && !jars.isEmpty()) {
            final Iterator<WebResourceSet> jarIt = jars.iterator();
            while (jarIt.hasNext()) {
                final WebResourceSet set = jarIt.next();
                if (set.getBaseUrl() == null) {
                    continue;
                }
                final File file = URLs.toFile(set.getBaseUrl());
                try {
                    if (file.exists() && (!TomEEClassLoaderEnricher.validateJarFile(file) || !jarIsAccepted(file))) {
                        // need to remove this resource
                        LOGGER.warning("Removing " + file.getAbsolutePath() + " since it is offending");
                        jarIt.remove();
                    }
                } catch (final IOException e) {
                    // ignore
                }
            }
        }
    }
}
项目:joinfaces    文件:JsfTomcatApplicationListener.java   
private JarWarResourceSet getFirstJarWarResourceSetAtJarResources(WebResourceRoot resources) {
    JarWarResourceSet result = null;
    for (WebResourceSet resourceSet :resources.getJarResources()) {
        if (resourceSet instanceof JarWarResourceSet) {
            result = (JarWarResourceSet) resourceSet;
            break;
        }
    }
    return result;
}
项目:joinfaces    文件:JsfTomcatApplicationListener.java   
private URL mainFile(WebResourceRoot resources) {
    URL result = null;
    for (WebResourceSet resourceSet :resources.getJarResources()) {
        if (resourceSet instanceof JarWarResourceSet) {
            result = resourceSet.getBaseUrl();
            break;
        }
    }
    return result;
}
项目:joinfaces    文件:MockWebResourceRoot.java   
@Override
public void addJarResources(WebResourceSet webResourceSet) {
    if (this.jarResources == null) {
        this.jarResources = new ArrayList<>();
    }
    this.jarResources.add(webResourceSet);
}
项目:joinfaces    文件:MockWebResourceRoot.java   
@Override
public void addPreResources(WebResourceSet webResourceSet) {
    throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}
项目:joinfaces    文件:MockWebResourceRoot.java   
@Override
public WebResourceSet[] getPreResources() {
    throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}
项目:joinfaces    文件:MockWebResourceRoot.java   
@Override
public WebResourceSet[] getJarResources() {
    return this.jarResources.toArray(new WebResourceSet[this.jarResources.size()]);
}
项目:joinfaces    文件:MockWebResourceRoot.java   
@Override
public void addPostResources(WebResourceSet webResourceSet) {
    throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}
项目:joinfaces    文件:MockWebResourceRoot.java   
@Override
public WebResourceSet[] getPostResources() {
    throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
}
项目:joinfaces    文件:ContextMock.java   
public void init(WebResourceSet... webResourcesSet) throws LifecycleException {
    for (WebResourceSet webResourceSet : webResourcesSet) {
        this.webResourceRoot.addJarResources(webResourceSet);
    }
}
项目:RAFTools    文件:NIOResourceRoot.java   
@Override
public WebResourceSet[] getPreResources() {
    return new WebResourceSet[0];
}
项目:RAFTools    文件:NIOResourceRoot.java   
@Override
public WebResourceSet[] getJarResources() {
    return new WebResourceSet[0];
}
项目:RAFTools    文件:NIOResourceRoot.java   
@Override
public WebResourceSet[] getPostResources() {
    return new WebResourceSet[0];

}
项目:tomee    文件:LazyStopStandardRoot.java   
@Override
public void addPreResources(final WebResourceSet webResourceSet) {
    delegate.addPreResources(webResourceSet);
}
项目:tomee    文件:LazyStopStandardRoot.java   
@Override
public WebResourceSet[] getPreResources() {
    return delegate.getPreResources();
}
项目:tomee    文件:LazyStopStandardRoot.java   
@Override
public void addJarResources(final WebResourceSet webResourceSet) {
    delegate.addJarResources(webResourceSet);
}
项目:tomee    文件:LazyStopStandardRoot.java   
@Override
public WebResourceSet[] getJarResources() {
    return delegate.getJarResources();
}
项目:tomee    文件:LazyStopStandardRoot.java   
@Override
public void addPostResources(final WebResourceSet webResourceSet) {
    delegate.addPostResources(webResourceSet);
}
项目:tomee    文件:LazyStopStandardRoot.java   
@Override
public WebResourceSet[] getPostResources() {
    return delegate.getPostResources();
}
项目:tomee    文件:TomcatWebAppBuilder.java   
private static DeploymentLoader.ExternalConfiguration configuredClasspath(final StandardContext standardContext) {
    Loader loader = standardContext.getLoader();
    if (loader != null && LazyStopLoader.class.isInstance(loader)) {
        loader = LazyStopLoader.class.cast(loader).getDelegateLoader();
    }
    if (loader != null) {
        final ClassLoader cl = standardContext.getLoader().getClassLoader();
        if (cl == null) {
            return null;
        }

        final Collection<String> cp = new LinkedList<>();

        final WebResourceRoot webResources = standardContext.getResources();
        if (webResources != null) { // to enhance
            for (final WebResourceSet[] sets : asList(webResources.getPreResources(), webResources.getPostResources(), webResources.getJarResources())) {
                for (final WebResourceSet wr : sets) {
                    final URL base = wr.getBaseUrl();
                    if (base != null) {
                        final File baseFile = URLs.toFile(base);
                        if (baseFile.isDirectory()) {
                            final String[] libs = wr.list("/WEB-INF/lib/");
                            if (libs != null) {
                                for (final String resource : libs) {
                                    cp.add(new File(baseFile, resource).getAbsolutePath());
                                }
                            }

                            final WebResource classes = wr.getResource("/WEB-INF/classes/");
                            if (classes != null) {
                                final String path = classes.getCanonicalPath();
                                if (path != null) {
                                    cp.add(path);
                                }
                            }
                        } else if (baseFile.exists() && baseFile.getName().endsWith(".jar") && wr.getResource("/WEB-INF/classes/").exists()) {
                            try {
                                cp.add(baseFile.getCanonicalPath());
                            } catch (final IOException e) {
                                throw new IllegalStateException(e);
                            }
                        }
                    }
                }
            }
        }

        if (!cp.isEmpty()) {
            return new DeploymentLoader.ExternalConfiguration(cp.toArray(new String[cp.size()]), null /*for now doesnt make sense, todo: configure*/);
        }
    }
    return null;
}
项目:RAFTools    文件:NIOResourceRoot.java   
@Override
public void addPreResources(WebResourceSet webResourceSet) {

}
项目:RAFTools    文件:NIOResourceRoot.java   
@Override
public void addJarResources(WebResourceSet webResourceSet) {

}
项目:RAFTools    文件:NIOResourceRoot.java   
@Override
public void addPostResources(WebResourceSet webResourceSet) {

}