本文整理汇总了Java中org.beetl.core.Configuration.defaultConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.defaultConfiguration方法的具体用法?Java Configuration.defaultConfiguration怎么用?Java Configuration.defaultConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.beetl.core.Configuration
的用法示例。
在下文中一共展示了Configuration.defaultConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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 ;
}
示例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);
}
}
示例11: 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");
}
示例12: 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");
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}