當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration.setTemplateExceptionHandler方法代碼示例

本文整理匯總了Java中freemarker.template.Configuration.setTemplateExceptionHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.setTemplateExceptionHandler方法的具體用法?Java Configuration.setTemplateExceptionHandler怎麽用?Java Configuration.setTemplateExceptionHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在freemarker.template.Configuration的用法示例。


在下文中一共展示了Configuration.setTemplateExceptionHandler方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepareConfiguration

import freemarker.template.Configuration; //導入方法依賴的package包/類
private static Configuration prepareConfiguration() {
  Configuration result = new Configuration(Configuration.VERSION_2_3_26);

  result.setNumberFormat("computer");
  result.setDefaultEncoding(StandardCharsets.UTF_8.name());
  result.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  result.setLogTemplateExceptions(false);

  return result;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:11,代碼來源:TemplateProcessor.java

示例2: TemplateService

import freemarker.template.Configuration; //導入方法依賴的package包/類
public TemplateService() {

		String templatePath = new File("").getAbsolutePath();
		System.out.println("Using template path '" + templatePath + "'.");
		
		try {
			config = new Configuration(Configuration.VERSION_2_3_25);
			config.setDirectoryForTemplateLoading(new File(templatePath));
			config.setDefaultEncoding("UTF-8");
			config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			config.setLogTemplateExceptions(false);
		} catch (IOException e) {
			throw new FileLibraryException(e);
		}
		
	}
 
開發者ID:dvanherbergen,項目名稱:robotframework-filelibrary,代碼行數:17,代碼來源:TemplateService.java

示例3: init

import freemarker.template.Configuration; //導入方法依賴的package包/類
public void init() throws IOException {
    ClassTemplateLoader ctl = new ClassTemplateLoader(Application.class, "/freemarker");
    MultiTemplateLoader mtl = new MultiTemplateLoader(new TemplateLoader[] {ctl});

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setTemplateLoader(mtl);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);

    Pair<String, Template> clusterResourceQuota = new ImmutablePair<String, Template>("ClusterResourceQuota-ForUser", cfg.getTemplate("ClusterResourceQuota-ForUser.ftlh"));
    Pair<String, Template> bestEffortResourceLimits = new ImmutablePair<String, Template>("LimitRange-BestEffortResourceLimits", cfg.getTemplate("LimitRange-BestEffortResourceLimits.ftlh"));
    Pair<String, Template> burstableResourceLimits = new ImmutablePair<String, Template>("LimitRange-BurstableResourceLimits", cfg.getTemplate("LimitRange-BurstableResourceLimits.ftlh"));
    Pair<String, Template> maxImageCounts = new ImmutablePair<String, Template>("LimitRange-MaxImageCounts", cfg.getTemplate("LimitRange-MaxImageCounts.ftlh"));
    Pair<String, Template> bestEffort = new ImmutablePair<String, Template>("ResourceQuota-BestEffort", cfg.getTemplate("ResourceQuota-BestEffort.ftlh"));
    Pair<String, Template> notTerminatingAndNotBestEffort = new ImmutablePair<String, Template>("ResourceQuota-NotTerminating-And-NotBestEffort",
                                                                              cfg.getTemplate("ResourceQuota-NotTerminating-And-NotBestEffort.ftlh"));
    Pair<String, Template> terminating = new ImmutablePair<String, Template>("ResourceQuota-Terminating", cfg.getTemplate("ResourceQuota-Terminating.ftlh"));

    templates = Arrays.asList(clusterResourceQuota, bestEffortResourceLimits, burstableResourceLimits, maxImageCounts, bestEffort, notTerminatingAndNotBestEffort, terminating);
}
 
開發者ID:garethahealy,項目名稱:quota-limits-generator,代碼行數:22,代碼來源:YamlTemplateProcessor.java

示例4: initializeConfiguration

import freemarker.template.Configuration; //導入方法依賴的package包/類
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
	
	Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
	customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);
	
	cfg.setCustomDateFormats(customDateFormats);
	cfg.setDateTimeFormat("@simle");

	Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);

	return cfg;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:22,代碼來源:DwFeatureModelOverviewGenerator.java

