Java Code Examples for freemarker.template.Configuration#setTemplateUpdateDelay()

The following examples show how to use freemarker.template.Configuration#setTemplateUpdateDelay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Freemarker.java    From freeacs with MIT License 6 votes vote down vote up
/**
 * Inits the freemarker.
 *
 * @return the configuration
 */
public static Configuration initFreemarker() {
  try {
    Configuration config = new Configuration();
    config.setTemplateLoader(new ClassTemplateLoader(Freemarker.class, "/templates"));
    config.setTemplateUpdateDelay(0);
    config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
    config.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER);
    config.setDefaultEncoding("ISO-8859-1");
    config.setOutputEncoding("ISO-8859-1");
    config.setNumberFormat("0");
    config.setSetting("url_escaping_charset", "ISO-8859-1");
    config.setLocale(Locale.ENGLISH);
    setAutoImport(config);
    setSharedVariables(config);
    return config;
  } catch (Throwable e) {
    throw new RuntimeException("Could not initialise Freemarker configuration", e);
  }
}
 
Example 2
Source File: Freemarker.java    From freeacs with MIT License 5 votes vote down vote up
public Configuration initFreemarker() {
  Configuration config = new Configuration();
  config.setTemplateLoader(new ClassTemplateLoader(Freemarker.class, "/templates"));
  config.setTemplateUpdateDelay(0);
  config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
  config.setObjectWrapper(ObjectWrapper.DEFAULT_WRAPPER);
  config.setDefaultEncoding("UTF-8");
  config.setOutputEncoding("UTF-8");
  return config;
}
 
Example 3
Source File: TelegramNotificator.java    From teamcity-telegram-plugin with Apache License 2.0 5 votes vote down vote up
private Configuration createFreeMarkerConfig(@NotNull Path configDir) throws IOException {
  Configuration cfg = new Configuration();
  cfg.setDefaultEncoding("UTF-8");
  cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  cfg.setDirectoryForTemplateLoading(configDir.toFile());
  cfg.setTemplateUpdateDelay(TeamCityProperties.getInteger(
      "teamcity.notification.template.update.interval", 60));
  return cfg;
}
 
Example 4
Source File: OutMsgXmlBuilder.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
private static Configuration initFreeMarkerConfiguration() {
	Configuration config = new Configuration();
	StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
	initStringTemplateLoader(stringTemplateLoader);
	config.setTemplateLoader(stringTemplateLoader);
	
	// 模板缓存更新时间,对于OutMsg xml 在类文件中的模板来说已有热加载保障了更新
       config.setTemplateUpdateDelay(999999);
       // - Set an error handler that prints errors so they are readable with
       //   a HTML browser.
       // config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
       config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
       
       // - Use beans wrapper (recommmended for most applications)
       config.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER);
       // - Set the default charset of the template files
       config.setDefaultEncoding(encoding);		// config.setDefaultEncoding("ISO-8859-1");
       // - Set the charset of the output. This is actually just a hint, that
       //   templates may require for URL encoding and for generating META element
       //   that uses http-equiv="Content-type".
       config.setOutputEncoding(encoding);			// config.setOutputEncoding("UTF-8");
       // - Set the default locale
       config.setLocale(Locale.getDefault() /* Locale.CHINA */ );		// config.setLocale(Locale.US);
       config.setLocalizedLookup(false);
       
       // 去掉int型输出时的逗号, 例如: 123,456
       // config.setNumberFormat("#");		// config.setNumberFormat("0"); 也可以
       config.setNumberFormat("#0.#####");
       config.setDateFormat("yyyy-MM-dd");
       config.setTimeFormat("HH:mm:ss");
       config.setDateTimeFormat("yyyy-MM-dd HH:mm:ss");
	return config;
}