コード例 #1
0
 protected SortedMap<String, DataSource> lookupDataSourcesByRouter(
     final String statementName, final Object parameterObject) {
   SortedMap<String, DataSource> resultMap = new TreeMap<String, DataSource>();
   String namespace = StringUtils.substringBeforeLast(statementName, ".");
   String dsName = shardStrategy.getShardIdentitiesByNamespace(namespace, parameterObject);
   if (dsName == null) {
     throw new IllegalStateException("无法找到相应的分库资源,请检查参数列表中是否有传分库字段值, 参数:" + parameterObject);
   }
   resultMap.put(dsName, shardDataSourceService.getDataSources().get(dsName));
   return resultMap;
 }