File tree Expand file tree Collapse file tree 4 files changed +12
-5
lines changed
main/java/com/ctrip/platform/dal/dao
test/java/com/ctrip/platform/dal/dao/datasource Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 44 <modelVersion >4.0.0</modelVersion >
55 <groupId >com.ctrip.platform</groupId >
66 <artifactId >dal-client</artifactId >
7- <version >1.17.6 </version >
7+ <version >1.17.7 </version >
88 <properties >
99 <ver .version>${project.version} </ver .version>
1010 <javax-persistence-version >1.0.2</javax-persistence-version >
Original file line number Diff line number Diff line change 22
33public interface IDataSourceConfigureProvider {
44// get datasource configure from local cache
5- IDataSourceConfigure getDataSourceConfigure () throws Exception ;
5+ IDataSourceConfigure getDataSourceConfigure ();
66
77// load datasource configure from configure center
88 IDataSourceConfigure forceLoadDataSourceConfigure ();
Original file line number Diff line number Diff line change @@ -25,10 +25,17 @@ public class DataSourceLocator {
2525
2626 private DataSourceConfigureProvider provider ;
2727
28+ private boolean isForceSwitch = false ;
29+
2830 public DataSourceLocator (DataSourceConfigureProvider provider ) {
2931 this .provider = provider ;
3032 }
3133
34+ public DataSourceLocator (DataSourceConfigureProvider provider , boolean isForceSwitch ) {
35+ this .provider = provider ;
36+ this .isForceSwitch = isForceSwitch ;
37+ }
38+
3239 // to be refactored
3340 public static boolean containsKey (String name ) {
3441 return cache .containsKey (name );
@@ -75,7 +82,7 @@ public DataSource getDataSource(String name) throws Exception {
7582
7683 private DataSource createDataSource (String name ) throws SQLException {
7784 IDataSourceConfigure config = provider .getDataSourceConfigure (name );
78- if (config == null ) {
85+ if (config == null && ! isForceSwitch ) {
7986 throw new SQLException ("Can not find connection configure for " + name );
8087 }
8188
Original file line number Diff line number Diff line change 99 */
1010public class ModifyDataSourceConfigureProvider implements IDataSourceConfigureProvider {
1111 @ Override
12- public IDataSourceConfigure getDataSourceConfigure () throws Exception {
13- throw new Exception ();
12+ public IDataSourceConfigure getDataSourceConfigure () {
13+ throw new RuntimeException ();
1414 }
1515
1616 @ Override
You can’t perform that action at this time.
0 commit comments