public Object findTemplateSource(String name) throws IOException { URL url = getURL(name); return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches()); }
public void closeTemplateSource(Object templateSource) throws IOException { if (templateSource instanceof File) { // Do nothing. } else { ((URLTemplateSource) templateSource).close(); } }
public Reader getReader(Object templateSource, String encoding) throws IOException { return new InputStreamReader( ((URLTemplateSource) templateSource).getInputStream(), encoding); }
/** * If IcI >= 2.3.21, sets {@link URLTemplateSource#setUseCaches(boolean)} to {@code false} for sources that come * from a {@link TemplateLoader} where {@link URLConnection} cache usage wasn't set explicitly. */ private Object modifyForConfIcI(Object templateSource) { if (templateSource == null) return null; if (config.getIncompatibleImprovements().intValue() < _TemplateAPI.VERSION_INT_2_3_21) { return templateSource; } if (templateSource instanceof URLTemplateSource) { URLTemplateSource urlTemplateSource = (URLTemplateSource) templateSource; if (urlTemplateSource.getUseCaches() == null) { // It was left unset urlTemplateSource.setUseCaches(false); } } else if (templateSource instanceof MultiSource) { modifyForConfIcI(((MultiSource) templateSource).getWrappedSource()); } return templateSource; }
public long getLastModified(Object templateSource) { return ((URLTemplateSource) templateSource).lastModified(); }
public long getLastModified(Object templateSource) { if (templateSource instanceof File) { return ((File) templateSource).lastModified(); } else { return ((URLTemplateSource) templateSource).lastModified(); } }
/** * If IcI >= 2.3.21, sets {@link URLTemplateSource#setUseCaches(boolean)} to {@code false} for sources that come * from a {@link TemplateLoader} where {@link URLConnection} cache usage wasn't set explicitly. */ private Object modifyForConfIcI(Object templateSource) { if (templateSource == null) return null; if (config.getIncompatibleImprovements().intValue() < _TemplateAPI.VERSION_INT_2_3_21) { return templateSource; } if (templateSource instanceof URLTemplateSource) { URLTemplateSource urlTemplateSource = (URLTemplateSource) templateSource; if (urlTemplateSource.getUseCaches() == null) { // It was left unset urlTemplateSource.setUseCaches(false); } } else if (templateSource instanceof MultiSource) { modifyForConfIcI(((MultiSource) templateSource).getWrappedSource()); } return templateSource; }
public Reader getReader(Object templateSource, String encoding) throws IOException { if (templateSource instanceof File) { return new InputStreamReader( new FileInputStream((File) templateSource), encoding); } else { return new InputStreamReader( ((URLTemplateSource) templateSource).getInputStream(), encoding); } }
public long getLastModified(Object templateSource) { return ((URLTemplateSource) templateSource).lastModified(); }
public Object findTemplateSource(String name) throws IOException { String fullPath = subdirPath + name; if (attemptFileAccess) { // First try to open as plain file (to bypass servlet container resource caches). try { String realPath = servletContext.getRealPath(fullPath); if (realPath != null) { File file = new File(realPath); if (file.canRead() && file.isFile()) { return file; } } } catch (SecurityException e) { ;// ignore } } // If it fails, try to open it with servletContext.getResource. URL url = null; try { url = servletContext.getResource(fullPath); } catch (MalformedURLException e) { LOG.warn("Could not retrieve resource " + StringUtil.jQuoteNoXSS(fullPath), e); return null; } return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches()); }
public void closeTemplateSource(Object templateSource) throws IOException { ((URLTemplateSource) templateSource).close(); }
/** * If IcI >= 2.3.21, sets {@link URLTemplateSource#setUseCaches(boolean)} to {@code false} for sources that come * from a {@link TemplateLoader} where {@link URLConnection} cache usage wasn't set explicitly. */ private Object modifyForConfIcI(Object templateSource) { if (templateSource == null) return null; if (config.getIncompatibleImprovements().intValue() < _TemplateAPI.VERSION_INT_2_3_21) { return templateSource; } if (templateSource instanceof URLTemplateSource) { URLTemplateSource urlTemplateSource = (URLTemplateSource) templateSource; if (urlTemplateSource.getUseCaches() == null) { // It was left unset urlTemplateSource.setUseCaches(false); } } else if (templateSource instanceof MultiSource) { modifyForConfIcI(((MultiSource) templateSource).getWrappedSource()); } return templateSource; }
public Reader getReader(Object templateSource, String encoding) throws IOException { return new InputStreamReader( ((URLTemplateSource) templateSource).getInputStream(), encoding); }
public long getLastModified(Object templateSource) { return ((URLTemplateSource) templateSource).lastModified(); }
public Object findTemplateSource(String name) throws IOException { URL url = getURL(name); return url == null ? null : new URLTemplateSource(url); }
public void closeTemplateSource(Object templateSource) throws IOException { ((URLTemplateSource) templateSource).close(); }
public Reader getReader(Object templateSource, String encoding) throws IOException { return new InputStreamReader( ((URLTemplateSource) templateSource).getInputStream(), encoding); }
public long getLastModified(Object templateSource) { return ((URLTemplateSource) templateSource).lastModified(); }
public Object findTemplateSource(String name) throws IOException { URL url = getURL(name); return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches()); }
public void closeTemplateSource(Object templateSource) throws IOException { if (templateSource instanceof File) { // Do nothing. } else { ((URLTemplateSource) templateSource).close(); } }