@Override public WebResource getResource( String path ) { log.debug( "MyDirContext#getResource: " + path ); if ( "/WEB-INF/classes".equals( path ) ) { return new FileResource( this, this.webAppPath, new File( this.buildOutputDirectory ), true ); } File file = new File( path ); if ( file.exists() ) { return new FileResource( this, this.webAppPath, file, true ); } WebResource webResource = super.getResource( path ); return webResource; }
@Override public URL getCodeBase() { if (getWebappPath().startsWith("/WEB-INF/classes/") && name.endsWith(".class")) { return getWebResourceRoot().getResource("/WEB-INF/classes/").getURL(); } else { return getURL(); } }
private long getContentLengthInternal(boolean convert) { if (convert) { byte[] content = getContent(); if (content == null) { return -1; } else { return content.length; } } if (isDirectory()) { return -1; } return resource.length(); }
@Override public final byte[] getContent() { long len = getContentLengthInternal(false); "abstractResource.getContentTooLarge", getWebappPath(), Long.valueOf(len))); if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("abstractResource.getContentFail", getWebappPath()), ioe);
@Override public final byte[] getContent() { long len = getContentLength(); if (len > Integer.MAX_VALUE) { // Can't create an array that big throw new ArrayIndexOutOfBoundsException(sm.getString( "abstractResource.getContentTooLarge", getWebappPath(), Long.valueOf(len))); } int size = (int) len; byte[] result = new byte[size]; int pos = 0; try (InputStream is = new FileInputStream(resource)) { while (pos < size) { int n = is.read(result, pos, size - pos); if (n < 0) { break; } pos += n; } } catch (IOException ioe) { if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("abstractResource.getContentFail", getWebappPath()), ioe); } } return result; }
@Override public long getContentLength() { return getContentLengthInternal(needConvert); }
@Override protected InputStream doGetInputStream() { if (needConvert) { byte[] content = getContent(); if (content == null) { return null; } else { return new ByteArrayInputStream(content); } } try { return new FileInputStream(resource); } catch (FileNotFoundException fnfe) { // Race condition (file has been deleted) - not an error return null; } }
@Override public final byte[] getContent() { long len = getContentLengthInternal(false); "abstractResource.getContentTooLarge", getWebappPath(), Long.valueOf(len))); if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("abstractResource.getContentFail", getWebappPath()), ioe);
@Override public long getContentLength() { return getContentLengthInternal(needConvert); }
@Override protected InputStream doGetInputStream() { if (needConvert) { byte[] content = getContent(); if (content == null) { return null; } else { return new ByteArrayInputStream(content); } } try { return new FileInputStream(resource); } catch (FileNotFoundException fnfe) { // Race condition (file has been deleted) - not an error return null; } }
return new FileResource( this, webAppPath, new File( url.getFile() ), true );
@Override public URL getCodeBase() { if (getWebappPath().startsWith("/WEB-INF/classes/") && name.endsWith(".class")) { return getWebResourceRoot().getResource("/WEB-INF/classes/").getURL(); } else { return getURL(); } }
private long getContentLengthInternal(boolean convert) { if (convert) { byte[] content = getContent(); if (content == null) { return -1; } else { return content.length; } } if (isDirectory()) { return -1; } return resource.length(); }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.equals(webAppMount)) { File f = file("", true); if (f == null) { return new EmptyResource(root, path); } return new FileResource(root, path, f); } if (path.charAt(path.length() - 1) != '/') { path = path + '/'; } if (webAppMount.startsWith(path)) { String name = path.substring(0, path.length() - 1); name = name.substring(name.lastIndexOf('/') + 1); if (name.length() > 0) { return new VirtualResource(root, path, name); } } return new EmptyResource(root, path); }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return new EmptyResource(root, path); } if (!f.exists()) { return new EmptyResource(root, path, f); } if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { path = path += '/'; } return new FileResource(root, path, f); } else { return new EmptyResource(root, path); } }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.equals(webAppMount)) { File f = file("", true); if (f == null) { return new EmptyResource(root, path); } return new FileResource(root, path, f, isReadOnly(), null); } if (path.charAt(path.length() - 1) != '/') { path = path + '/'; } if (webAppMount.startsWith(path)) { String name = path.substring(0, path.length() - 1); name = name.substring(name.lastIndexOf('/') + 1); if (name.length() > 0) { return new VirtualResource(root, path, name); } } return new EmptyResource(root, path); }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.equals(webAppMount)) { File f = file("", true); if (f == null) { return new EmptyResource(root, path); } return new FileResource(root, path, f, isReadOnly(), null); } if (path.charAt(path.length() - 1) != '/') { path = path + '/'; } if (webAppMount.startsWith(path)) { String name = path.substring(0, path.length() - 1); name = name.substring(name.lastIndexOf('/') + 1); if (name.length() > 0) { return new VirtualResource(root, path, name); } } return new EmptyResource(root, path); }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return new EmptyResource(root, path); } if (!f.exists()) { return new EmptyResource(root, path, f); } if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { path = path + '/'; } return new FileResource(root, path, f, isReadOnly(), getManifest()); } else { return new EmptyResource(root, path); } }
return new FileResource( context.getResources(), getPath(), file, true ); return new FileResource( context.getResources(), getPath(), new File( project.getBuild().getOutputDirectory() ), true ); if ( file.exists() ) return new FileResource( context.getResources(), getPath(), file, true );
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return new EmptyResource(root, path); } if (!f.exists()) { return new EmptyResource(root, path, f); } if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { path = path + '/'; } return new FileResource(root, path, f, isReadOnly(), getManifest()); } else { return new EmptyResource(root, path); } }