1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.wa.starter.actuate;
20
21 import org.apache.syncope.common.rest.api.service.UserSelfService;
22 import org.apache.syncope.wa.bootstrap.WARestClient;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import org.springframework.boot.actuate.health.Health;
26 import org.springframework.boot.actuate.health.HealthIndicator;
27 import org.springframework.boot.actuate.health.Status;
28
29 public class SyncopeCoreHealthIndicator implements HealthIndicator {
30
31 protected static final Logger LOG = LoggerFactory.getLogger(SyncopeCoreHealthIndicator.class);
32
33 protected final WARestClient waRestClient;
34
35 public SyncopeCoreHealthIndicator(final WARestClient waRestClient) {
36 this.waRestClient = waRestClient;
37 }
38
39 @Override
40 public Health health() {
41 Health.Builder builder = new Health.Builder();
42
43 try {
44 waRestClient.getService(UserSelfService.class).read();
45 builder.status(Status.UP);
46 } catch (Exception e) {
47 LOG.debug("When attempting to connect to Syncope Core", e);
48 builder.status(Status.DOWN);
49 }
50
51 return builder.build();
52 }
53 }