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;
}
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;
}
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
}
}
}
}
}
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);
}
}
}
}
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;
}
Aggregations