當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。