/** * The getter pair of {@link #setCacheStorage(CacheStorage)}. * * @since 2.3.20 */ public CacheStorage getCacheStorage() { // "synchronized" is removed from the API as it's not safe to set anything after publishing the Configuration synchronized (this) { if (cache == null) { return null; } return cache.getCacheStorage(); } }
@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; }
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 #setCacheStorage(CacheStorage)}. * * @since 2.3.20 */ public CacheStorage getCacheStorage() { // "synchronized" is removed from the API as it's not safe to set anything after publishing the Configuration synchronized (this) { if (cache == null) { return null; } return cache.getCacheStorage(); } }
/** * The getter pair of {@link #setCacheStorage(CacheStorage)}. * * @since 2.3.20 */ public CacheStorage getCacheStorage() { // "synchronized" is removed from the API as it's not safe to set anything after publishing the Configuration synchronized (this) { if (cache == null) { return null; } return cache.getCacheStorage(); } }
/** * Sets a template loader that is used to look up and load templates. * By providing your own template loader, you can customize the way * templates are loaded. Several convenience methods in this class already * allow you to install commonly used loaders: * {@link #setClassForTemplateLoading(Class, String)}, * {@link #setDirectoryForTemplateLoading(File)}, and * {@link #setServletContextForTemplateLoading(Object, String)}. By default, * a multi-loader is used that first tries to load a template from the file * in the current directory, then from a resource on the classpath. */ public synchronized void setTemplateLoader(TemplateLoader loader) { createTemplateCache(loader, cache.getCacheStorage()); }
public Object clone() { try { Configuration copy = (Configuration)super.clone(); copy.variables = new HashMap(variables); copy.encodingMap = new HashMap(encodingMap); copy.createTemplateCache(cache.getTemplateLoader(), cache.getCacheStorage()); return copy; } catch (CloneNotSupportedException e) { throw new RuntimeException("Clone is not supported, but it should be: " + e.getMessage()); } }
@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 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 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 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); } }