public void closeTemplateSource(Object source) throws IOException { if (source instanceof File) { fileTemplateLoader.closeTemplateSource(source); } else { ClassTemplateSource wrapper = (ClassTemplateSource) source; // close the raw source classTemplateLoader.closeTemplateSource(wrapper.source); // cleanup wrapper.path = null; wrapper.source = null; } }
public Reader getReader(Object source, String encoding) throws IOException { if (source instanceof File) { // loaded from file return fileTemplateLoader.getReader(source, encoding); } else { // get teh resource for the raw source as use it right away ClassTemplateSource wrapper = (ClassTemplateSource) source; return classTemplateLoader.getReader(wrapper.source, encoding); } }
public long getLastModified(Object source) { if (source instanceof File) { // loaded from file return fileTemplateLoader.getLastModified(source); } else { // loaded from class ClassTemplateSource wrapper = (ClassTemplateSource) source; return classTemplateLoader.getLastModified(wrapper.source); } }
/** * This implementation registers an additional ClassTemplateLoader * for the Spring-provided macros, added to the end of the list. */ @Override protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) { templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, "")); }
private void recreateTemplateCacheWith( TemplateLoader loader, CacheStorage storage, TemplateLookupStrategy templateLookupStrategy, TemplateNameFormat templateNameFormat, TemplateConfigurationFactory templateConfigurations) { TemplateCache oldCache = cache; cache = new TemplateCache( loader, storage, templateLookupStrategy, templateNameFormat, templateConfigurations, this); cache.clear(); // for fully BC behavior cache.setDelay(oldCache.getDelay()); cache.setLocalizedLookup(localizedLookup); }
@Override public void closeTemplateSource(Object templateSource) throws IOException { delegate.closeTemplateSource(templateSource); } }
public Object findTemplateSource(String name) throws IOException { URL url = getURL(name); return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches()); }
/** Used internally to create the appropriate kind of result from the parameters. */ static TemplateLookupResult from(String templateSourceName, Object templateSource) { return templateSource != null ? new PositiveTemplateLookupResult(templateSourceName, templateSource) : createNegativeResult(); }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { if (matcher.matches(sourceName, templateSource)) { if (templateConfigurationFactory != null) { return templateConfigurationFactory.get(sourceName, templateSource); } else { return templateConfiguration; } } else { return null; } }
/** * Returns a close approximation of the current number of cache entries. * * @see #getStrongSize() * @see #getSoftSize() * @since 2.3.21 */ public int getSize() { return getSoftSize() + getStrongSize(); }
/** * The getter pair of {@link #setTemplateLoader(TemplateLoader)}. */ public TemplateLoader getTemplateLoader() { if (cache == null) { return null; } return cache.getTemplateLoader(); }
/** * The getter pair of {@link #setTemplateUpdateDelayMilliseconds(long)}. * * @since 2.3.23 */ public long getTemplateUpdateDelayMilliseconds() { return cache.getDelay(); }
/** * Removes all entries from the template cache, thus forcing reloading of templates * on subsequent <code>getTemplate</code> calls. * * <p>This method is thread-safe and can be called while the engine processes templates. */ public void clearTemplateCache() { cache.clear(); }
/** * Returns a close approximation of the <em>current</em> number of soft cache entries. * * @see #getSoftSizeLimit() * @since 2.3.21 */ public int getSoftSize() { removeClearedReferences(); return softSize; }
/** * Sets if the matching will be case insensitive (UNICODE compliant); default is {@code false}. */ public void setCaseInsensitive(boolean caseInsensitive) { boolean lastCaseInsensitive = this.caseInsensitive; this.caseInsensitive = caseInsensitive; if (lastCaseInsensitive != caseInsensitive) { buildPattern(); } }
/** * Same as {@link #setAllowNoMatch(boolean)}, but return this object to support "fluent API" style. */ public FirstMatchTemplateConfigurationFactory allowNoMatch(boolean allow) { setAllowNoMatch(allow); return this; }
/** * Fluid API variation of {@link #setCaseInsensitive(boolean)} */ public FileNameGlobMatcher caseInsensitive(boolean caseInsensitive) { setCaseInsensitive(caseInsensitive); return this; }
/** * Same as {@link #setNoMatchErrorDetails(String)}, but return this object to support "fluent API" style. */ public FirstMatchTemplateConfigurationFactory noMatchErrorDetails(String message) { setNoMatchErrorDetails(message); return this; }
/** * This implementation registers an additional ClassTemplateLoader * for the Spring-provided macros, added to the end of the list. */ @Override protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) { templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, "")); }