本文整理汇总了Java中freemarker.template.DefaultObjectWrapperBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DefaultObjectWrapperBuilder类的具体用法?Java DefaultObjectWrapperBuilder怎么用?Java DefaultObjectWrapperBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultObjectWrapperBuilder类属于freemarker.template包,在下文中一共展示了DefaultObjectWrapperBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfigurationByClass
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的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;
}
示例2: getConfigurationByClassLoader
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的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;
}
示例3: getConfigurationByDirectory
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* 根据模板的路径,获取一个配置文件
* @author [email protected]
* @param templateLoadingPath
* @return
*/
public static Configuration getConfigurationByDirectory(File templateLoadingPath)
{
try
{
Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
//以下这两种设置方式是等价的
// configuration.setDirectoryForTemplateLoading(templateLoadingPath);
configuration.setTemplateLoader(new FileTemplateLoader(templateLoadingPath));
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;
}
示例4: main
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Project project = new Project();
Configuration cfg = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
cfg.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build());
Template temp = cfg.getTemplate("src/assemblies/eclipse_classpath.ftl");
Map<String, Object> root = new HashMap<String, Object>();
root.put("project", project);
Writer out = new FileWriter(project.getOutputDirectory() + "/eclipse_classpath");
temp.process(root, out);
out.flush();
project = new Project();
cfg = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
cfg.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build());
temp = cfg.getTemplate("src/assemblies/netbeans_classpath.ftl");
root = new HashMap<String, Object>();
root.put("project", project);
out = new FileWriter(project.getOutputDirectory() + "/netbeans_classpath");
temp.process(root, out);
out.flush();
}
示例5: showRollupEmail
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
@GET
@Timed
@Path("/rollup")
@Produces(MediaType.TEXT_HTML)
public Response showRollupEmail(@Auth Person user, @QueryParam("startDate") Long start,
@QueryParam("endDate") Long end,
@QueryParam("orgType") OrganizationType orgType,
@QueryParam("advisorOrganizationId") Integer advisorOrgId,
@QueryParam("principalOrganizationId") Integer principalOrgId,
@QueryParam("showText") @DefaultValue("false") Boolean showReportText) {
DailyRollupEmail action = new DailyRollupEmail();
action.setStartDate(new DateTime(start));
action.setEndDate(new DateTime(end));
action.setChartOrgType(orgType);
action.setAdvisorOrganizationId(advisorOrgId);
action.setPrincipalOrganizationId(principalOrgId);
Map<String,Object> context = action.execute();
context.put("serverUrl", config.getServerUrl());
context.put(AdminSettingKeys.SECURITY_BANNER_TEXT.name(), engine.getAdminSetting(AdminSettingKeys.SECURITY_BANNER_TEXT));
context.put(AdminSettingKeys.SECURITY_BANNER_COLOR.name(), engine.getAdminSetting(AdminSettingKeys.SECURITY_BANNER_COLOR));
context.put(DailyRollupEmail.SHOW_REPORT_TEXT_FLAG, showReportText);
try {
Configuration freemarkerConfig = new Configuration(Configuration.getVersion());
freemarkerConfig.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.getVersion()).build());
freemarkerConfig.loadBuiltInEncodingMap();
freemarkerConfig.setDefaultEncoding(StandardCharsets.UTF_8.name());
freemarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
freemarkerConfig.setAPIBuiltinEnabled(true);
Template temp = freemarkerConfig.getTemplate(action.getTemplateName());
StringWriter writer = new StringWriter();
temp.process(context, writer);
return Response.ok(writer.toString(), MediaType.TEXT_HTML_TYPE).build();
} catch (Exception e) {
throw new WebApplicationException(e);
}
}
示例6: AnetEmailWorker
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
public AnetEmailWorker(Handle dbHandle, AnetConfiguration config, ScheduledExecutorService scheduler) {
this.handle = dbHandle;
this.scheduler = scheduler;
this.mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
//mapper.enableDefaultTyping();
this.emailMapper = new AnetEmailMapper();
this.fromAddr = config.getEmailFromAddr();
this.serverUrl = config.getServerUrl();
instance = this;
SmtpConfiguration smtpConfig = config.getSmtp();
props = new Properties();
props.put("mail.smtp.starttls.enable", smtpConfig.getStartTls().toString());
props.put("mail.smtp.host", smtpConfig.getHostname());
props.put("mail.smtp.port", smtpConfig.getPort().toString());
auth = null;
if (smtpConfig.getUsername() != null && smtpConfig.getUsername().trim().length() > 0) {
props.put("mail.smtp.auth", "true");
auth = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(smtpConfig.getUsername(), smtpConfig.getPassword());
}
};
}
freemarkerConfig = new Configuration(Configuration.getVersion());
freemarkerConfig.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.getVersion()).build());
freemarkerConfig.loadBuiltInEncodingMap();
freemarkerConfig.setDefaultEncoding(StandardCharsets.UTF_8.name());
freemarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
freemarkerConfig.setAPIBuiltinEnabled(true);
}
示例7: createFreeMarkerConfiguration
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* Creates a new FreeMarker configuration.
* By default, it is configured as follows:
* <ul>
* <li>compatibility level is set to 2.3.23
* <li>the object wrapper is configured to expose fields
* <li>API builtins are enabled
* <li>there are 2 template loaders - 1 for loading templates from /META-INF using a classloader and a second
* one to load templates from files.
* </ul>
* @return
*/
protected Configuration createFreeMarkerConfiguration() {
DefaultObjectWrapperBuilder bld = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_23);
bld.setExposeFields(true);
Configuration freeMarker = new Configuration(Configuration.VERSION_2_3_23);
freeMarker.setObjectWrapper(bld.build());
freeMarker.setAPIBuiltinEnabled(true);
freeMarker.setTemplateLoader(new MultiTemplateLoader(
new TemplateLoader[]{new ClassTemplateLoader(getClass(), "/META-INF"),
new NaiveFileTemplateLoader()}));
return freeMarker;
}
示例8: Environment
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
private Environment() {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
// Specify the data source where the template files come from.
cfg.setClassForTemplateLoading(getClass(), "/templates/");
DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_23);
builder.setExposeFields(true);
cfg.setObjectWrapper(builder.build());
freemarkerConfig = cfg;
fmHelper = new FreeMarkerHelper();
templateCache = new ConcurrentHashMap<String, Template>();
symbols = new ConcurrentHashMap<String, String>();
textFormatter = new TextFormatter();
xmlFormatter = new XMLFormatter();
nsContext = new NamespaceContextImpl();
fillNamespaceContext();
xPathHelper = new XPathHelper();
jsonPathHelper = new JsonPathHelper();
jsonHelper = new JsonHelper();
htmlCleaner = new HtmlCleaner();
httpClient = new HttpClient();
programHelper = new ProgramHelper();
programHelper.setTimeoutHelper(timeoutHelper);
configDatesHelper();
driverManager = new DriverManager();
cookieConverter = new CookieConverter();
}
示例9: getDefaultFreemarkerConfiguration
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* Gets the default configuration for Freemarker within Windup.
*/
public static Configuration getDefaultFreemarkerConfiguration()
{
freemarker.template.Configuration configuration = new freemarker.template.Configuration(Configuration.VERSION_2_3_26);
DefaultObjectWrapperBuilder objectWrapperBuilder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_26);
objectWrapperBuilder.setUseAdaptersForContainers(true);
objectWrapperBuilder.setIterableSupport(true);
configuration.setObjectWrapper(objectWrapperBuilder.build());
configuration.setAPIBuiltinEnabled(true);
configuration.setTemplateLoader(new FurnaceFreeMarkerTemplateLoader());
configuration.setTemplateUpdateDelayMilliseconds(3600);
return configuration;
}
示例10: FreemarkerTemplate
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
public FreemarkerTemplate() {
configuration = new Configuration(Configuration.VERSION_2_3_23);
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_23).build());
}