use of org.apache.catalina.loader.ParallelWebappClassLoader in project spring-boot by spring-projects.
the class TomcatEmbeddedWebappClassLoaderTests method withWebappClassLoader.
private void withWebappClassLoader(File war, ClassLoaderConsumer consumer) throws Exception {
URLClassLoader parent = new URLClassLoader(new URL[] { new URL(webInfClassesUrlString(war)) }, null);
try (ParallelWebappClassLoader classLoader = new TomcatEmbeddedWebappClassLoader(parent)) {
StandardContext context = new StandardContext();
context.setName("test");
StandardRoot resources = new StandardRoot();
resources.setContext(context);
resources.addJarResources(new WarResourceSet(resources, "/", war.getAbsolutePath()));
resources.start();
classLoader.setResources(resources);
classLoader.start();
try {
consumer.accept(classLoader);
} finally {
classLoader.stop();
classLoader.close();
resources.stop();
}
}
parent.close();
}
Aggregations