use of com.jfinal.plugin.activerecord.ActiveRecordPlugin in project my_curd by qinyou.
the class AppConfig method configPlugin.
@Override
public void configPlugin(Plugins me) {
DruidPlugin dbPlugin = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
// druid 监控
dbPlugin.addFilter(new StatFilter());
WallFilter wall = new WallFilter();
wall.setDbType("mysql");
dbPlugin.addFilter(wall);
ActiveRecordPlugin arp = new ActiveRecordPlugin(dbPlugin);
arp.setShowSql(PropKit.getBoolean("devMode"));
arp.setDialect(new MysqlDialect());
MappingKit.mapping(arp);
me.add(dbPlugin);
me.add(arp);
}
use of com.jfinal.plugin.activerecord.ActiveRecordPlugin in project fruit-manage by liuzhaozhao.
the class JFConfig method configPlugin.
/**
* 配置插件
*/
@Override
public void configPlugin(Plugins me) {
// 配置数据库连接池插件
// DruidPlugin dataSource = new DruidPlugin(PropKit.get("db.url"), PropKit.get("db.user"),
// PropKit.get("db.password"), PropKit.get("db.driver"));
// // StatFilter提供JDBC层的统计信息
// dataSource.addFilter(new StatFilter());
// // WallFilter的功能是防御SQL注入攻击
// WallFilter wallDefault = new WallFilter();
// wallDefault.setDbType(JdbcConstants.MYSQL);
// dataSource.addFilter(wallDefault);
// dataSource.setInitialSize(PropKit.getInt("db.poolInitialSize"));
// dataSource.setMaxPoolPreparedStatementPerConnectionSize(PropKit.getInt("db.poolMaxSize"));
// dataSource.setTimeBetweenConnectErrorMillis(PropKit.getInt("db.connectionTimeoutMillis"));
// me.add(dataSource);
// 配置数据库连接池
HikariCpPlugin dataSource = new HikariCpPlugin(PropKit.get("db.url"), PropKit.get("db.user"), PropKit.get("db.password"), PropKit.get("db.driver"));
dataSource.setMaximumPoolSize(PropKit.getInt("db.poolMaxSize"));
dataSource.setConnectionTimeout(PropKit.getInt("db.connectionTimeoutMillis"));
me.add(dataSource);
ActiveRecordPlugin arp = new ActiveRecordPlugin(dataSource);
// 所有映射在 MappingKit 中自动化搞定
_MappingKit.mapping(arp);
me.add(arp);
// 初始化应用缓存插件
me.add(new EhCachePlugin());
// 初始化定时任务插件
me.add(new Cron4jPlugin("job.properties"));
// 权限控制插件
ShiroPlugin shiroPlugin = new ShiroPlugin(routes);
shiroPlugin.setLoginUrl("/login");
shiroPlugin.setSuccessUrl("/");
// 没有权限提示页
shiroPlugin.setUnauthorizedUrl("");
me.add(shiroPlugin);
}
use of com.jfinal.plugin.activerecord.ActiveRecordPlugin in project zrlog by 94fzb.
the class ZrLogConfig method getActiveRecordPlugin.
/**
* 配置JFinal提供过简易版本的ORM(其实这里是叫Active+Record)。
*
* @param c3p0Plugin
* @return
*/
private ActiveRecordPlugin getActiveRecordPlugin(C3p0Plugin c3p0Plugin) {
ActiveRecordPlugin arp = new ActiveRecordPlugin("c3p0Plugin" + new Random().nextInt(), c3p0Plugin);
arp.addMapping(User.TABLE_NAME, "userId", User.class);
arp.addMapping(Log.TABLE_NAME, "logId", Log.class);
arp.addMapping(Type.TABLE_NAME, "typeId", Type.class);
arp.addMapping(Link.TABLE_NAME, "linkId", Link.class);
arp.addMapping(Comment.TABLE_NAME, "commentId", Comment.class);
arp.addMapping(LogNav.TABLE_NAME, "navId", LogNav.class);
arp.addMapping(WebSite.TABLE_NAME, "siteId", WebSite.class);
arp.addMapping(Plugin.TABLE_NAME, "pluginId", Plugin.class);
arp.addMapping(Tag.TABLE_NAME, "tagId", Tag.class);
return arp;
}
Aggregations