public class DataSourceHealthIndicator extends AbstractHealthIndicator implements InitializingBean
HealthIndicator
that tests the status of a DataSource
and optionally
runs a test query.Constructor and Description |
---|
DataSourceHealthIndicator()
Create a new
DataSourceHealthIndicator instance. |
DataSourceHealthIndicator(DataSource dataSource)
Create a new
DataSourceHealthIndicator using the specified
DataSource . |
DataSourceHealthIndicator(DataSource dataSource,
String query)
Create a new
DataSourceHealthIndicator using the specified
DataSource and validation query. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
doHealthCheck(Health.Builder builder)
Actual health check logic.
|
String |
getQuery()
Return the validation query or
null . |
protected String |
getValidationQuery(String product) |
void |
setDataSource(DataSource dataSource)
Set the
DataSource to use. |
void |
setQuery(String query)
Set a specific validation query to use to validate a connection.
|
health
public DataSourceHealthIndicator()
DataSourceHealthIndicator
instance.public DataSourceHealthIndicator(DataSource dataSource)
DataSourceHealthIndicator
using the specified
DataSource
.dataSource
- the data sourcepublic DataSourceHealthIndicator(DataSource dataSource, String query)
DataSourceHealthIndicator
using the specified
DataSource
and validation query.dataSource
- the data sourcequery
- the validation query to use (can be null
)public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
protected void doHealthCheck(Health.Builder builder) throws Exception
AbstractHealthIndicator
doHealthCheck
in class AbstractHealthIndicator
builder
- the Health.Builder
to report health status and detailsException
- any Exception
that should create a Status.DOWN
system status.public void setDataSource(DataSource dataSource)
DataSource
to use.dataSource
- the data sourcepublic void setQuery(String query)
query
- the querypublic String getQuery()
null
.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.