@Override public WebResource[] getResources(String path) { Path _path = rootPath.resolve(rootPath); if(!Files.exists(_path)) { return new WebResource[0]; } if(!Files.isDirectory(_path)) { return new WebResource[] { createResource(_path) }; } return listResources(path); }
@Override public Long[] getResourceAttributes(String name, Context context) { Long[] result = new Long[2]; WebResource resource = context.getResources().getResource(name); result[0] = resource.getContentLength(); result[1] = resource.getLastModified(); return result; }
@Override public WebResource[] listResources(String path) { Path[] children = listDirectory(rootPath.resolve(path)); WebResource[] res = new WebResource[children.length]; for(int i = 0; i < children.length; ++i) { res[i] = createResource(children[i]); } return res; }
@Override public WebResource getResource(String path) { logger.debug("Request for resource: %s", path); if(path.startsWith("/META-INF") || path.startsWith("/WEB-INF")) { logger.debug(" Forbidden path, returning empty"); return new EmptyResource(this, path); } return super.getResource(path); }
@Override public WebResource[] listResources(String path) { if(path.startsWith("/META-INF") || path.startsWith("/WEB-INF")) { logger.debug(" Forbidden path, returning empty"); return new WebResource[0]; } return super.listResources(path); }
public Long[] getResourceAttributes(String name, Context context) { Long result[] = new Long[2]; WebResource resource = context.getResources().getResource(name); result[0] = resource.getContentLength(); result[1] = resource.getLastModified(); return result; }
@Override public WebResource getResource(String path) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); }
@Override public WebResource[] getResources(String path) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); }
@Override public WebResource getClassLoaderResource(String path) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); }
@Override public WebResource[] getClassLoaderResources(String path) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); }
@Override public WebResource[] listResources(String path) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); }
@Override public InputStream getResourceStream(String name, Context context) throws IOException { WebResource resource = context.getResources().getResource(name); return resource.getInputStream(); }
@Override public WebResource getResource(String path) { return createResource(rootPath.resolve(path)); }
@Override public WebResource getClassLoaderResource(String path) { return new EmptyResource(this, webAppPath); }
@Override public WebResource[] getClassLoaderResources(String path) { return new WebResource[0]; }
@Override public WebResource getResource(final String path) { return super.getResource(computePath(path)); }
@Override public WebResource getResource(final String path) { return delegate.getResource(path); }
@Override public WebResource getClassLoaderResource(final String path) { return delegate.getClassLoaderResource(path); }
@Override public WebResource[] getClassLoaderResources(final String path) { return delegate.getClassLoaderResources(path); }
@Override public WebResource[] getResources(final String path) { return delegate.getResources(path); }
@Override public WebResource[] listResources(final String path) { return delegate.listResources(path); }
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; }