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

Java FileResourceLoader类代码示例

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

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



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

示例1: velocityEngineFactoryBean

import org.apache.velocity.runtime.resource.loader.FileResourceLoader; //导入依赖的package包/类
@Lazy
@Bean(name = "shibboleth.VelocityEngine")
public VelocityEngineFactoryBean velocityEngineFactoryBean() {
    final VelocityEngineFactoryBean bean = new VelocityEngineFactoryBean();

    final Properties properties = new Properties();
    properties.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SLF4JLogChute.class.getName());
    properties.put(RuntimeConstants.INPUT_ENCODING, StandardCharsets.UTF_8.name());
    properties.put(RuntimeConstants.OUTPUT_ENCODING, StandardCharsets.UTF_8.name());
    properties.put(RuntimeConstants.ENCODING_DEFAULT, StandardCharsets.UTF_8.name());
    properties.put(RuntimeConstants.RESOURCE_LOADER, "file, classpath, string");
    properties.put(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FileUtils.getTempDirectory().getAbsolutePath());
    properties.put(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, Boolean.FALSE);
    properties.put("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    properties.put("string.resource.loader.class", StringResourceLoader.class.getName());
    properties.put("file.resource.loader.class", FileResourceLoader.class.getName());
    bean.setOverrideLogging(false);
    bean.setVelocityProperties(properties);
    return bean;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:CoreSamlConfiguration.java


示例2: postProcessVelocityEngine

import org.apache.velocity.runtime.resource.loader.FileResourceLoader; //导入依赖的package包/类
@Override
protected void postProcessVelocityEngine(VelocityEngine velocityEngine) {
	super.postProcessVelocityEngine(velocityEngine);
	velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "webapp,file,class,url,jar,spring,springMacro");
	velocityEngine.setProperty("webapp.resource.loader.class", WebappResourceLoader.class.getName());
	velocityEngine.setProperty("file.resource.loader.class", FileResourceLoader.class.getName());
	velocityEngine.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
	velocityEngine.setProperty("url.resource.loader.class", URLResourceLoader.class.getName());
	velocityEngine.setProperty("jar.resource.loader.class", JarResourceLoader.class.getName());

	velocityEngine.setProperty("resource.manager.cache.class", ResourceCacheImpl.class.getName());
	velocityEngine.setProperty("resource.manager.cache.size", 2048);
	velocityEngine.setProperty("resource.manager.class", ResourceManagerImpl.class.getName());

	velocityEngine.setProperty(RuntimeConstants.COUNTER_INITIAL_VALUE, 1);
	velocityEngine.setProperty(RuntimeConstants.INPUT_ENCODING, inputEncoding);
	velocityEngine.setProperty(RuntimeConstants.OUTPUT_ENCODING, outputEncoding);
	velocityEngine.setProperty("contentType", contentType);
	// org.apache.velocity.runtime.log.AvalonLogChute
	// org.apache.velocity.runtime.log.Log4JLogChute
	// org.apache.velocity.runtime.log.CommonsLogLogChute
	// org.apache.velocity.runtime.log.ServletLogChute
	// org.apache.velocity.runtime.log.JdkLogChute
	velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new Log4JLogChute());
	velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, true);
}
 
开发者ID:liufeiit,项目名称:sharding,代码行数:27,代码来源:VelocityTemplateConfigurer.java


示例3: renderToFolder

import org.apache.velocity.runtime.resource.loader.FileResourceLoader; //导入依赖的package包/类
private void renderToFolder(EntityObject eo, String template, String folder, String fileName) throws IOException {
	// first, let's build the filename.
	String fullFileName = folder + File.separator + fileName;

	VelocityEngine ve = new VelocityEngine();
	// Tried using classpath, but discarded it.
	ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "file");
	ve.setProperty("file.resource.loader.class", FileResourceLoader.class.getName());
	// setting it empty, so we can use an absolute path
	ve.setProperty("file.resource.loader.path", "");
	ve.init();
	VelocityContext ctx = new VelocityContext();
	ctx.put("ENTITY", eo);
	ctx.put("display", new DisplayTool());
	// now, let's expand the template path in case we are using one of our
	// default templates.
	if (template.startsWith("templates/")) {
		// ok, we assume it's one of our default templates in MCP_HOME
		String modelHomeFolder = System.getenv("MCP_HOME");
		if (!modelHomeFolder.endsWith(File.separator))
			modelHomeFolder = modelHomeFolder + File.separator;
		template = modelHomeFolder + template;
	}

	Template t = ve.getTemplate(template);
	StringWriter writer = new StringWriter();
	t.merge(ctx, writer);
	// System.out.println(writer);

	log.info("Writing file " + fullFileName);
	FileWriter fileWriter = new FileWriter(fullFileName);
	fileWriter.write(writer.toString());
	fileWriter.flush();
	fileWriter.close();
}
 
开发者ID:activequant,项目名称:mcp,代码行数:36,代码来源:VelocityRenderer.java


示例4: createVelocityEngine

