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

matrix.module.jdbc.utils.DynamicDataSource Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package matrix.module.jdbc.utils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author wangcheng
 */
public class DynamicDataSource extends AbstractRoutingDataSource {

    private final static Logger logger = LogManager.getLogger(DynamicDataSource.class);

    @Override
    public void afterPropertiesSet() {
        super.afterPropertiesSet();
    }

    @Override
    protected Object determineCurrentLookupKey() {
        Object key = DynamicDataSourceHolder.getDataSource();
        logger.debug("==> select datasource key [{}]", key);
        return key;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy