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


Java Configuration.setCacheStorage方法代碼示例

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


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

示例1: 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

示例2: createConfig

import freemarker.template.Configuration; //導入方法依賴的package包/類
private Configuration createConfig(){
    Configuration config = new Configuration(new Version(2, 3, 23));
    config.setDefaultEncoding("UTF-8");
    config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    config.setCacheStorage(NullCacheStorage.INSTANCE);
    return config;
}
 
開發者ID:automate-website,項目名稱:jwebrobot,代碼行數:8,代碼來源:FreemarkerExpressionEvaluator.java

示例3: main

import freemarker.template.Configuration; //導入方法依賴的package包/類
public static void main( String[] args )
{
    CommandLineOptions options = new CommandLineOptions();
    new JCommander(options, args);

    logger.finest("Options.debug = " + options.debug);
    logger.finest("Options.servicePort = " + options.servicePort);

    port(options.servicePort);

    FreeMarkerEngine freeMarkerEngine = new FreeMarkerEngine();
    Configuration freeMarkerConfiguration = new Configuration();
    freeMarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(App.class, "/"));

    if (options.debug) {
        freeMarkerConfiguration.setCacheStorage(new NullCacheStorage());

        WebpackThread.run();
    }

    freeMarkerEngine.setConfiguration(freeMarkerConfiguration);

    if (options.debug) {
        String projectDir = System.getProperty("user.dir");
        String staticDir = "/src/main/frontend/public";

        staticFiles.externalLocation(projectDir + staticDir);
    } else {
        staticFileLocation("/public");
    }

    get("/", (request, response) -> {
        if (shouldReturnHtml(request)) {
            response.status(200);
            response.type("text/html");
            Map<String, Object> attributes = new HashMap<>();
            return freeMarkerEngine.render(new ModelAndView(attributes, "index.ftl"));
        } else {
            response.status(200);
            response.type("application/json");
            return dataToJson(null);
        }
    });

    get("/alive", (request, response) -> "ok");
}
 
開發者ID:viatsko,項目名稱:react-redux-spark-boilerplate,代碼行數:47,代碼來源:App.java


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