protected byte[] getResourceContent(String uri) throws Exception { Resource resource = getResource(uri); return resource.getContent(); }
public Resource(ServletContext servletContext, String uri, String charset, boolean cache) throws ResourceNotFoundException { this.servletContext = servletContext; this.charset = charset; this.cache = cache; URL url = getUrl(uri); File file = getFile(uri); if (url != null || (file != null && file.exists())) { path = url != null ? url.getPath() : file.getAbsolutePath(); resource = url != null ? url : file; } else { logger.error("Error processing " + uri + "."); throw new ResourceNotFoundException("Error processing " + uri + "."); } }
protected long getResourceLastModified(String uri) throws IOException { Resource resource = getResource(uri); return resource.getLastModified(); }
protected Resource getResource(String uri) throws ResourceNotFoundException { String mimeType = getResourceMimeType(uri); if (!resources.containsKey(uri)) { if ("text/css".equals(mimeType)) { resources.put(uri, new StyleResource(getServletContext(), uri, charset, cache, compress)); } else if ("text/javascript".equals(mimeType)) { resources.put(uri, new ScriptResource(getServletContext(), uri, charset, cache, compress)); } else { resources.put(uri, new Resource(getServletContext(), uri, charset, cache)); } } return resources.get(uri); }
public byte[] getContent() throws Exception { if (content == null || (!cache && lastModified < getLastModified())) { content = resource instanceof URL ? ResourceUtils .readBinaryUrl((URL) resource) : ResourceUtils .readBinaryFile((File) resource); lastModified = getLastModified(); } return content; }