Fixing SDCListenerCustomIndicator issues
[ccsdk/cds.git] / ms / sdclistener / application / src / main / java / org / onap / ccsdk / cds / sdclistener / actuator / indicator / SDCListenerCustomIndicator.java
index 11fd2c2..5758512 100644 (file)
 
 package org.onap.ccsdk.cds.sdclistener.actuator.indicator;
 
-
 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse;
 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus;
 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.SDCListenerHealthCheck;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.health.AbstractHealthIndicator;
-import org.springframework.boot.actuate.health.Health.Builder;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.actuate.health.HealthIndicator;
 import org.springframework.stereotype.Component;
+
 /**
  * Health Indicator for SDCListener.
+ *
  * @author Shaaban Ebrahim
  * @version 1.0
  */
 @Component
-public class SDCListenerCustomIndicator extends AbstractHealthIndicator {
+public class SDCListenerCustomIndicator implements HealthIndicator {
+
+    @Autowired
+    private SDCListenerHealthCheck sDCListenerHealthCheck;
 
-  @Autowired
-  private SDCListenerHealthCheck sDCListenerHealthCheck;
+    @Override
+    public Health health() {
+        HealthApiResponse healthAPIResponse = sDCListenerHealthCheck.retrieveEndpointExecutionStatus();
+        if (healthAPIResponse.getStatus() == HealthCheckStatus.UP) {
 
-  @Override
-  protected void doHealthCheck(Builder builder) {
-    HealthApiResponse healthAPIResponse = sDCListenerHealthCheck.retrieveEndpointExecutionStatus();
-    if (healthAPIResponse.getStatus() == HealthCheckStatus.UP) {
-      builder.up();
-    } else {
-      builder.down();
+            return Health.up().withDetail("Services", healthAPIResponse.getChecks()).build();
+        }
+        return Health.down().build();
     }
-    builder.withDetail("Services", healthAPIResponse.getChecks());
-  }
 }