当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.VERSION_2_3_22属性代码示例

本文整理汇总了Java中freemarker.template.Configuration.VERSION_2_3_22属性的典型用法代码示例。如果您正苦于以下问题:Java Configuration.VERSION_2_3_22属性的具体用法?Java Configuration.VERSION_2_3_22怎么用?Java Configuration.VERSION_2_3_22使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在freemarker.template.Configuration的用法示例。


在下文中一共展示了Configuration.VERSION_2_3_22属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

public void render(String modelType) throws IOException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setClassLoaderForTemplateLoading(SimpleModel.class.getClassLoader(), "/");
    if (!outDir.getParentFile().exists())
        outDir.getParentFile().mkdirs();
    String modelTypeName = modelType.substring(0, 1).toUpperCase() + modelType.substring(1);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("packageName", packageName);
    params.put("models", models);
    writeFile(packageName, modelTypeName, getTemplate(cfg, modelType), params);

    for (SimpleModel model : models) {
        if (model.isRender()) {
            params = new HashMap<>();
            params.put("model", model);
            writeFile(model.getPackageName(), model.getName(), getModelTemplate(cfg), params);
        }
    }
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:21,代码来源:Context.java

示例2: NexuDeployScriptController

public NexuDeployScriptController() {
	try {
		Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
		cfg.setClassForTemplateLoading(getClass(), "/");
		this.template = cfg.getTemplate("nexu_deploy.ftl.js", "UTF-8");
	} catch (IOException e) {
		throw new RuntimeException();
	}
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:9,代码来源:NexuDeployScriptController.java

示例3: render

public void render() throws IOException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "/");
    renderPersistence(cfg);
    renderContentProvider(cfg);
    renderDbHelper(cfg);
    renderModels(cfg);
    renderMappers(cfg);
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:11,代码来源:DbContext.java

示例4: init

@PostConstruct
public void init()
{
  Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
  
  cfg.setDefaultEncoding("UTF-8");
  
  String templatePath = _config.get("view.freemarker.templates",
                                   "classpath:/templates");
  
  ClassLoader loader = Thread.currentThread().getContextClassLoader();
  
  if (templatePath.startsWith("classpath:")) {
    String path = templatePath.substring(("classpath:").length());
    
    cfg.setClassLoaderForTemplateLoading(loader, path);
  }
  else {
    throw new UnsupportedOperationException();
  }
  
  cfg.setAutoFlush(false);
  
  cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
  
  _cfg = cfg;
}
 
开发者ID:baratine,项目名称:baratine,代码行数:27,代码来源:ViewFreemarker.java

示例5: FreemarkerConfiguration

@Inject
public FreemarkerConfiguration() throws Exception {
    configuration = new Configuration(Configuration.VERSION_2_3_22);
    configuration.setDirectoryForTemplateLoading(new File(TEMPLATES_DIRECTORY));
    configuration.setDefaultEncoding("UTF-8");
    configuration.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
}
 
开发者ID:mrtenda,项目名称:HawkEye,代码行数:7,代码来源:FreemarkerConfiguration.java

示例6: sendMail

@Async
@Override
public void sendMail(String to, Map<String, String> parameters, String template, String subject) {
    log.debug("sendMail() - to: " + to);
    MimeMessage message = mailSender.createMimeMessage();
    try {
        String stringDir = MailServiceImpl.class.getResource("/templates/freemarker").getPath();
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
        cfg.setDefaultEncoding("UTF-8");

        File dir = new File(stringDir);
        cfg.setDirectoryForTemplateLoading(dir);
        cfg.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_22));

        StringBuffer content = new StringBuffer();
        Template temp = cfg.getTemplate(template + ".ftl");
        content.append(FreeMarkerTemplateUtils.processTemplateIntoString(temp, parameters));

        MimeBodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setContent(content.toString(), "text/html;charset=\"UTF-8\"");

        MimeMultipart multipart = new MimeMultipart("related");
        multipart.addBodyPart(messageBodyPart);

        message.setContent(multipart);
        message.setFrom(new InternetAddress(platformMailConfigurationProperties.getUser().getUsername(), platformMailConfigurationProperties.getUser().getName()));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject(subject);
        mailSender.send(message);

        log.info("Message has been sent to: " + to);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:abixen,项目名称:abixen-platform,代码行数:35,代码来源:MailServiceImpl.java

示例7: FreeMarkerRender

public FreeMarkerRender(String template, String templateName)
		throws IOException {
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
	this.t = new Template(templateName, template, cfg);
}
 
开发者ID:DTStack,项目名称:jlogstash,代码行数:5,代码来源:FreeMarkerRender.java

示例8: renderModelBindings

void renderModelBindings() throws Exception {
    if (bindings.size() == 0 && allModels.size() == 0)
        return;
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "/");

    Template bindingTemplate = cfg.getTemplate("templates/java/binding.ftl");
    for (IntentBinding binding : bindings) {
        String name = (binding.getPackageName() != null ? binding.getPackageName() + "." : "")
                + binding.getName() + "Binding";
        JavaFileObject file = this.processingEnv.getFiler()
                .createSourceFile(name, binding.getElement());
        Writer writer = file.openWriter();
        try {
            Map<String, Object> model = new HashMap<>();
            model.put("binding", binding);
            model.put("cyto", "true".equals(processingEnv.getOptions().get(UI)));
            bindingTemplate.process(model, writer);
            writer.flush();
        } catch (TemplateException err) {
            throw new IOException(err);
        }
        writer.close();
    }

    if (allModels.size() > 0) {
        Element[] elements = new Element[allModels.size()];
        int ix = 0;
        for (SimpleModel simpleModel : allModels.values()) {
            elements[ix++] = simpleModel.getElement();
            if (simpleModel instanceof ArrayModel) {
                ArrayModel arrayModel = (ArrayModel) simpleModel;
                if (arrayModel.getModel() == null)
                    ((ArrayModel) simpleModel).setModel(allModels.get(arrayModel.getModelId()));
                continue;
            }
            if (simpleModel.getParentId() != null && simpleModel.getParent() == null) {
                simpleModel.setParent(allModels.get(simpleModel.getParentId()));
                simpleModel.getProperties().addAll(simpleModel.getParent().getProperties());
            }
            for (Property property : simpleModel.getProperties()) {
                if (property.getModelId() != null) {
                    property.setModel(allModels.get(property.getModelId()));
                    if (property.getModel() == null)
                        throw new Exception("Model (" + property.getModelId() + ") not found");
                }
            }
        }

        String modelTypes = processingEnv.getOptions().get(MODEL_TYPES);
        if (modelTypes != null) {
            for (String modelType : modelTypes.split(",")) {
                String packageName = processingEnv.getOptions().get(DEFAULT_PACKAGE);
                if (packageName == null)
                    packageName = "nuclei.data";
                Context context = new Context(allModels.values(), packageName, null);
                context.render(cfg, modelType, processingEnv.getFiler());
            }
        }
    }
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:63,代码来源:AptProcessor.java


注:本文中的freemarker.template.Configuration.VERSION_2_3_22属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。