示例5: getConfigurationByClass

import freemarker.template.Configuration; //導入方法依賴的package包/類
/**
 * 根據根路徑的類,獲取配置文件
 * @author nan.li
 * @param paramClass
 * @param prefix
 * @return
 */
public static Configuration getConfigurationByClass(Class<?> paramClass, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassForTemplateLoading(paramClass, prefix);
        //等價於下麵這種方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:lnwazg,項目名稱:kit,代碼行數:28,代碼來源:FreeMkKit.java

示例6: getConfigurationByClassLoader

import freemarker.template.Configuration; //導入方法依賴的package包/類
public static Configuration getConfigurationByClassLoader(ClassLoader classLoader, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassLoaderForTemplateLoading(classLoader, prefix);
        //等價於下麵這種方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:lnwazg,項目名稱:kit,代碼行數:21,代碼來源:FreeMkKit.java

示例7: init

import freemarker.template.Configuration; //導入方法依賴的package包/類
private void init() {
	if (inited) {
		return;
	}
	lock.lock();
	try {
		if (!inited) {
			cfg = new Configuration(Configuration.VERSION_2_3_25);
			cfg.setDefaultEncoding(encode);
			cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			cfg.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(), tmplPath);
		}
	} finally {
		lock.unlock();
	}
}
 
開發者ID:kanven,項目名稱:schedule,代碼行數:17,代碼來源:TmplMarker.java

示例8: PluginStatusReportViewBuilder

import freemarker.template.Configuration; //導入方法依賴的package包/類
private PluginStatusReportViewBuilder() throws IOException {
    configuration = new Configuration(Configuration.VERSION_2_3_23);
    configuration.setTemplateLoader(new ClassTemplateLoader(getClass(), "/"));
    configuration.setDefaultEncoding("UTF-8");
    configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    configuration.setLogTemplateExceptions(false);
    configuration.setDateTimeFormat("iso");
}
 
開發者ID:gocd,項目名稱:kubernetes-elastic-agents,代碼行數:9,代碼來源:PluginStatusReportViewBuilder.java

示例9: init

import freemarker.template.Configuration; //導入方法依賴的package包/類
@PostConstruct
public void init() throws IOException {
  try {
    cfg = new Configuration(Configuration.getVersion());
    cfg.setDirectoryForTemplateLoading(new File(templateLocation));
    cfg.setDefaultEncoding(templateEncoding);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  } catch (IOException e) {
    logger.error("Problem getting rule template location." + e.getMessage());
    throw e;
  }
}
 
開發者ID:edgexfoundry,項目名稱:support-rulesengine,代碼行數:13,代碼來源:RuleCreator.java

示例10: initializeTemplateConfiguration

import freemarker.template.Configuration; //導入方法依賴的package包/類
private static Configuration initializeTemplateConfiguration() throws IOException {
  Configuration cfg = new Configuration(Configuration.getVersion());
  cfg.setDefaultEncoding("UTF-8");
  cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  cfg.setLogTemplateExceptions(false);
  return cfg;
}
 
開發者ID:tsiq,項目名稱:magic-beanstalk,代碼行數:8,代碼來源:FileGenerator.java

示例11: getStringConfig

import freemarker.template.Configuration; //導入方法依賴的package包/類
/**
 * FreeMarker configuration for loading the specified template directly from a String
 * 
 * @param path      Pseudo Path to the template
 * @param template  Template content
 * 
 * @return FreeMarker configuration
 */
protected Configuration getStringConfig(String path, String template)
{
    Configuration config = new Configuration();
    
    // setup template cache
    config.setCacheStorage(new MruCacheStorage(2, 0));
    
    // use our custom loader to load a template directly from a String
    StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
    stringTemplateLoader.putTemplate(path, template);
    config.setTemplateLoader(stringTemplateLoader);
    
    // use our custom object wrapper that can deal with QNameMap objects directly
    config.setObjectWrapper(qnameObjectWrapper);
    
    // rethrow any exception so we can deal with them
    config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    
    // set default template encoding
    if (defaultEncoding != null)
    {
        config.setDefaultEncoding(defaultEncoding);
    }
    config.setIncompatibleImprovements(new Version(2, 3, 20));
    config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
    
    return config;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:37,代碼來源:FreeMarkerProcessor.java

示例12: createFreemarkerConfiguration

import freemarker.template.Configuration; //導入方法依賴的package包/類
private static Configuration createFreemarkerConfiguration() {
    Configuration cfg = new Configuration();
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler( TemplateExceptionHandler.RETHROW_HANDLER );
    cfg.setClassForTemplateLoading( Reporter.class, "/" );
    return cfg;
}
 
開發者ID:dmn-tck,項目名稱:tck,代碼行數:8,代碼來源:Reporter.java

示例13: newFreeMarkerConfig

import freemarker.template.Configuration; //導入方法依賴的package包/類
private Configuration newFreeMarkerConfig() {
    Configuration freeMarkerConfig = new Configuration(Configuration.VERSION_2_3_24);
    freeMarkerConfig.setDefaultEncoding("UTF-8");
    freeMarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
    freeMarkerConfig
            .setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);

    return freeMarkerConfig;
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:10,代碼來源:Freemarker.java

示例14: FreeMarkerService

import freemarker.template.Configuration; //導入方法依賴的package包/類
private FreeMarkerService(Builder bulder) {
     maxOutputLength = bulder.getMaxOutputLength();
     maxThreads = bulder.getMaxThreads();
     maxQueueLength = bulder.getMaxQueueLength();
     maxTemplateExecutionTime = bulder.getMaxTemplateExecutionTime();

     int actualMaxQueueLength = maxQueueLength != null
             ? maxQueueLength
             : Math.max(
                     MIN_DEFAULT_MAX_QUEUE_LENGTH,
                     (int) (MAX_DEFAULT_MAX_QUEUE_LENGTH_MILLISECONDS / maxTemplateExecutionTime));
     ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
             maxThreads, maxThreads,
             THREAD_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS,
             new BlockingArrayQueue<Runnable>(actualMaxQueueLength));
     threadPoolExecutor.allowCoreThreadTimeOut(true);
     templateExecutor = threadPoolExecutor;

     freeMarkerConfig = new Configuration(Configuration.getVersion());
     freeMarkerConfig.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
     freeMarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
     freeMarkerConfig.setLogTemplateExceptions(false);
     freeMarkerConfig.setAttemptExceptionReporter(new AttemptExceptionReporter() {
@Override
public void report(TemplateException te, Environment env) {
	// Suppress it
}
     });
     freeMarkerConfig.setLocale(AllowedSettingValuesMaps.DEFAULT_LOCALE);
     freeMarkerConfig.setTimeZone(AllowedSettingValuesMaps.DEFAULT_TIME_ZONE);
     freeMarkerConfig.setOutputFormat(AllowedSettingValuesMaps.DEFAULT_OUTPUT_FORMAT);
     freeMarkerConfig.setOutputEncoding("UTF-8");
 }
 
開發者ID:apache,項目名稱:incubator-freemarker-online-tester,代碼行數:34,代碼來源:FreeMarkerService.java

示例15: processIndexPageTemplate

import freemarker.template.Configuration; //導入方法依賴的package包/類
private void processIndexPageTemplate(ProjectDescriptor projectDescriptor, CustomData customData) throws IOException, URISyntaxException, TemplateException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "template");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);
    Map<String, Object> root = new HashMap<String, Object>();
    root.put("project", projectDescriptor);
    root.put("customData", customData);
    Template template = cfg.getTemplate("index.ftl");
    template.process(root, new FileWriter(new File(outputDir, "index.html")));
}
 
開發者ID:gradle-guides,項目名稱:gradle-site-plugin,代碼行數:13,代碼來源:FreemarkerSiteGenerator.java


注:本文中的freemarker.template.Configuration.setTemplateExceptionHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。