本文整理匯總了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));
}
}