Package com.alibaba.druid.proxy.jdbc

Examples of com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl


            return null;
        }

        connectCount.incrementAndGet();

        DataSourceProxyImpl dataSource = getDataSource(url, info);

        return dataSource.connect(info);
    }
View Full Code Here


     * @param url
     * @return
     * @throws SQLException
     */
    private DataSourceProxyImpl getDataSource(String url, Properties info) throws SQLException {
        DataSourceProxyImpl dataSource = proxyDataSources.get(url);

        if (dataSource == null) {
            DataSourceProxyConfig config = parseConfig(url, info);

            Driver rawDriver = createDriver(config.getRawDriverClassName());

            DataSourceProxyImpl newDataSource = new DataSourceProxyImpl(rawDriver, config);
           
            {
                String property = System.getProperty("druid.filters");
                if (property != null && property.length() > 0) {
                    for (String filterItem : property.split(",")) {
                        DruidLoaderUtils.loadFilter(config.getFilters(), filterItem);
                    }
                }
            }
            {
                int dataSourceId = createDataSourceId();
                newDataSource.setId(dataSourceId);

                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }
View Full Code Here

        return this.minorVersion;
    }

    @Override
    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
        DataSourceProxyImpl dataSource = getDataSource(url, info);
        return dataSource.getRawDriver().getPropertyInfo(dataSource.getConfig().getRawUrl(), info);
    }
View Full Code Here

            return null;
        }

        connectCounter.incrementAndGet();

        DataSourceProxyImpl dataSource = getDataSource(url, info);

        return dataSource.connect(info);
    }
View Full Code Here

     * @param url
     * @return
     * @throws SQLException
     */
    private DataSourceProxyImpl getDataSource(String url, Properties info) throws SQLException {
        DataSourceProxyImpl dataSource = proxyDataSources.get(url);

        if (dataSource == null) {
            String restUrl = url.substring(DEFAULT_PREFIX.length());

            DataSourceProxyConfig config;

            config = new DataSourceProxyConfig();

            List<AbstractDruidFilterConfig> druidFilterConfigList = new ArrayList<AbstractDruidFilterConfig>();
            String configFile = info.getProperty(CONFIG_PREFIX);
            if (configFile != null) {
                DruidFilterConfigLoader.loadConfig(configFile.trim(), druidFilterConfigList);
            }

            if (restUrl.startsWith(DRIVER_PREFIX)) {
                int pos = restUrl.indexOf(':', DRIVER_PREFIX.length());
                String driverText = restUrl.substring(DRIVER_PREFIX.length(), pos);
                if (driverText.length() > 0) {
                    config.setRawDriverClassName(driverText.trim());
                }
                restUrl = restUrl.substring(pos + 1);
            }

            if (restUrl.startsWith(FILTERS_PREFIX)) {
                int pos = restUrl.indexOf(':', FILTERS_PREFIX.length());
                String filtersText = restUrl.substring(FILTERS_PREFIX.length(), pos);
                for (String filterItem : filtersText.split(",")) {
                    DruidLoaderUtils.loadFilter(config.getFilters(), filterItem);
                }
                restUrl = restUrl.substring(pos + 1);
            }
            // 如果url中并无定义filter 采用配置
            if (config.getFilters().size() <= 0) {
                DruidLoaderUtils.loadFilter(config.getFilters(), druidFilterConfigList);
            }

            if (restUrl.startsWith(NAME_PREFIX)) {
                int pos = restUrl.indexOf(':', NAME_PREFIX.length());
                String name = restUrl.substring(NAME_PREFIX.length(), pos);
                config.setName(name);
                restUrl = restUrl.substring(pos + 1);
            }

            if (restUrl.startsWith(JMX_PREFIX)) {
                int pos = restUrl.indexOf(':', JMX_PREFIX.length());
                String jmxOption = restUrl.substring(JMX_PREFIX.length(), pos);
                config.setJmxOption(jmxOption);
                restUrl = restUrl.substring(pos + 1);
            }

            String rawUrl = restUrl;
            config.setRawUrl(rawUrl);

            if (config.getRawDriverClassName() == null) {
                String rawDriverClassname = JdbcUtils.getDriverClassName(rawUrl);
                config.setRawDriverClassName(rawDriverClassname);
            }

            config.setUrl(url);

            Driver rawDriver = createDriver(config.getRawDriverClassName());

            DataSourceProxyImpl newDataSource = new DataSourceProxyImpl(rawDriver, config);
            {
                int dataSourceId = createDataSourceId();
                newDataSource.setId(dataSourceId);

                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }
View Full Code Here

        return this.minorVersion;
    }

    @Override
    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
        DataSourceProxyImpl dataSource = getDataSource(url, info);
        return dataSource.getRawDriver().getPropertyInfo(dataSource.getConfig().getRawUrl(), info);
    }
View Full Code Here

            return null;
        }

        connectCount.incrementAndGet();

        DataSourceProxyImpl dataSource = getDataSource(url, info);

        return dataSource.connect(info);
    }
View Full Code Here

     * @param url
     * @return
     * @throws SQLException
     */
    private DataSourceProxyImpl getDataSource(String url, Properties info) throws SQLException {
        DataSourceProxyImpl dataSource = proxyDataSources.get(url);

        if (dataSource == null) {
            DataSourceProxyConfig config = parseConfig(url, info);

            Driver rawDriver = createDriver(config.getRawDriverClassName());

            DataSourceProxyImpl newDataSource = new DataSourceProxyImpl(rawDriver, config);

            {
                String property = System.getProperty("druid.filters");
                if (property != null && property.length() > 0) {
                    for (String filterItem : property.split(",")) {
                        FilterManager.loadFilter(config.getFilters(), filterItem);
                    }
                }
            }
            {
                int dataSourceId = createDataSourceId();
                newDataSource.setId(dataSourceId);

                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }
View Full Code Here

        return this.minorVersion;
    }

    @Override
    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
        DataSourceProxyImpl dataSource = getDataSource(url, info);
        return dataSource.getRawDriver().getPropertyInfo(dataSource.getConfig().getRawUrl(), info);
    }
View Full Code Here

            return null;
        }

        connectCount.incrementAndGet();

        DataSourceProxyImpl dataSource = getDataSource(url, info);

        return dataSource.connect(info);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.