mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Rename SimpleDataSourceHealthIndicator
Rename SimpleDataSourceHealthIndicator to DataSourceHealthIndicator.
This commit is contained in:
parent
aa03d9a41c
commit
96a0d672af
@ -26,13 +26,13 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.actuate.health.CompositeHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.DataSourceHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthAggregator;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
|
||||
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.SimpleDataSourceHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
@ -100,15 +100,14 @@ public class HealthIndicatorAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "dbHealthIndicator")
|
||||
public HealthIndicator dbHealthIndicator() {
|
||||
if (this.dataSources.size() == 1) {
|
||||
return new SimpleDataSourceHealthIndicator(this.dataSources.values()
|
||||
.iterator().next());
|
||||
return new DataSourceHealthIndicator(this.dataSources.values().iterator()
|
||||
.next());
|
||||
}
|
||||
|
||||
CompositeHealthIndicator composite = new CompositeHealthIndicator(
|
||||
this.healthAggregator);
|
||||
for (Map.Entry<String, DataSource> entry : this.dataSources.entrySet()) {
|
||||
composite.addHealthIndicator(entry.getKey(),
|
||||
new SimpleDataSourceHealthIndicator(entry.getValue()));
|
||||
new DataSourceHealthIndicator(entry.getValue()));
|
||||
}
|
||||
return composite;
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Simple implementation of {@link HealthIndicator} that returns a status and also
|
||||
* attempts a simple database test.
|
||||
* {@link HealthIndicator} that tests the status of a {@link DataSource} and optionally
|
||||
* runs a test query.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
public class SimpleDataSourceHealthIndicator extends AbstractHealthIndicator {
|
||||
public class DataSourceHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
@ -55,17 +55,16 @@ public class SimpleDataSourceHealthIndicator extends AbstractHealthIndicator {
|
||||
private String query = null;
|
||||
|
||||
/**
|
||||
* Create a new {@link SimpleDataSourceHealthIndicator} instance.
|
||||
* Create a new {@link DataSourceHealthIndicator} instance.
|
||||
*/
|
||||
public SimpleDataSourceHealthIndicator() {
|
||||
public DataSourceHealthIndicator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link SimpleDataSourceHealthIndicator} using the specified
|
||||
* datasource.
|
||||
* Create a new {@link DataSourceHealthIndicator} using the specified datasource.
|
||||
* @param dataSource the data source
|
||||
*/
|
||||
public SimpleDataSourceHealthIndicator(DataSource dataSource) {
|
||||
public DataSourceHealthIndicator(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
@ -25,7 +25,7 @@ import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.SimpleDataSourceHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.DataSourceHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
@ -149,7 +149,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
assertEquals(1, beans.size());
|
||||
assertEquals(SimpleDataSourceHealthIndicator.class, beans.values().iterator()
|
||||
assertEquals(DataSourceHealthIndicator.class, beans.values().iterator()
|
||||
.next().getClass());
|
||||
}
|
||||
|
||||
|
@ -37,13 +37,13 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Tests for {@link SimpleDataSourceHealthIndicator}.
|
||||
* Tests for {@link DataSourceHealthIndicator}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SimpleDataSourceHealthIndicatorTests {
|
||||
public class DataSourceHealthIndicatorTests {
|
||||
|
||||
private final SimpleDataSourceHealthIndicator indicator = new SimpleDataSourceHealthIndicator();
|
||||
private final DataSourceHealthIndicator indicator = new DataSourceHealthIndicator();
|
||||
|
||||
private DriverManagerDataSource dataSource;
|
||||
|
Loading…
Reference in New Issue
Block a user