import org.apache.velocity.runtime.resource.loader.FileResourceLoader; //导入依赖的package包/类
private VelocityEngine createVelocityEngine(final File templateDir) {
final VelocityEngine ve = new VelocityEngine();
if (templateDir == null) {
    ve.addProperty("resource.loader", "class");
} else {
    ve.addProperty("resource.loader", "file, class");
    ve.addProperty("file.resource.loader.class",
	    FileResourceLoader.class.getName());
    ve.addProperty("file.resource.loader.path", templateDir.toString());
}
ve.addProperty("class.resource.loader.class",
	ClasspathResourceLoader.class.getName());
ve.init();
return ve;
   }
 
开发者ID:fuinorg,项目名称:srcgen4j-core,代码行数:16,代码来源:VelocityGenerator.java


示例5: configure

import org.apache.velocity.runtime.resource.loader.FileResourceLoader; //导入依赖的package包/类
@Override
public void configure(String templatesPath, boolean debugMode)
		throws JannocessorException {
	logger.info(
			"Configuring Velocity engine: {templates_path={}, debug={}}",
			templatesPath, debugMode);

	try {
		Properties velocityConfig = new Properties();

		if (templatesPath != null) {
			velocityConfig
					.setProperty("resource.loader", "file, classpath");

			velocityConfig.setProperty(RESOURCE_LOADER_CLASS,
					FileResourceLoader.class.getCanonicalName());
			velocityConfig.setProperty(FILE_RESOURCE_LOADER_PATH,
					templatesPath);

			velocityConfig.setProperty("classpath.resource.loader.class",
					ClasspathResourceLoader.class.getCanonicalName());
			velocityConfig.setProperty("classpath.resource.loader.cache",
					"false");
		} else {
			velocityConfig.setProperty(RESOURCE_LOADER_CLASS,
					ClasspathResourceLoader.class.getCanonicalName());
		}

		velocityConfig.setProperty(VM_LIBRARY,
				StringUtils.join(VM_LIBRARY_FILES, ","));

		velocityConfig.setProperty(VM_MAX_DEPTH, "1000");
		velocityConfig.setProperty(VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL,
				"true");
		velocityConfig.setProperty(VM_PERM_INLINE_LOCAL, "false");
		velocityConfig.setProperty(VM_PERM_ALLOW_INLINE, "true");

		// FIXME: deprecated
		velocityConfig.setProperty(VM_CONTEXT_LOCALSCOPE, "true");

		if (debugMode) {
			velocityConfig.setProperty(VM_LIBRARY_AUTORELOAD, "true");
			velocityConfig.setProperty(FILE_RESOURCE_LOADER_CACHE, "false");
		} else {
			velocityConfig.setProperty(VM_LIBRARY_AUTORELOAD, "false");
			velocityConfig.setProperty(FILE_RESOURCE_LOADER_CACHE, "true");
		}

		engine.setProperty(RUNTIME_LOG_LOGSYSTEM, this);
		engine.init(velocityConfig);

		customize(true);

		configured = true;
	} catch (Exception e) {
		throw new JannocessorException(
				"Exception occured while configuring the template renderer",
				e);
	}
}
 
开发者ID:muh6mm3d,项目名称:jannocessor,代码行数:61,代码来源:VelocityTemplateRenderer.java


示例6: doWork

import org.apache.velocity.runtime.resource.loader.FileResourceLoader; //导入依赖的package包/类
@Override
public int doWork(List<String> args) {
if(args.size()!=1) {
	LOG.error("expected one and only one argument.");
	return -1;
}
if(this.velocityTemplate==null) {
	LOG.error("undefined option -T");
	return -1;
}
String command = args.get(0);
Reader jsonReader = null;
PrintWriter pw = null;
JsonElement jsonDoc=null;
try
	{
	final JsonParser parser=new JsonParser();
	
	try {
		File jsonF = new File(command);
		if(!jsonF.exists() && jsonF.isFile()) {
			jsonReader = new FileReader(jsonF);
		}
	} catch (IOException e) {
		jsonReader=null;
	}
	
	if(jsonReader==null) {
		if(command.endsWith(".php")) {
			command+=".json";
		}
		
		if(command.startsWith("org_")) {
			command = "https://software.broadinstitute.org/gatk/gatkdocs/"+command;
		}

		jsonReader = new InputStreamReader(IOUtils.openURIForReading(command));
	}
	
	jsonDoc = parser.parse(jsonReader);
	jsonReader.close();
	
	LOG.info("URL is :" + command);
	
	IOUtil.assertFileIsReadable(this.velocityTemplate);
	pw = openFileOrStdoutAsPrintWriter(this.outputFile);
	VelocityContext context = new VelocityContext();
	
	context.put("json", jsonDoc);
	context.put("utils", new Utils());
	final VelocityEngine ve = new VelocityEngine();
       ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "file");
       ve.setProperty("file.resource.loader.class",FileResourceLoader.class.getName());
       ve.setProperty("file.resource.loader.path",this.velocityTemplate.getParent());
       ve.init();
       final Template template = ve.getTemplate(this.velocityTemplate.getName());
       template.merge( context, pw);
       pw.flush();
	
	return RETURN_OK;
	}
catch(final Exception err)
	{
	LOG.error(err);
	return -1;
	}
finally
	{
	CloserUtil.close(pw);
	CloserUtil.close(jsonReader);
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:73,代码来源:GATKCodeGenerator.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EnvironmentVariablesNodeProperty类代码示例发布时间:2022-05-22
下一篇:
Java ContextListImpl类代码示例发布时间: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