Search in sources :

Example 6 with WebResourceSet

use of org.apache.catalina.WebResourceSet in project tomcat by apache.

the class TestDirResourceSetMount method getWebResourceRoot.

@Override
public WebResourceRoot getWebResourceRoot() {
    TesterWebResourceRoot root = new TesterWebResourceRoot();
    WebResourceSet webResourceSet = new DirResourceSet(new TesterWebResourceRoot(), getMount(), getBaseDir().getAbsolutePath(), "/");
    root.setMainResources(webResourceSet);
    return root;
}
Also used : WebResourceSet(org.apache.catalina.WebResourceSet)

Example 7 with WebResourceSet

use of org.apache.catalina.WebResourceSet in project tomcat by apache.

the class TestJarResourceSet method getWebResourceRoot.

@Override
public WebResourceRoot getWebResourceRoot() {
    File f = new File("test/webresources/dir1.jar");
    TesterWebResourceRoot root = new TesterWebResourceRoot();
    WebResourceSet webResourceSet = new JarResourceSet(root, "/", f.getAbsolutePath(), "/");
    root.setMainResources(webResourceSet);
    return root;
}
Also used : WebResourceSet(org.apache.catalina.WebResourceSet) File(java.io.File)

Example 8 with WebResourceSet

use of org.apache.catalina.WebResourceSet in project tomee by apache.

the class TomEEWebappClassLoader method setResources.

@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
                }
            }
        }
    }
}
Also used : WebResourceSet(org.apache.catalina.WebResourceSet) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) IOException(java.io.IOException) File(java.io.File)

Example 9 with WebResourceSet

use of org.apache.catalina.WebResourceSet in project tomcat by apache.

the class WebResourceRootSF method storeChildren.

/**
     * Store the specified Resources children.
     *
     * @param aWriter
     *            PrintWriter to which we are storing
     * @param indent
     *            Number of spaces to indent this element
     *
     * @exception Exception
     *                if an exception occurs while storing
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aResourceRoot, StoreDescription parentDesc) throws Exception {
    if (aResourceRoot instanceof WebResourceRoot) {
        WebResourceRoot resourceRoot = (WebResourceRoot) aResourceRoot;
        // Store nested <PreResources> elements
        WebResourceSet[] preResourcesArray = resourceRoot.getPreResources();
        StoreDescription preResourcesElementDesc = getRegistry().findDescription(WebResourceSet.class.getName() + ".[PreResources]");
        if (preResourcesElementDesc != null) {
            for (WebResourceSet preResources : preResourcesArray) {
                preResourcesElementDesc.getStoreFactory().store(aWriter, indent, preResources);
            }
        }
        // Store nested <JarResources> elements
        WebResourceSet[] jarResourcesArray = resourceRoot.getJarResources();
        StoreDescription jarResourcesElementDesc = getRegistry().findDescription(WebResourceSet.class.getName() + ".[JarResources]");
        if (jarResourcesElementDesc != null) {
            for (WebResourceSet jarResources : jarResourcesArray) {
                jarResourcesElementDesc.getStoreFactory().store(aWriter, indent, jarResources);
            }
        }
        // Store nested <PostResources> elements
        WebResourceSet[] postResourcesArray = resourceRoot.getPostResources();
        StoreDescription postResourcesElementDesc = getRegistry().findDescription(WebResourceSet.class.getName() + ".[PostResources]");
        if (postResourcesElementDesc != null) {
            for (WebResourceSet postResources : postResourcesArray) {
                postResourcesElementDesc.getStoreFactory().store(aWriter, indent, postResources);
            }
        }
    }
}
Also used : WebResourceSet(org.apache.catalina.WebResourceSet) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Example 10 with WebResourceSet

use of org.apache.catalina.WebResourceSet in project tomcat by apache.

the class AbstractTestFileResourceSet method getWebResourceRoot.

@Override
public WebResourceRoot getWebResourceRoot() {
    TesterWebResourceRoot root = new TesterWebResourceRoot();
    WebResourceSet webResourceSet = new DirResourceSet(root, "/", getBaseDir().getAbsolutePath(), "/");
    webResourceSet.setReadOnly(readOnly);
    root.setMainResources(webResourceSet);
    WebResourceSet f1 = new FileResourceSet(root, "/f1.txt", "test/webresources/dir1/f1.txt", "/");
    f1.setReadOnly(readOnly);
    root.addPreResources(f1);
    WebResourceSet f2 = new FileResourceSet(root, "/f2.txt", "test/webresources/dir1/f2.txt", "/");
    f2.setReadOnly(readOnly);
    root.addPreResources(f2);
    WebResourceSet d1f1 = new FileResourceSet(root, "/d1/d1-f1.txt", "test/webresources/dir1/d1/d1-f1.txt", "/");
    d1f1.setReadOnly(readOnly);
    root.addPreResources(d1f1);
    WebResourceSet d2f1 = new FileResourceSet(root, "/d2/d2-f1.txt", "test/webresources/dir1/d2/d2-f1.txt", "/");
    d2f1.setReadOnly(readOnly);
    root.addPreResources(d2f1);
    return root;
}
Also used : WebResourceSet(org.apache.catalina.WebResourceSet)

Aggregations

WebResourceSet (org.apache.catalina.WebResourceSet)21 File (java.io.File)8 IOException (java.io.IOException)3 WebResource (org.apache.catalina.WebResource)3 LinkedList (java.util.LinkedList)2 TrackedWebResource (org.apache.catalina.TrackedWebResource)2 WebResourceRoot (org.apache.catalina.WebResourceRoot)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 JarFile (java.util.jar.JarFile)1 Host (org.apache.catalina.Host)1 Loader (org.apache.catalina.Loader)1 WebappLoader (org.apache.catalina.loader.WebappLoader)1 DeploymentLoader (org.apache.openejb.config.DeploymentLoader)1 Test (org.junit.Test)1