com.jeesuite.mybatis.datasource.MutiRouteDataSource Maven / Gradle / Ivy
/**
*
*/
package com.jeesuite.mybatis.datasource;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.jdbc.datasource.AbstractDataSource;
import org.springframework.jdbc.datasource.lookup.DataSourceLookup;
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup;
import com.jeesuite.common.util.ResourceUtils;
import com.jeesuite.mybatis.datasource.builder.DruidDataSourceBuilder;
import com.jeesuite.mybatis.datasource.builder.HikariCPDataSourceBuilder;
import com.jeesuite.spring.InstanceFactory;
import com.jeesuite.spring.SpringInstanceProvider;
/**
* 自动路由多数据源(读写分离 and 水平分库路由)
* @description
* @author vakin
* @date 2015年11月18日
* @Copyright (c) 2015, jwww
*/
public class MutiRouteDataSource extends AbstractDataSource implements ApplicationContextAware,InitializingBean{
private static final Logger logger = LoggerFactory.getLogger(MutiRouteDataSource.class);
private static final String MASTER_KEY = "master";
private DataSourceType dataSourceType = DataSourceType.Druid;
private ApplicationContext context;
private Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy