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

Java Configuration类代码示例

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

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



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

示例1: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		String home = System.getProperty("user.dir") + File.separator
				+ "template" + File.separator;
		Configuration cf = Configuration.defaultConfiguration();
		cf.setStatementStart("<!--:");
		cf.setStatementEnd("-->");
		FileResourceLoader rs = new FileResourceLoader(home, cf.getCharset());
		GroupTemplate gt = new GroupTemplate(rs, cf);

		List<StockModel> list = StockModel.dummyItems();

		Template t = gt.getTemplate("/helloworld.html");
		t.binding("items", list);
		StringWriter sw = new StringWriter();
		t.renderTo(sw);
		System.out.println(sw.toString());

		// 第二次
		t = gt.getTemplate("/helloworld.html");
		t.binding("items", list);
		sw = new StringWriter();
		t.renderTo(sw);
		System.out.println(sw.toString());

	}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:27,代码来源:GroupTemplateTest.java


示例2: ServletGroupTemplate

import org.beetl.core.Configuration; //导入依赖的package包/类
private ServletGroupTemplate()
{

	try
	{
		Configuration cfg = Configuration.defaultConfiguration();
		WebAppResourceLoader resourceLoader = new WebAppResourceLoader();
		groupTemplate = new GroupTemplate(resourceLoader, cfg);
	}
	catch (Exception ex)
	{
		ex.printStackTrace();
		throw new RuntimeException("加载GroupTemplate失败", ex);

	}

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:ServletGroupTemplate.java


示例3: BeetlActionResult

import org.beetl.core.Configuration; //导入依赖的package包/类
public BeetlActionResult()
{

	try
	{

		Configuration cfg = Configuration.defaultConfiguration();
		WebAppResourceLoader resourceLoader = new WebAppResourceLoader();
		groupTemplate = new GroupTemplate(resourceLoader, cfg);

	}
	catch (IOException e)
	{
		throw new RuntimeException("加载GroupTemplate失败", e);
	}

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:BeetlActionResult.java


示例4: getGt

import org.beetl.core.Configuration; //导入依赖的package包/类
public GroupTemplate getGt()
{
	ClasspathResourceLoader rs = new ClasspathResourceLoader("/template");
	Configuration cfg;
	try
	{
		cfg = Configuration.defaultConfiguration();
	}
	catch (IOException e)
	{
		throw new RuntimeException(e);
	}
	cfg.setStatementEnd(null);
	cfg.setStatementStart("@");
	GroupTemplate gt = new GroupTemplate(rs, cfg);
	return gt;
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:SingleDLTest.java


示例5: getGt

import org.beetl.core.Configuration; //导入依赖的package包/类
public GroupTemplate getGt()
{
	ClasspathResourceLoader rs = new ClasspathResourceLoader("/template");
	Configuration cfg;
	try
	{
		cfg = Configuration.defaultConfiguration();
	}
	catch (IOException e)
	{
		throw new RuntimeException(e);
	}
	cfg.setStatementEnd("%>");
	cfg.setStatementStart("<%");

	GroupTemplate gt = new GroupTemplate(rs, cfg);
	return gt;
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:19,代码来源:PairDLTest.java


示例6: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();		
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
Map<String,Object> shared = new HashMap<String,Object>();
shared.put("name", "beetl");
gt.setSharedVars(shared);
Template t = gt.getTemplate("/org/beetl/sample/s0208/t1.txt");	
String str = t.render();
System.out.println(str);
t = gt.getTemplate("/org/beetl/sample/s0208/t2.txt");	
str = t.render();
System.out.println(str);


}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:SharedVars.java


示例7: TempletGenerate

import org.beetl.core.Configuration; //导入依赖的package包/类
public TempletGenerate(String generateRootPath, String generateConfigRootPath, String generateDbName) {
    WebAppResourceLoader resourceLoader = new WebAppResourceLoader();
    Configuration cfg = null;
    try {
      cfg = Configuration.defaultConfiguration();
    } catch ( IOException e ) {
      e.printStackTrace();
    }
    gt = new GroupTemplate(resourceLoader, cfg);

    this.generateCodeRootPath = generateRootPath;
//		this.generateConfigRootPath = generateConfigRootPath;
    this.generateDbName = generateDbName;
    init();
  }
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:16,代码来源:TempletGenerate.java


示例8: init

import org.beetl.core.Configuration; //导入依赖的package包/类
@BeforeClass
public static void init() throws IOException {
	WebAppResourceLoader resourceLoader = new WebAppResourceLoader();
	String root = "E:\\workspace\\WALL-E\\src\\main\\webapp";
	resourceLoader.setRoot(root);
	Configuration cfg = Configuration.defaultConfiguration();

	gt = new GroupTemplate(resourceLoader, cfg);

	PluginFactory.startActiveRecordPlugin();
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:12,代码来源:TempletGenerateTest.java


示例9: init

import org.beetl.core.Configuration; //导入依赖的package包/类
public AutoGen init(String configPath) throws IOException {
    if(configPath == null || configPath.length() == 0){
        configPath = PathKit.getRootClassPath() + "/defaultRule.json" ;
    }
    config = getConfig(configPath) ;
    if(config == null){
        throw new NullPointerException("No Config.");
    }
    JSONObject dataSourceConfig = config.getJSONObject("dataSource") ;
    dp = new DruidPlugin(
            dataSourceConfig.getString("url"),
            dataSourceConfig.getString("user"),
            dataSourceConfig.getString("pwd")
    );
    dp.addFilter(new StatFilter());
    WallFilter wall = new WallFilter();
    wall.setDbType("mysql");
    WallConfig wallConfig = new WallConfig();
    wallConfig.setFunctionCheck(false);
    wallConfig.setCreateTableAllow(true);
    wallConfig.setCommentAllow(true);
    wallConfig.setMultiStatementAllow(true);
    wall.setConfig(wallConfig);
    dp.addFilter(wall);
    arp = new ActiveRecordPlugin(dp);
    arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));// 大小写不敏感
    arp.setDialect(new MysqlDialect());
    dp.start();
    arp.start();
    resourceLoader = new FileResourceLoader(config.getString("baseTemplatePath"),"utf-8");
    cfg = Configuration.defaultConfiguration();
    gt = new GroupTemplate(resourceLoader, cfg);
    System.out.println("-- init success .");
    return this ;
}
 
开发者ID:devilyaos,项目名称:AutoGenerate,代码行数:36,代码来源:AutoGen.java


示例10: BeetlIo

import org.beetl.core.Configuration; //导入依赖的package包/类
/**
 * 初始化Beetl
 */
public BeetlIo() {
    try {
        StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
        Configuration cfg = Configuration.defaultConfiguration();
        gt = new GroupTemplate(resourceLoader, cfg);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:darkfireworld,项目名称:java-fast-framework,代码行数:13,代码来源:BeetlIo.java


示例11: BeetlFacade

import org.beetl.core.Configuration; //导入依赖的package包/类
private BeetlFacade() {
    try {
        ps = loadDefaultConfig();
        Properties ext = loadExtConfig();
        ps.putAll(ext);
        StringSqlTemplateLoader resourceLoader = new StringSqlTemplateLoader();
        Configuration cfg = new Configuration(ps);
        gt = new GroupTemplate(resourceLoader, cfg);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:hatunet,项目名称:mybatis-beetl-scripting,代码行数:13,代码来源:BeetlFacade.java


示例12: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		String home = System.getProperty("user.dir") + File.separator
				+ "template" + File.separator;
		Configuration cf = Configuration.defaultConfiguration();
		FileResourceLoader rs = new FileResourceLoader(home, cf.getCharset());
		GroupTemplate gt = new GroupTemplate(rs, cf);
		Template t = gt.getTemplate("/helloworld.html");
		Program p = gt.getProgram("/helloworld.html");
		ProgramMetaData old = p.metaData;
		ProgramMetaData copy = old.copy();
		System.out.println("ok");
	}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:14,代码来源:MetaCopyTest.java


示例13: init

import org.beetl.core.Configuration; //导入依赖的package包/类
public void init() throws IOException {
    log.debug("beetl init ....");
    Configuration cfg = Configuration.defaultConfiguration();
    Properties prop = new Properties();
    InputStream ins = Configuration.class.getResourceAsStream("/beetl.properties");
    if (ins != null) {
        log.debug("found beetl.properties, loading ...");
        try {
            prop.load(ins);
        }
        finally {
            Streams.safeClose(ins);
        }
    }
    if (!prop.containsKey(Configuration.RESOURCE_LOADER)) {
        // 默认选用WebAppResourceLoader,除非用户自定义了RESOURCE_LOADER
        log.debug("no custom RESOURCE_LOADER found , select WebAppResourceLoader");
        cfg.setResourceLoader(WebAppResourceLoader.class.getName());
    }
    if (!prop.containsKey(Configuration.DIRECT_BYTE_OUTPUT)) {
        // 默认启用DIRECT_BYTE_OUTPUT,除非用户自定义, 一般不会.
        log.debug("no custom DIRECT_BYTE_OUTPUT found , set to true");
        // 当DIRECT_BYTE_OUTPUT为真时, beetl渲染会通过getOutputStream获取输出流
        // 而BeetlView会使用LazyResponseWrapper代理getOutputStream方法
        // 从而实现在模板输出之前,避免真正调用getOutputStream
        // 这样@Fail视图就能正常工作了
        cfg.setDirectByteOutput(true);
    }
    if (!prop.containsKey(Configuration.ERROR_HANDLER)) {
        // 没有自定义ERROR_HANDLER,用定制的
        cfg.setErrorHandlerClass(LogErrorHandler.class.getName());
    }
    groupTemplate = new GroupTemplate(cfg);
    render = new WebRender(groupTemplate);
    log.debug("beetl init complete");
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:37,代码来源:BeetlViewMaker.java


示例14: testSimple

import org.beetl.core.Configuration; //导入依赖的package包/类
@Test
public void testSimple() throws Exception
{

	Configuration conf = Configuration.defaultConfiguration();
	CompositeResourceLoader loader = new CompositeResourceLoader();
	String home = System.getProperty("user.dir");
	String path1 = home + "/src/test/resources/template/resourceloader/var1";
	String path2 = home + "/src/test/resources/template/resourceloader/var2";
	FileResourceLoader fileLoader1 = new FileResourceLoader(path1);
	FileResourceLoader fileLoader2 = new FileResourceLoader(path2);
	Map data = getData();
	// 根据id加载
	MapResourceLoader mapLoader = new MapResourceLoader(data);

	loader.addResourceLoader(new StartsWithMatcher("http:").withoutPrefix(), fileLoader2);
	loader.addResourceLoader(new StartsWithMatcher("db:").withoutPrefix(), mapLoader);
	loader.addResourceLoader(new AllowAllMatcher(), fileLoader1);

	GroupTemplate gt = new GroupTemplate(loader, conf);

	Template t = gt.getTemplate("/xxx.html");
	t.binding("a", "hello");
	String result = t.render();
	;
	AssertJUnit.assertEquals("hellohello--file2:hello--db=hello", result);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:29,代码来源:CompositeResourceLoaderTest.java


示例15: testSecurity

import org.beetl.core.Configuration; //导入依赖的package包/类
@Test
public void testSecurity() throws Exception
{

	StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
	Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("hello,${@java.lang.System.currentTimeMillis()}");

	String str = t.render();
	AssertJUnit.assertEquals("hello,", str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:14,代码来源:NativeTest.java


示例16: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
String root = System.getProperty("user.dir")+File.separator+"template";
FileResourceLoader resourceLoader = new FileResourceLoader(root,"utf-8");		
	Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
gt.registerFunctionPackage("t", new FunctionPackage());
Template t = gt.getTemplate("/s32/functionPackage.html");	
String str = t.render();		
System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:13,代码来源:RegisterFunctionByFile.java


示例17: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
String root = System.getProperty("user.dir")+File.separator+"template";
FileResourceLoader resourceLoader = new FileResourceLoader(root,"utf-8");		
	Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
Template t = gt.getTemplate("/s32/pagefunction.html");	
String str = t.render();		
System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:RegisterFunctionPackage.java


示例18: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
	ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();		
	URL url = resourceLoader.getClass().getResource("/org/beetl/sample/s01/hello.txt");
	Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("/org/beetl/sample/s01/hello.txt");	
	String str = t.render();
	System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:ClasspathRL.java


示例19: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();		
	Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("hello,${name}");
	t.binding("name", "beetl");		
	String str = t.render();
	System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:11,代码来源:HelloBeetl.java


示例20: main

import org.beetl.core.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
	String root = System.getProperty("user.dir")+File.separator+"template";
	FileResourceLoader resourceLoader = new FileResourceLoader(root,"utf-8");		
		Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("/s01/hello.txt");	
	String str = t.render();		
	System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:FilePathRL.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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