public class DataSourceHealthIndicator extends AbstractHealthIndicator implements org.springframework.beans.factory.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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHealth
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 org.springframework.beans.factory.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 © 2019 Pivotal Software, Inc.. All rights reserved.