/** * The getter pair of {@link #setTemplateNameFormat(TemplateNameFormat)}. */ public TemplateNameFormat getTemplateNameFormat() { if (cache == null) { return null; } return cache.getTemplateNameFormat(); }
@Override public Object clone() { try { Configuration copy = (Configuration) super.clone(); copy.sharedVariables = new HashMap(sharedVariables); copy.localeToCharsetMap = new ConcurrentHashMap(localeToCharsetMap); copy.recreateTemplateCacheWith( cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); return copy; } catch (CloneNotSupportedException e) { throw new BugException("Cloning failed", e); } }
private void recreateTemplateCache() { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), getTemplateConfigurations()); }
/** * Sets the {@link TemplateLookupStrategy} that is used to look up templates based on the requested name; as a side * effect the template cache will be emptied. The default value is {@link TemplateLookupStrategy#DEFAULT_2_3_0}. * * @since 2.3.22 */ public void setTemplateLookupStrategy(TemplateLookupStrategy templateLookupStrategy) { if (cache.getTemplateLookupStrategy() != templateLookupStrategy) { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), templateLookupStrategy, cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); } templateLookupStrategyExplicitlySet = true; }
/** * Sets the template name format used. The default is {@link TemplateNameFormat#DEFAULT_2_3_0}, while the * recommended value for new projects is {@link TemplateNameFormat#DEFAULT_2_4_0}. * * @since 2.3.22 */ public void setTemplateNameFormat(TemplateNameFormat templateNameFormat) { if (cache.getTemplateNameFormat() != templateNameFormat) { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), templateNameFormat, cache.getTemplateConfigurations()); } templateNameFormatExplicitlySet = true; }
/** * Sets the {@link CacheStorage} used for caching {@link Template}-s; * the earlier content of the template cache will be dropt. * * The default is a {@link SoftCacheStorage}. If the total size of the {@link Template} * objects is significant but most templates are used rarely, using a * {@link MruCacheStorage} instead might be advisable. If you don't want caching at * all, use {@link freemarker.cache.NullCacheStorage} (you can't use {@code null}). * * <p>Note that setting the cache storage will re-create the template cache, so * all its content will be lost. */ public void setCacheStorage(CacheStorage cacheStorage) { // "synchronized" is removed from the API as it's not safe to set anything after publishing the Configuration synchronized (this) { if (getCacheStorage() != cacheStorage) { recreateTemplateCacheWith(cache.getTemplateLoader(), cacheStorage, cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); } cacheStorageExplicitlySet = true; } }
if (cache.getTemplateLoader() != templateLoader) { recreateTemplateCacheWith(templateLoader, cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), cache.getTemplateConfigurations());
/** * Sets a {@link TemplateConfigurationFactory} that will configure individual templates where their settings differ * from those coming from the common {@link Configuration} object. A typical use case for that is specifying the * {@link TemplateConfiguration#setOutputFormat(OutputFormat) outputFormat} for templates based on their file * extension or parent directory. * * <p> * Note that the settings suggested by standard file extensions are stronger than that you set here. See * {@link #setRecognizeStandardFileExtensions(boolean)} for more information about standard file extensions. * * <p>See "Template configurations" in the FreeMarker Manual for examples. * * @since 2.3.24 */ public void setTemplateConfigurations(TemplateConfigurationFactory templateConfigurations) { if (cache.getTemplateConfigurations() != templateConfigurations) { if (templateConfigurations != null) { templateConfigurations.setConfiguration(this); } recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), templateConfigurations); } }
/** * The getter pair of {@link #setTemplateNameFormat(TemplateNameFormat)}. */ public TemplateNameFormat getTemplateNameFormat() { if (cache == null) { return null; } return cache.getTemplateNameFormat(); }
/** * The getter pair of {@link #setTemplateNameFormat(TemplateNameFormat)}. */ public TemplateNameFormat getTemplateNameFormat() { if (cache == null) { return null; } return cache.getTemplateNameFormat(); }
@Override public Object clone() { try { Configuration copy = (Configuration) super.clone(); copy.sharedVariables = new HashMap(sharedVariables); copy.localeToCharsetMap = new ConcurrentHashMap(localeToCharsetMap); copy.recreateTemplateCacheWith( cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); return copy; } catch (CloneNotSupportedException e) { throw new BugException("Cloning failed", e); } }
@Override public Object clone() { try { Configuration copy = (Configuration) super.clone(); copy.sharedVariables = new HashMap(sharedVariables); copy.localeToCharsetMap = new ConcurrentHashMap(localeToCharsetMap); copy.recreateTemplateCacheWith( cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); return copy; } catch (CloneNotSupportedException e) { throw new BugException("Cloning failed", e); } }
private void recreateTemplateCache() { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), getTemplateConfigurations()); }
private void recreateTemplateCache() { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), getTemplateConfigurations()); }
/** * Sets the {@link TemplateLookupStrategy} that is used to look up templates based on the requested name; as a side * effect the template cache will be emptied. The default value is {@link TemplateLookupStrategy#DEFAULT_2_3_0}. * * @since 2.3.22 */ public void setTemplateLookupStrategy(TemplateLookupStrategy templateLookupStrategy) { if (cache.getTemplateLookupStrategy() != templateLookupStrategy) { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), templateLookupStrategy, cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); } templateLookupStrategyExplicitlySet = true; }
/** * Sets the template name format used. The default is {@link TemplateNameFormat#DEFAULT_2_3_0}, while the * recommended value for new projects is {@link TemplateNameFormat#DEFAULT_2_4_0}. * * @since 2.3.22 */ public void setTemplateNameFormat(TemplateNameFormat templateNameFormat) { if (cache.getTemplateNameFormat() != templateNameFormat) { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), templateNameFormat, cache.getTemplateConfigurations()); } templateNameFormatExplicitlySet = true; }
/** * Sets the template name format used. The default is {@link TemplateNameFormat#DEFAULT_2_3_0}, while the * recommended value for new projects is {@link TemplateNameFormat#DEFAULT_2_4_0}. * * @since 2.3.22 */ public void setTemplateNameFormat(TemplateNameFormat templateNameFormat) { if (cache.getTemplateNameFormat() != templateNameFormat) { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), templateNameFormat, cache.getTemplateConfigurations()); } templateNameFormatExplicitlySet = true; }
/** * Sets the {@link TemplateLookupStrategy} that is used to look up templates based on the requested name; as a side * effect the template cache will be emptied. The default value is {@link TemplateLookupStrategy#DEFAULT_2_3_0}. * * @since 2.3.22 */ public void setTemplateLookupStrategy(TemplateLookupStrategy templateLookupStrategy) { if (cache.getTemplateLookupStrategy() != templateLookupStrategy) { recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), templateLookupStrategy, cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); } templateLookupStrategyExplicitlySet = true; }
/** * Sets the {@link CacheStorage} used for caching {@link Template}-s; * the earlier content of the template cache will be dropt. * * The default is a {@link SoftCacheStorage}. If the total size of the {@link Template} * objects is significant but most templates are used rarely, using a * {@link MruCacheStorage} instead might be advisable. If you don't want caching at * all, use {@link freemarker.cache.NullCacheStorage} (you can't use {@code null}). * * <p>Note that setting the cache storage will re-create the template cache, so * all its content will be lost. */ public void setCacheStorage(CacheStorage cacheStorage) { // "synchronized" is removed from the API as it's not safe to set anything after publishing the Configuration synchronized (this) { if (getCacheStorage() != cacheStorage) { recreateTemplateCacheWith(cache.getTemplateLoader(), cacheStorage, cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), cache.getTemplateConfigurations()); } cacheStorageExplicitlySet = true; } }
/** * Sets a {@link TemplateConfigurationFactory} that will configure individual templates where their settings differ * from those coming from the common {@link Configuration} object. A typical use case for that is specifying the * {@link TemplateConfiguration#setOutputFormat(OutputFormat) outputFormat} for templates based on their file * extension or parent directory. * * <p> * Note that the settings suggested by standard file extensions are stronger than that you set here. See * {@link #setRecognizeStandardFileExtensions(boolean)} for more information about standard file extensions. * * <p>See "Template configurations" in the FreeMarker Manual for examples. * * @since 2.3.24 */ public void setTemplateConfigurations(TemplateConfigurationFactory templateConfigurations) { if (cache.getTemplateConfigurations() != templateConfigurations) { if (templateConfigurations != null) { templateConfigurations.setConfiguration(this); } recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), templateConfigurations); } }