Skip to content

Commit

Permalink
Provide access to AbstractRoutingDataSource's resolved target DataSou…
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller authored and xcl(徐程林) committed Aug 16, 2020
1 parent 617c608 commit acfd5ec
Showing 1 changed file with 25 additions and 1 deletion.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -164,6 +165,29 @@ else if (dataSource instanceof String) {
}
}

/**
* Return the resolved target DataSources that this router manages.
* @return an unmodifiable map of resolved lookup keys and DataSources
* @throws IllegalStateException if the target DataSources are not resolved yet
* @since 5.2.9
* @see #setTargetDataSources
*/
public Map<Object, DataSource> getResolvedDataSources() {
Assert.state(this.resolvedDataSources != null, "DataSources not resolved yet - call afterPropertiesSet");
return Collections.unmodifiableMap(this.resolvedDataSources);
}

/**
* Return the resolved default target DataSource, if any.
* @return the default DataSource, or {@code null} if none or not resolved yet
* @since 5.2.9
* @see #setDefaultTargetDataSource
*/
@Nullable
public DataSource getResolvedDefaultDataSource() {
return this.resolvedDefaultDataSource;
}


@Override
public Connection getConnection() throws SQLException {
Expand Down

0 comments on commit acfd5ec

Please sign in to comment.