use of io.undertow.server.handlers.resource.ResourceManager in project spring-boot by spring-projects.
the class UndertowServletWebServerFactory method getDocumentRootResourceManager.
private ResourceManager getDocumentRootResourceManager() {
File root = getCanonicalDocumentRoot();
List<URL> metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources();
List<URL> resourceJarUrls = new ArrayList<URL>();
List<ResourceManager> resourceManagers = new ArrayList<ResourceManager>();
ResourceManager rootResourceManager = root.isDirectory() ? new FileResourceManager(root, 0) : new JarResourceManager(root);
resourceManagers.add(rootResourceManager);
for (URL url : metaInfResourceUrls) {
if ("file".equals(url.getProtocol())) {
File file = new File(url.getFile());
if (file.isFile()) {
try {
resourceJarUrls.add(new URL("jar:" + url + "!/"));
} catch (MalformedURLException ex) {
throw new RuntimeException(ex);
}
} else {
resourceManagers.add(new FileResourceManager(new File(file, "META-INF/resources"), 0));
}
} else {
resourceJarUrls.add(url);
}
}
resourceManagers.add(new MetaInfResourcesResourceManager(resourceJarUrls));
return new CompositeResourceManager(resourceManagers.toArray(new ResourceManager[resourceManagers.size()]));
}
Aggregations