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


Java Configuration.setClassForTemplateLoading方法代码示例

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


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

示例1: buildToOutputStream

import freemarker.template.Configuration; //导入方法依赖的package包/类
public void buildToOutputStream(Class<?> commonServiceClass, OutputStream os) throws Exception {
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(ThriftFileBuilder.class, "/");
	Template template = cfg.getTemplate("templates/thrift/thrift.ftl");
	Writer out = new OutputStreamWriter(os);

	ThriftServiceBuilder serviceBuilder = new ThriftServiceBuilder(commonServiceClass);
	ThriftService service = serviceBuilder.buildThriftService();

	Map<String, Object> rootMap = new HashMap<String, Object>();
	rootMap.put("thriftServicePackage", this.getPackageName(commonServiceClass));
	List<ThriftStruct> structs = serviceBuilder.getStructs();
	List<ThriftEnum> enums = serviceBuilder.getEnums();
	CommonUtils.removeRepeat(structs);
	rootMap.put("structList", structs);
	rootMap.put("enumList", enums);
	CommonUtils.removeRepeat(enums);
	rootMap.put("serviceList", Arrays.asList(service));

	template.process(rootMap, out);
}
 
开发者ID:funtl,项目名称:framework,代码行数:22,代码来源:ThriftFileBuilder.java

示例2: initializeConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
	
	Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
	customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);
	
	cfg.setCustomDateFormats(customDateFormats);
	cfg.setDateTimeFormat("@simle");

	Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);

	return cfg;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:22,代码来源:DwFeatureModelOverviewGenerator.java

示例3: DaoGenerator

import freemarker.template.Configuration; //导入方法依赖的package包/类
public DaoGenerator() throws IOException {
    System.out.println("greenDAO Generator");
    System.out.println("Copyright 2011-2016 Markus Junginger, greenrobot.de. Licensed under GPL V3.");
    System.out.println("This program comes with ABSOLUTELY NO WARRANTY");

    patternKeepIncludes = compilePattern("INCLUDES");
    patternKeepFields = compilePattern("FIELDS");
    patternKeepMethods = compilePattern("METHODS");

    Configuration config = new Configuration(Configuration.VERSION_2_3_23);
    config.setClassForTemplateLoading(this.getClass(), "/");

    templateDao = config.getTemplate("dao.ftl");
    templateDaoMaster = config.getTemplate("dao-master.ftl");
    templateDaoSession = config.getTemplate("dao-session.ftl");
    templateEntity = config.getTemplate("entity.ftl");
    templateDaoUnitTest = config.getTemplate("dao-unit-test.ftl");
    templateContentProvider = config.getTemplate("content-provider.ftl");
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:20,代码来源:DaoGenerator.java

示例4: initializeConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
/**
 * Configures freemarker for usage.
 * @return
 * @throws URISyntaxException
 * @throws TemplateNotFoundException
 * @throws MalformedTemplateNameException
 * @throws ParseException
 * @throws IOException
 * @throws TemplateException
 */
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

	Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);
	
	Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();

	customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE);

	cfg.setCustomNumberFormats(customNumberFormats);

	return cfg;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:32,代码来源:DwFeatureModelSVGGenerator.java

示例5: getConfigurationByClass

import freemarker.template.Configuration; //导入方法依赖的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;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:28,代码来源:FreeMkKit.java

示例6: NexuDeployScriptController

import freemarker.template.Configuration; //导入方法依赖的package包/类
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,代码行数:10,代码来源:NexuDeployScriptController.java

示例7: generateDefaultDockerrunFile

import freemarker.template.Configuration; //导入方法依赖的package包/类
/**
 *Generate a dockerrun.aws.json file with the default template
 * @param outputFilePath the output directory
 * @param parameters a map to hydrate the default template with
 * @throws IOException if failed to load the template file
 * @throws TemplateException if template generation fails
 */
