public void init() { if (getServletConfig() != null) { if (getInitParameter("charset") != null) { charset = getInitParameter("charset"); } if (getInitParameter("cache") != null) { cache = Boolean.valueOf(getInitParameter("cache")); } if (getInitParameter("compress") != null) { compress = Boolean.valueOf(getInitParameter("compress")); } } try { initialContext = new javax.naming.InitialContext(); } catch (NamingException e) { } catch (NoClassDefFoundError e) { } if (initialContext != null) { if (getJndiParameter("/resource/Charset") != null) { charset = (String) getJndiParameter("/resource/Charset"); } if (getJndiParameter("/resource/Cache") != null) { cache = (Boolean) getJndiParameter("/resource/Cache"); } if (getJndiParameter("/resource/Compress") != null) { compress = (Boolean) getJndiParameter("/resource/Compress"); } } }
protected long getResourceLastModified(String uri) throws IOException { Resource resource = getResource(uri); return resource.getLastModified(); }
protected String getResourceMimeType(String uri) { String extension = uri.substring(uri.lastIndexOf(".") + 1); String mimeType = mimeTypes.containsKey(extension) ? mimeTypes .get(extension) : getServletContext().getMimeType(uri); return mimeType != null ? mimeType : "application/octet-stream"; }
+ request.getServletPath() + (request.getPathInfo() == null ? "" : request.getPathInfo())) }; String mimeType = getResourceMimeType(uri[0]); long lastModified = 0; byte[] content = new byte[0]; ""); try { content = mergeContent(content, getResourceContent(resource)); } catch (IOException e) { logger.error("Cannot find " + resource + "."); getResourceLastModified(resource));
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); }
protected byte[] getResourceContent(String uri) throws Exception { Resource resource = getResource(uri); return resource.getContent(); }
protected Resource getResource(String uri) throws ResourceNotFoundException { String mimeType = getResourceMimeType(uri); if (!resources.containsKey(uri)) { logger.debug("Using new LessResource for uri " + uri); if ("text/css".equals(mimeType)) { resources.put(uri, new LessResource(engine, getServletContext(), uri, charset, cache, compress)); return resources.get(uri); } else { return super.getResource(uri); } } else { logger.debug("Using existing LessResource for uri " + uri); return resources.get(uri); } } }