• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Jade4J类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.neuland.jade4j.Jade4J的典型用法代码示例。如果您正苦于以下问题:Java Jade4J类的具体用法?Java Jade4J怎么用?Java Jade4J使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: prepareTaskMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareTaskMail(Optional<SingularityTask> task, SingularityTaskId taskId, SingularityRequest request, SingularityEmailType emailType, Map<String, Object> extraProperties,
    Collection<SingularityTaskHistoryUpdate> taskHistory, ExtendedTaskState taskState, List<SingularityTaskMetadata> taskMetadata) {
  final Collection<SingularityEmailDestination> emailDestination = getDestination(request, emailType);

  final Map<String, Object> templateProperties = Maps.newHashMap();
  populateRequestEmailProperties(templateProperties, request);
  populateTaskEmailProperties(templateProperties, taskId, taskHistory, taskState, taskMetadata);
  templateProperties.putAll(extraProperties);

  final String subject = mailTemplateHelpers.getSubjectForTaskHistory(taskId, taskState, emailType, taskHistory);

  final String adminEmails = adminJoiner.join(maybeSmtpConfiguration.get().getAdmins());
  templateProperties.put("adminEmails", adminEmails);

  final String body = Jade4J.render(taskTemplate, templateProperties);

  final Optional<String> user = task.isPresent() ? task.get().getTaskRequest().getPendingTask().getUser() : Optional.<String> absent();

  queueMail(emailDestination, request, emailType, user, subject, body);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:SingularityMailer.java


示例2: prepareRequestInCooldownMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareRequestInCooldownMail(SingularityRequest request) {
  final List<SingularityEmailDestination> emailDestination = getDestination(request, SingularityEmailType.REQUEST_IN_COOLDOWN);

  if (emailDestination.isEmpty()) {
    LOG.debug("Not configured to send request cooldown mail for");
    return;
  }

  final Map<String, Object> templateProperties = Maps.newHashMap();
  populateRequestEmailProperties(templateProperties, request);

  final String subject = String.format("Request %s has entered system cooldown — Singularity", request.getId());

  templateProperties.put("numFailures", configuration.getCooldownAfterFailures());
  templateProperties.put("cooldownDelayFormat", DurationFormatUtils.formatDurationHMS(TimeUnit.SECONDS.toMillis(configuration.getCooldownMinScheduleSeconds())));
  templateProperties.put("cooldownExpiresFormat", DurationFormatUtils.formatDurationHMS(TimeUnit.MINUTES.toMillis(configuration.getCooldownExpiresAfterMinutes())));

  final String body = Jade4J.render(requestInCooldownTemplate, templateProperties);

  queueMail(emailDestination, request, SingularityEmailType.REQUEST_IN_COOLDOWN, Optional.<String> absent(), subject, body);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:SingularityMailer.java


示例3: toHtmlString

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
public String toHtmlString(String generatedHtml) {
	Map<String, Object> model = new HashMap<String, Object>();
	model.put("filename", filename);
	model.put("linenumber", lineNumber);
	model.put("message", getMessage());
	model.put("lines", getTemplateLines());
	model.put("exception", getName());
	if (generatedHtml != null) {
		model.put("html", generatedHtml);
	}

	try {
		URL url = JadeException.class.getResource("/error.jade");
		return Jade4J.render(url, model, true);
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:eamonfoy,项目名称:trello-to-markdown,代码行数:20,代码来源:JadeException.java


示例4: prepareTaskMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareTaskMail(Optional<SingularityTask> task, SingularityTaskId taskId, SingularityRequest request, SingularityEmailType emailType, Map<String, Object> extraProperties,
                             Collection<SingularityTaskHistoryUpdate> taskHistory, ExtendedTaskState taskState, List<SingularityTaskMetadata> taskMetadata) {
  final Collection<SingularityEmailDestination> emailDestination = getDestination(request, emailType);

  final Map<String, Object> templateProperties = Maps.newHashMap();
  populateRequestEmailProperties(templateProperties, request, emailType);
  populateTaskEmailProperties(templateProperties, taskId, taskHistory, taskState, taskMetadata, emailType);
  templateProperties.putAll(extraProperties);

  final String subject = mailTemplateHelpers.getSubjectForTaskHistory(taskId, taskState, emailType, taskHistory);

  final String adminEmails = adminJoiner.join(smtpConfiguration.getAdmins());
  templateProperties.put("adminEmails", adminEmails);

  final String body = Jade4J.render(taskTemplate, templateProperties);

  final Optional<String> user = task.isPresent() ? task.get().getTaskRequest().getPendingTask().getUser() : Optional.<String> absent();

  queueMail(emailDestination, request, emailType, user, subject, body);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:21,代码来源:SmtpMailer.java


示例5: prepareRequestInCooldownMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareRequestInCooldownMail(SingularityRequest request) {
  final List<SingularityEmailDestination> emailDestination = getDestination(request, SingularityEmailType.REQUEST_IN_COOLDOWN);

  if (emailDestination.isEmpty()) {
    LOG.debug("Not configured to send request cooldown mail for {}", request);
    return;
  }

  final Map<String, Object> templateProperties = Maps.newHashMap();
  populateRequestEmailProperties(templateProperties, request, SingularityEmailType.REQUEST_IN_COOLDOWN);

  final String subject = String.format("Request %s has entered system cooldown — Singularity", request.getId());

  templateProperties.put("numFailures", configuration.getCooldownAfterFailures());
  templateProperties.put("cooldownDelayFormat", DurationFormatUtils.formatDurationHMS(TimeUnit.SECONDS.toMillis(configuration.getCooldownMinScheduleSeconds())));
  templateProperties.put("cooldownExpiresFormat", DurationFormatUtils.formatDurationHMS(TimeUnit.MINUTES.toMillis(configuration.getCooldownExpiresAfterMinutes())));

  final String body = Jade4J.render(requestInCooldownTemplate, templateProperties);

  queueMail(emailDestination, request, SingularityEmailType.REQUEST_IN_COOLDOWN, Optional.<String> absent(), subject, body);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:22,代码来源:SmtpMailer.java


示例6: prepareDisasterMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareDisasterMail(final SingularityDisastersData disastersData) {
  final List<SingularityEmailDestination> emailDestination = configuration.getSmtpConfigurationOptional().get().getEmailConfiguration().get(SingularityEmailType.DISASTER_DETECTED);
  if (emailDestination.isEmpty() || !emailDestination.contains(SingularityEmailDestination.ADMINS) || smtpConfiguration.getAdmins().isEmpty()) {
    LOG.info("Not configured to send disaster detected mail");
    return;
  }

  final List<String> toList = smtpConfiguration.getAdmins();
  final List<String> ccList = Lists.newArrayList();
  final String subject = String.format("Disaster(s) Detected %s", disastersData.getDisasters());

  final Map<String, Object> templateProperties = Maps.newHashMap();

  templateProperties.put("disasterTypes", disastersData.getDisasters());
  templateProperties.put("stats", mailTemplateHelpers.getJadeDisasterStats(disastersData.getStats()));

  final String body = Jade4J.render(disastersTemplate, templateProperties);

  smtpSender.queueMail(toList, ccList, subject, body);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:21,代码来源:SmtpMailer.java


示例7: JadeTemplateEngine

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
public JadeTemplateEngine(final CompositeConfiguration config, final ContentStore db, final File destination, final File templatesPath) {
    super(config, db, destination, templatesPath);

    TemplateLoader loader = new FileTemplateLoader(templatesPath.getAbsolutePath() + File.separatorChar, config.getString(Keys.TEMPLATE_ENCODING));
    jadeConfiguration.setTemplateLoader(loader);
    jadeConfiguration.setMode(Jade4J.Mode.XHTML);
    jadeConfiguration.setPrettyPrint(true);
    jadeConfiguration.setFilter(FILTER_CDATA, new CDATAFilter());
    jadeConfiguration.setFilter(FILTER_SCRIPT, new JsFilter());
    jadeConfiguration.setFilter(FILTER_STYLE, new CssFilter());
    jadeConfiguration.getSharedVariables().put("formatter", new FormatHelper());
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:13,代码来源:JadeTemplateEngine.java


示例8: prepareRequestMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareRequestMail(SingularityRequest request, RequestMailType type, Optional<String> user, Optional<String> message, Optional<Map<String, Object>> additionalProperties) {
  final List<SingularityEmailDestination> emailDestination = getDestination(request, type.getEmailType());

  if (emailDestination.isEmpty()) {
    LOG.debug("Not configured to send request cooldown mail for");
    return;
  }

  final String subject = String.format("Request %s has been %s — Singularity", request.getId(), type.name().toLowerCase());
  final Map<String, Object> templateProperties = Maps.newHashMap();
  populateRequestEmailProperties(templateProperties, request);

  templateProperties.put("expiring", Boolean.FALSE);
  templateProperties.put("requestPaused", type == RequestMailType.PAUSED);
  templateProperties.put("requestUnpaused", type == RequestMailType.UNPAUSED);
  templateProperties.put("requestScaled", type == RequestMailType.SCALED);
  templateProperties.put("action", type.name().toLowerCase());
  templateProperties.put("hasUser", user.isPresent());
  templateProperties.put("hasMessage", message.isPresent());

  if (user.isPresent()) {
    templateProperties.put("user", user.get());
  }

  if (message.isPresent()) {
    templateProperties.put("message", message.get());
  }

  if (additionalProperties.isPresent()) {
    templateProperties.putAll(additionalProperties.get());
  }

  final String body = Jade4J.render(requestModifiedTemplate, templateProperties);

  queueMail(emailDestination, request, type.getEmailType(), user, subject, body);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:37,代码来源:SingularityMailer.java


示例9: contextLoads

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
@Test
public void contextLoads() throws Exception {
	String source = "div Hello #{arg}!";
	Map<String, Object> context = new HashMap<String, Object>();
	context.put("arg", "world");
	assertEquals("<div>Hello world!</div>", Jade4J.render(new StringReader(source), "teste.jade", context)); 
}
 
开发者ID:marlonbernardes,项目名称:spring-boot-jade,代码行数:8,代码来源:ApplicationTests.java


示例10: doGet

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	resp.setContentType("text/html; charset=UTF-8");

	if (StringUtil.countHappens('.', req.getServerName()) == 1) {
		resp.sendRedirect("http://www." + req.getServerName()); // Fix ui-sref urls
		return;
	}
	
	String requestURI = req.getRequestURI();
	if (requestURI.equals("/")) {
		requestURI = "/spa.jade";
	}
	File file = new File(webLoc + "/spa" + requestURI);
	
	if (!file.exists()) {
		resp.sendRedirect("/#!" + requestURI.replaceFirst("/$", "")); // Fix ui-sref urls
		return;
	}
	
	JadeTemplate template = Jade4J.getTemplate(file.getPath());
	if ("/spa.jade".equals(requestURI)) {
		StringWriter buffer = new StringWriter();
		template.process(new JadeModel(Cols.map(
				"version", version
				)), buffer);

		String target = "<!--spa-js-->";
		
		String scriptLocations = allJs();
		
		String content = buffer.toString();
		resp.getWriter().write(
				StringUtil.replace(scriptLocations, Range.fromlength(content.indexOf(target), target.length()), content)
		);
	} else {
		template.process(new JadeModel(null), resp.getWriter());
	}
}
 
开发者ID:quanla,项目名称:classreloading,代码行数:41,代码来源:JadeServlet.java


示例11: defaultJadeConfiguration

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
@Bean
public JadeConfiguration defaultJadeConfiguration() {
  JadeConfiguration configuration = new JadeConfiguration();
  configuration.setCaching(this.environment.getProperty("caching", Boolean.class, true));
  configuration.setTemplateLoader(defaultSpringTemplateLoader());
  configuration.setPrettyPrint(this.environment.getProperty("prettyPrint", Boolean.class, false));
  configuration.setMode(this.environment.getProperty("mode", Jade4J.Mode.class, Jade4J.Mode.HTML));
  return configuration;
}
 
开发者ID:domix,项目名称:spring-boot-starter-jade4j,代码行数:10,代码来源:Jade4JAutoConfiguration.java


示例12: prepareRequestMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private void prepareRequestMail(SingularityRequest request, RequestMailType type, Optional<String> user, Optional<String> message, Optional<Map<String, Object>> additionalProperties) {
  final List<SingularityEmailDestination> emailDestination = getDestination(request, type.getEmailType());

  if (emailDestination.isEmpty()) {
    LOG.debug("Not configured to send request mail for {}", request);
    return;
  }

  final String subject = String.format("Request %s has been %s — Singularity", request.getId(), type.name().toLowerCase());
  final Map<String, Object> templateProperties = Maps.newHashMap();
  populateRequestEmailProperties(templateProperties, request, type.getEmailType());

  templateProperties.put("expiring", Boolean.FALSE);
  templateProperties.put("requestPaused", type == RequestMailType.PAUSED);
  templateProperties.put("requestUnpaused", type == RequestMailType.UNPAUSED);
  templateProperties.put("requestScaled", type == RequestMailType.SCALED);
  templateProperties.put("action", type.name().toLowerCase());
  templateProperties.put("hasUser", user.isPresent());
  templateProperties.put("hasMessage", message.isPresent());

  if (user.isPresent()) {
    templateProperties.put("user", user.get());
  }

  if (message.isPresent()) {
    templateProperties.put("message", message.get());
  }

  if (additionalProperties.isPresent()) {
    templateProperties.putAll(additionalProperties.get());
  }

  final String body = Jade4J.render(requestModifiedTemplate, templateProperties);

  queueMail(emailDestination, request, type.getEmailType(), user, subject, body);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:37,代码来源:SmtpMailer.java


示例13: queueMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
/**
 * Check to see if email should be rate limited, and if so, send a rate limit
 * email notification. Next attempt to email will immediately return.
 *
 * @param destination collection of enum values used to specify who will receive this email.
 * @param request SingularityRequest this email is about.
 * @param emailType what the email is about (e.g. TASK_FAILED).
 * @param actionTaker the user taking the action
 * @param subject the subject line of the email.
 * @param body the body of the email.
 */
private void queueMail(final Collection<SingularityEmailDestination> destination, final SingularityRequest request, final SingularityEmailType emailType, final Optional<String> actionTaker, String subject, String body) {
  RateLimitResult result = checkRateLimitForMail(request, emailType);

  if (result == RateLimitResult.DONT_SEND_MAIL_IN_COOLDOWN) {
    return;
  }

  if (result == RateLimitResult.SEND_COOLDOWN_STARTED_MAIL) {
    subject = String.format("%s notifications for %s are being rate limited", emailType.name(), request.getId());
    body = Jade4J.render(rateLimitedTemplate, getRateLimitTemplateProperties(request, emailType));
  }

  final List<String> toList = Lists.newArrayList();
  final List<String> ccList = Lists.newArrayList();

  // Decide where to send this email.
  if (destination.contains(SingularityEmailDestination.OWNERS) && request.getOwners().isPresent() && !request.getOwners().get().isEmpty()) {
    toList.addAll(request.getOwners().get());
  }

  if (destination.contains(SingularityEmailDestination.ADMINS) && !maybeSmtpConfiguration.get().getAdmins().isEmpty()) {
    if (toList.isEmpty()) {
      toList.addAll(maybeSmtpConfiguration.get().getAdmins());
    } else {
      ccList.addAll(maybeSmtpConfiguration.get().getAdmins());
    }
  }

  if (actionTaker.isPresent() && !Strings.isNullOrEmpty(actionTaker.get())) {
    if (destination.contains(SingularityEmailDestination.ACTION_TAKER)) {
      toList.add(actionTaker.get());
    } else {
      final Iterator<String> i = toList.iterator();
      while (i.hasNext()) {
        if (actionTaker.get().equalsIgnoreCase(i.next())) {
          i.remove();
        }
      }
    }
  }

  smtpSender.queueMail(toList, ccList, subject, body);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:55,代码来源:SingularityMailer.java


示例14: render

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
private Buffer render() {
    JsonObject model = new JsonObject()
            .put(BENCHMARKS, baseline(reorder(results)))
            .put(VERSION, new LauncherSettings().getVersion());
    return Buffer.buffer(Jade4J.render(getTemplate(), model.getMap(), true));
}
 
开发者ID:codingchili,项目名称:chili-core,代码行数:7,代码来源:BenchmarkHTMLReport.java


示例15: queueMail

import de.neuland.jade4j.Jade4J; //导入依赖的package包/类
/**
 * Check to see if email should be rate limited, and if so, send a rate limit
 * email notification. Next attempt to email will immediately return.
 *
 * @param destination collection of enum values used to specify who will receive this email.
 * @param request SingularityRequest this email is about.
 * @param emailType what the email is about (e.g. TASK_FAILED).
 * @param actionTaker the user taking the action
 * @param subject the subject line of the email.
 * @param body the body of the email.
 */
private void queueMail(final Collection<SingularityEmailDestination> destination, final SingularityRequest request, final SingularityEmailType emailType, final Optional<String> actionTaker, String subject, String body) {
  RateLimitResult result = checkRateLimitForMail(request, emailType);

  if (result == RateLimitResult.DONT_SEND_MAIL_IN_COOLDOWN) {
    return;
  }

  if (result == RateLimitResult.SEND_COOLDOWN_STARTED_MAIL) {
    subject = String.format("%s notifications for %s are being rate limited", emailType.name(), request.getId());
    body = Jade4J.render(rateLimitedTemplate, getRateLimitTemplateProperties(request, emailType));
  }

  final List<String> toList = Lists.newArrayList();
  final List<String> ccList = Lists.newArrayList();

  // Decide where to send this email.
  if (destination.contains(SingularityEmailDestination.OWNERS) && request.getOwners().isPresent() && !request.getOwners().get().isEmpty()) {
    toList.addAll(request.getOwners().get());
  }

  if (destination.contains(SingularityEmailDestination.ADMINS) && !smtpConfiguration.getAdmins().isEmpty()) {
    if (toList.isEmpty()) {
      toList.addAll(smtpConfiguration.getAdmins());
    } else {
      ccList.addAll(smtpConfiguration.getAdmins());
    }
  }

  if (actionTaker.isPresent() && !Strings.isNullOrEmpty(actionTaker.get())) {
    if (destination.contains(SingularityEmailDestination.ACTION_TAKER)) {
      toList.add(actionTaker.get());
    } else {
      final Iterator<String> i = toList.iterator();
      while (i.hasNext()) {
        if (actionTaker.get().equalsIgnoreCase(i.next())) {
          i.remove();
        }
      }
    }
  }

  smtpSender.queueMail(toList, ccList, subject, body);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:55,代码来源:SmtpMailer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RedisOperationsSessionRepository类代码示例发布时间:2022-05-22
下一篇:
Java Serde类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap