|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.sql.Connection;
|
20 | 20 | import java.sql.SQLException;
|
| 21 | +import java.util.Collections; |
21 | 22 | import java.util.HashMap;
|
22 | 23 | import java.util.Map;
|
23 | 24 |
|
@@ -164,6 +165,29 @@ else if (dataSource instanceof String) {
|
164 | 165 | }
|
165 | 166 | }
|
166 | 167 |
|
| 168 | + /** |
| 169 | + * Return the resolved target DataSources that this router manages. |
| 170 | + * @return an unmodifiable map of resolved lookup keys and DataSources |
| 171 | + * @throws IllegalStateException if the target DataSources are not resolved yet |
| 172 | + * @since 5.2.9 |
| 173 | + * @see #setTargetDataSources |
| 174 | + */ |
| 175 | + public Map<Object, DataSource> getResolvedDataSources() { |
| 176 | + Assert.state(this.resolvedDataSources != null, "DataSources not resolved yet - call afterPropertiesSet"); |
| 177 | + return Collections.unmodifiableMap(this.resolvedDataSources); |
| 178 | + } |
| 179 | + |
| 180 | + /** |
| 181 | + * Return the resolved default target DataSource, if any. |
| 182 | + * @return the default DataSource, or {@code null} if none or not resolved yet |
| 183 | + * @since 5.2.9 |
| 184 | + * @see #setDefaultTargetDataSource |
| 185 | + */ |
| 186 | + @Nullable |
| 187 | + public DataSource getResolvedDefaultDataSource() { |
| 188 | + return this.resolvedDefaultDataSource; |
| 189 | + } |
| 190 | + |
167 | 191 |
|
168 | 192 | @Override
|
169 | 193 | public Connection getConnection() throws SQLException {
|
|
0 commit comments