Search in sources :

Example 1 with ActiveRecordPlugin

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);
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) MysqlDialect(com.jfinal.plugin.activerecord.dialect.MysqlDialect) DruidPlugin(com.jfinal.plugin.druid.DruidPlugin) StatFilter(com.alibaba.druid.filter.stat.StatFilter) ActiveRecordPlugin(com.jfinal.plugin.activerecord.ActiveRecordPlugin)

Example 2 with ActiveRecordPlugin

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);
}
Also used : Cron4jPlugin(com.jfinal.plugin.cron4j.Cron4jPlugin) ShiroPlugin(com.fruit.manage.plugin.shiro.ShiroPlugin) ActiveRecordPlugin(com.jfinal.plugin.activerecord.ActiveRecordPlugin) HikariCpPlugin(com.jfinal.plugin.hikaricp.HikariCpPlugin) EhCachePlugin(com.jfinal.plugin.ehcache.EhCachePlugin)

Example 3 with ActiveRecordPlugin

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;
}
Also used : Random(java.util.Random) ActiveRecordPlugin(com.jfinal.plugin.activerecord.ActiveRecordPlugin)

Aggregations

ActiveRecordPlugin (com.jfinal.plugin.activerecord.ActiveRecordPlugin)3 StatFilter (com.alibaba.druid.filter.stat.StatFilter)1 WallFilter (com.alibaba.druid.wall.WallFilter)1 ShiroPlugin (com.fruit.manage.plugin.shiro.ShiroPlugin)1 MysqlDialect (com.jfinal.plugin.activerecord.dialect.MysqlDialect)1 Cron4jPlugin (com.jfinal.plugin.cron4j.Cron4jPlugin)1 DruidPlugin (com.jfinal.plugin.druid.DruidPlugin)1 EhCachePlugin (com.jfinal.plugin.ehcache.EhCachePlugin)1 HikariCpPlugin (com.jfinal.plugin.hikaricp.HikariCpPlugin)1 Random (java.util.Random)1