20 lines
567 B
Plaintext
20 lines
567 B
Plaintext
package com.surfbird.util;
|
|
|
|
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
|
|
|
public class MultipleDataSource extends AbstractRoutingDataSource {
|
|
|
|
private static final ThreadLocal<String> dataSourceKey = new InheritableThreadLocal<String>();
|
|
|
|
public static void setDataSourceKey(String dataSource) {
|
|
dataSourceKey.set(dataSource);
|
|
}
|
|
|
|
public static void removeDataSourceKey() {
|
|
dataSourceKey.remove();
|
|
}
|
|
|
|
protected Object determineCurrentLookupKey() {
|
|
return dataSourceKey.get();
|
|
}
|
|
} |