Search in sources :

Example 1 with WallFilter

use of com.alibaba.druid.wall.WallFilter 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 WallFilter

use of com.alibaba.druid.wall.WallFilter in project druid by alibaba.

the class TestOracleWall2 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    WallFilter wall = new WallFilter();
    wall.setConfig(new WallConfig());
    wall.getConfig().setWrapAllow(false);
    dataSource.setOracle(true);
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(new OracleMockDriver());
    dataSource.setPoolPreparedStatements(true);
    dataSource.setConnectionProperties("defaultRowPrefetch=50");
    dataSource.setFilters("stat");
    dataSource.getProxyFilters().add(wall);
    dataSource.setDbType("oracle");
// dataSource.setFilters("log4j");
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) WallConfig(com.alibaba.druid.wall.WallConfig) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) OracleMockDriver(com.alibaba.druid.test.util.OracleMockDriver)

Example 3 with WallFilter

use of com.alibaba.druid.wall.WallFilter in project tesla by linking12.

the class DruidDBConfig method getProxyFilters.

private List<Filter> getProxyFilters() {
    List<Filter> proxyFilters = Lists.newArrayList();
    WallConfig wallConfig = new WallConfig();
    wallConfig.setDir("");
    wallConfig.setCommentAllow(true);
    wallConfig.init();
    WallFilter wallFilter = new WallFilter();
    wallFilter.setDbType("mysql");
    wallFilter.setConfig(wallConfig);
    proxyFilters.add(wallFilter);
    return proxyFilters;
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) WallFilter(com.alibaba.druid.wall.WallFilter) WebStatFilter(com.alibaba.druid.support.http.WebStatFilter) Filter(com.alibaba.druid.filter.Filter) WallConfig(com.alibaba.druid.wall.WallConfig)

Example 4 with WallFilter

use of com.alibaba.druid.wall.WallFilter in project neweagle-api by apgzs.

the class DruidConfiguration method wallFilter.

@Bean
public WallFilter wallFilter() {
    WallFilter wallFilter = new WallFilter();
    // 允许执行多条SQL
    WallConfig config = new WallConfig();
    config.setMultiStatementAllow(true);
    wallFilter.setConfig(config);
    return wallFilter;
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) WallConfig(com.alibaba.druid.wall.WallConfig) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with WallFilter

use of com.alibaba.druid.wall.WallFilter in project neweagle-api by apgzs.

the class DruidConfiguration method dataSource.

@Bean
@Primary
public DataSource dataSource() {
    DruidDataSource datasource = new DruidDataSource();
    datasource.setUrl(this.dbUrl);
    datasource.setUsername(username);
    datasource.setPassword(password);
    datasource.setDriverClassName(driverClassName);
    // configuration
    if (initialSize != null) {
        datasource.setInitialSize(initialSize);
    }
    if (minIdle != null) {
        datasource.setMinIdle(minIdle);
    }
    if (maxActive != null) {
        datasource.setMaxActive(maxActive);
    }
    if (maxWait != null) {
        datasource.setMaxWait(maxWait);
    }
    if (timeBetweenEvictionRunsMillis != null) {
        datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    }
    if (minEvictableIdleTimeMillis != null) {
        datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    }
    if (validationQuery != null) {
        datasource.setValidationQuery(validationQuery);
    }
    if (testWhileIdle != null) {
        datasource.setTestWhileIdle(testWhileIdle);
    }
    if (testOnBorrow != null) {
        datasource.setTestOnBorrow(testOnBorrow);
    }
    if (testOnReturn != null) {
        datasource.setTestOnReturn(testOnReturn);
    }
    if (poolPreparedStatements != null) {
        datasource.setPoolPreparedStatements(poolPreparedStatements);
    }
    if (maxPoolPreparedStatementPerConnectionSize != null) {
        datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
    }
    if (connectionProperties != null) {
        datasource.setConnectionProperties(connectionProperties);
    }
    List<Filter> filters = new ArrayList<>();
    filters.add(statFilter());
    filters.add(wallFilter());
    datasource.setProxyFilters(filters);
    return datasource;
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) WebStatFilter(com.alibaba.druid.support.http.WebStatFilter) Filter(com.alibaba.druid.filter.Filter) StatFilter(com.alibaba.druid.filter.stat.StatFilter) ArrayList(java.util.ArrayList) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Primary(org.springframework.context.annotation.Primary) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

WallFilter (com.alibaba.druid.wall.WallFilter)9 WallConfig (com.alibaba.druid.wall.WallConfig)6 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)5 Filter (com.alibaba.druid.filter.Filter)3 Bean (org.springframework.context.annotation.Bean)3 StatFilter (com.alibaba.druid.filter.stat.StatFilter)2 WebStatFilter (com.alibaba.druid.support.http.WebStatFilter)2 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)2 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)2 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)2 OracleMockDriverJdbc3 (com.alibaba.druid.test.util.OracleMockDriverJdbc3)1 ActiveRecordPlugin (com.jfinal.plugin.activerecord.ActiveRecordPlugin)1 MysqlDialect (com.jfinal.plugin.activerecord.dialect.MysqlDialect)1 DruidPlugin (com.jfinal.plugin.druid.DruidPlugin)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)1 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)1 Primary (org.springframework.context.annotation.Primary)1