cn.bridgeli.masterslavedbselector.MasterSlaveDataSource Maven / Gradle / Ivy
package cn.bridgeli.masterslavedbselector;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
/**
* 主从数据源
*/
public class MasterSlaveDataSource extends AbstractRoutingDataSource {
private MasterSlaveSelector masterSlaveSelector;
/**
* @see org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource#determineCurrentLookupKey()
*/
@Override
protected Object determineCurrentLookupKey() {
return masterSlaveSelector.get();
}
/**
* Setter method for property masterSlaveSelector.
*
* @param masterSlaveSelector value to be assigned to property masterSlaveSelector
*/
public void setMasterSlaveSelector(MasterSlaveSelector masterSlaveSelector) {
this.masterSlaveSelector = masterSlaveSelector;
}
}