All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.deansquirrel.tools.db.ToolsHelperImpl Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.github.deansquirrel.tools.db;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class ToolsHelperImpl implements IToolsDbHelper {

    private final JdbcTemplate jdbcTemplate;
    private final DynamicRoutingDataSource dynamicRoutingDataSource;

    public ToolsHelperImpl(@Qualifier(value = IToolsDbHelper.BEAN_JDBC_TEMPLATE) JdbcTemplate jdbcTemplate,
                           @Qualifier(value = IToolsDbHelper.DYNAMIC_ROUTEING_DATASOURCE) DynamicRoutingDataSource dynamicRoutingDataSource) {
        this.jdbcTemplate = jdbcTemplate;
        this.dynamicRoutingDataSource = dynamicRoutingDataSource;
    }

    @Override
    public JdbcTemplate getJdbcTemplate() {
        return this.jdbcTemplate;
    }

    @Override
    public void addDataSource(String key, DruidDataSource dataSource, Integer queryTimeout, Integer maxActive) {
        this.dynamicRoutingDataSource.addDataSource(key, dataSource);
    }

    @Override
    public void removeDataSource(String key) {
        this.dynamicRoutingDataSource.removeDataSource(key);
    }

    @Override
    public void clear() {
        this.dynamicRoutingDataSource.clear();
    }

    @Override
    public long size() {
        return this.dynamicRoutingDataSource.size();
    }

    @Override
    public void setDataSourceKey(String key) {
        this.dynamicRoutingDataSource.setDataSourceKey(key);
    }

    @Override
    public void remove() {
        this.dynamicRoutingDataSource.remove();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy