本文整理汇总了Java中freemarker.template.Configuration.setTemplateUpdateDelay方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.setTemplateUpdateDelay方法的具体用法?Java Configuration.setTemplateUpdateDelay怎么用?Java Configuration.setTemplateUpdateDelay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freemarker.template.Configuration
的用法示例。
在下文中一共展示了Configuration.setTemplateUpdateDelay方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFreeMarkerConfig
import freemarker.template.Configuration; //导入方法依赖的package包/类
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;
}
示例2: createEndpoint
import freemarker.template.Configuration; //导入方法依赖的package包/类
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// should we use regular configuration or no cache (content cache is default true)
Configuration config;
String encoding = getAndRemoveParameter(parameters, "encoding", String.class);
boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, Boolean.TRUE);
int templateUpdateDelay = getAndRemoveParameter(parameters, "templateUpdateDelay", Integer.class, 0);
if (cache) {
config = getConfiguration();
if (templateUpdateDelay > 0) {
config.setTemplateUpdateDelay(templateUpdateDelay);
}
} else {
config = getNoCacheConfiguration();
}
FreemarkerEndpoint endpoint = new FreemarkerEndpoint(uri, this, remaining);
if (ObjectHelper.isNotEmpty(encoding)) {
endpoint.setEncoding(encoding);
}
endpoint.setContentCache(cache);
endpoint.setConfiguration(config);
endpoint.setTemplateUpdateDelay(templateUpdateDelay);
// if its a http resource then append any remaining parameters and update the resource uri
if (ResourceHelper.isHttpUri(remaining)) {
remaining = ResourceHelper.appendParameters(remaining, parameters);
endpoint.setResourceUri(remaining);
}
return endpoint;
}
示例3: FreemarkerTemplate
import freemarker.template.Configuration; //导入方法依赖的package包/类
public FreemarkerTemplate()
{
cfg = new Configuration();
try
{
//File cfgPath = new File(config.getConfigurationPath());
//cfg.setDirectoryForTemplateLoading( new File(cfgPath.getParent()) );
cfg.setServletContextForTemplateLoading(TernContext.getServletContext(),"/WEB-INF/views");
//cfg.setTemplateLoader(loader)
//cfg.setLocale(Locale.CHINA);
cfg.setSetting("date_format", "yyyy-MM-dd");
cfg.setSetting("time_format", "HH:mm:ss");
cfg.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss");
}
catch (Exception e)
{
cfg = null;
Trace.write(Trace.Error, e,"init freemarker failed!");
return;
}
cfg.setDefaultEncoding(config.getEncoding());
cfg.setOutputEncoding(config.getEncoding());
wrapper = new ActionDataWrapper();//ObjectWrapper.BEANS_WRAPPER;//.DEFAULT_WRAPPER;
/*wrapper = new DefaultObjectWrapper(){
public TemplateModel wrap(Object obj) throws TemplateModelException {
if(obj instanceof com.tern.dao.RecordSet){
return new freemarker.template.SimpleCollection(((com.tern.dao.RecordSet)obj).iterator(), this);
}
return super.wrap(obj);
}
};*/
cfg.setObjectWrapper(wrapper);
cfg.setTemplateExceptionHandler(new TemplateExceptionHandler(){
@Override
public void handleTemplateException(TemplateException te,
Environment env, Writer writer) throws TemplateException {
if(config.isDebug())
{
if(te.getCause() instanceof RedirectRequest)
{
throw (RedirectRequest)te.getCause();
}
TemplateExceptionHandler.HTML_DEBUG_HANDLER.handleTemplateException(te, env, writer);
}
throw te;
}
});
/*if(config.isDebug())
{
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
cfg.setTemplateUpdateDelay(0);
}
else
{
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setTemplateUpdateDelay(config.getInt("template.delay", 3600));
}*/
if(!config.isDebug())
{
cfg.setTemplateUpdateDelay(config.getInt("template.delay", 3600));
}
}