public byte[] getContent(String path) throws IOException { if (content == null || (!cache && lastModified < getLastModified())) { content = resource instanceof URL ? ResourceUtils.readTextUrl( (URL) resource, charset) : ResourceUtils.readTextFile( (File) resource, charset); lastModified = getLastModified(); if (compress) { compress(); } } return content; }
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 LessException, IOException { if (content == null || !cache) { logger.debug("Not using cache."); if (engine != null) { logger.debug("LessEngine available, compiling."); content = (resource instanceof URL ? engine .compile((URL) resource) : engine .compile((File) resource)).replaceAll("\\\\n", "\n") .getBytes(charset); } else { logger.debug("LessEngine not available, treating as regular resource."); content = resource instanceof URL ? ResourceUtils.readTextUrl( (URL) resource, charset) : ResourceUtils.readTextFile( (File) resource, charset); } lastModified = super.getLastModified(); if (compress) { logger.debug("Compressing resource."); compress(); } } else { logger.debug("Using cache, since lastModified: " + lastModified + " and getLastModified: " + getLastModified()); } return content; }