Search in sources :

Example 1 with HikariCpPlugin

use of com.jfinal.plugin.hikaricp.HikariCpPlugin in project fruit-manage by liuzhaozhao.

the class GeneratorDemo method getDataSource.

public static DataSource getDataSource() {
    PropKit.use("setting.properties");
    // 配置数据库连接池插件
    // 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"));
    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"));
    dataSource.start();
    return dataSource.getDataSource();
}
Also used : HikariCpPlugin(com.jfinal.plugin.hikaricp.HikariCpPlugin)

Example 2 with HikariCpPlugin

use of com.jfinal.plugin.hikaricp.HikariCpPlugin 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)

Aggregations

HikariCpPlugin (com.jfinal.plugin.hikaricp.HikariCpPlugin)2 ShiroPlugin (com.fruit.manage.plugin.shiro.ShiroPlugin)1 ActiveRecordPlugin (com.jfinal.plugin.activerecord.ActiveRecordPlugin)1 Cron4jPlugin (com.jfinal.plugin.cron4j.Cron4jPlugin)1 EhCachePlugin (com.jfinal.plugin.ehcache.EhCachePlugin)1