public static void generateDefaultDockerrunFile(
    String outputFilePath,
    Map<String, Object> parameters
) throws IOException, TemplateException {
  Configuration cfg = initializeTemplateConfiguration();
  cfg.setClassForTemplateLoading(FileGenerator.class, "/");
  final String defaultDockerrunTemplateFile = "DockerrunTemplate.ftlh";
  generateFileFromTemplate(cfg, defaultDockerrunTemplateFile, outputFilePath, parameters);
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:17,代码来源:FileGenerator.java

示例8: createFreemarkerConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
private static Configuration createFreemarkerConfiguration() {
    Configuration cfg = new Configuration();
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler( TemplateExceptionHandler.RETHROW_HANDLER );
    cfg.setClassForTemplateLoading( Reporter.class, "/" );
    return cfg;
}
 
开发者ID:dmn-tck,项目名称:tck,代码行数:8,代码来源:Reporter.java

示例9: getTemplate

import freemarker.template.Configuration; //导入方法依赖的package包/类
protected Template getTemplate(String tmplFileName)
		throws IOException {
	Configuration cfg = new Configuration();
	cfg.setEncoding(DEFAULT_LOCALE, DEFAULT_ENCODING);
	this.logger.debug("reading ftl " + tmplFileName
			+ " from class path " + freemarkerTemplateDefaultFilePath);
	cfg.setClassForTemplateLoading(this.getClass(),
			freemarkerTemplateDefaultFilePath);
	Template tmpl = cfg.getTemplate(tmplFileName);
	tmpl.setEncoding(DEFAULT_ENCODING);
	return tmpl;
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:13,代码来源:FreemarkerWriter.java

示例10: message

import freemarker.template.Configuration; //导入方法依赖的package包/类
private String message() throws IOException, TemplateException {
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
	cfg.setClassForTemplateLoading(EventEmail.class, "");
	cfg.setLocale(Localization.getJavaLocale());
	cfg.setOutputEncoding("utf-8");
	Template template = cfg.getTemplate("confirmation.ftl");
	Map<String, Object> input = new HashMap<String, Object>();
	input.put("msg", MESSAGES);
	input.put("const", CONSTANTS);
	input.put("subject", subject());
	input.put("event", event());
	input.put("operation", request().getOperation() == null ? "NONE" : request().getOperation().name());
	if (response().hasCreatedMeetings())
		input.put("created", EventInterface.getMultiMeetings(response().getCreatedMeetings(), true, false));
	if (response().hasDeletedMeetings())
		input.put("deleted", EventInterface.getMultiMeetings(response().getDeletedMeetings(), true, false));
	if (response().hasCancelledMeetings())
		input.put("cancelled", EventInterface.getMultiMeetings(response().getCancelledMeetings(), true, false));
	if (response().hasUpdatedMeetings())
		input.put("updated", EventInterface.getMultiMeetings(response().getUpdatedMeetings(), true, false));
	if (request().hasMessage())
		input.put("message", request().getMessage());
	if (request().getEvent().getId() != null) {
		if (event().hasMeetings()) {
			input.put("meetings", EventInterface.getMultiMeetings(event().getMeetings(), true, false));
		} else
			input.put("meetings", new TreeSet<MultiMeetingInterface>());
	}
	input.put("version", MESSAGES.pageVersion(Constants.getVersion(), Constants.getReleaseDate()));
	input.put("ts", new Date());
	input.put("link", ApplicationProperty.UniTimeUrl.value());
	input.put("sessionId", iRequest.getSessionId());
	
	StringWriter s = new StringWriter();
	template.process(input, new PrintWriter(s));
	s.flush(); s.close();

	return s.toString();
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:40,代码来源:EventEmail.java

示例11: newFreeMarkerConfig

import freemarker.template.Configuration; //导入方法依赖的package包/类
private Configuration newFreeMarkerConfig() {
    Configuration freeMarkerConfig = new Configuration(Configuration.VERSION_2_3_24);
    freeMarkerConfig.setDefaultEncoding("UTF-8");
    freeMarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
    freeMarkerConfig
            .setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);

    return freeMarkerConfig;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:10,代码来源:Freemarker.java

示例12: init

import freemarker.template.Configuration; //导入方法依赖的package包/类
@PostConstruct
public void init() throws IOException {
	cfg = new Configuration(Configuration.VERSION_2_3_21);
	cfg.setClassForTemplateLoading(App.class, "/queries/");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
	tpl = cfg.getTemplate(FTL);
}
 
开发者ID:petabyte-research,项目名称:redflags,代码行数:9,代码来源:NoticesSvc.java

示例13: getTemplate

import freemarker.template.Configuration; //导入方法依赖的package包/类
public Template getTemplate(String templatePath)
		throws IOException, TemplateNotFoundException, MalformedTemplateNameException, ParseException {
	@SuppressWarnings("deprecation")
	Configuration cfg = new Configuration();
	if (templatePath.startsWith("classpath:")) {
		cfg.setClassForTemplateLoading(FindClass.class, ".." + Constants.FILE_SEP);
		templatePath = templatePath.replace("classpath:", "");
	} else {
		cfg.setDirectoryForTemplateLoading(new File(templatePath));			
	}
	Template template = cfg.getTemplate(templatePath);
	return template;
}
 
开发者ID:witchpou,项目名称:lj-projectbuilder,代码行数:14,代码来源:GeneratorService.java

示例14: showRollupEmail

import freemarker.template.Configuration; //导入方法依赖的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);
	}
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:41,代码来源:ReportResource.java

示例15: AnetEmailWorker

import freemarker.template.Configuration; //导入方法依赖的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);
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:35,代码来源:AnetEmailWorker.java


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