Skip to content

Commit

Permalink
Merge pull request #13 from fujitsu/microprofile-health-3.1
Browse files Browse the repository at this point in the history
Update health api version to 3.1
  • Loading branch information
kosakak authored Oct 8, 2021
2 parents 8706a7c + e60c45e commit 251dcfd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Fujitsu Limited and/or its affiliates. All rights
* Copyright (c) 2019-2021 Fujitsu Limited and/or its affiliates. All rights
* reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -11,20 +11,29 @@
package com.fujitsu.launcher.microprofile.health;

import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;

import io.smallrye.health.AsyncHealthCheckFactory;
import io.smallrye.health.registry.LivenessHealthRegistry;
import io.smallrye.health.registry.ReadinessHealthRegistry;
import io.smallrye.health.registry.StartupHealthRegistry;
import io.smallrye.health.registry.WellnessHealthRegistry;

/**
* Enables {@link HealthReporterProducer}.
*
*
* @author Takahiro Nagao
*/
public class HealthExtension implements Extension {

public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager bm) {
AnnotatedType<HealthReporterProducer> reporterProducer = bm.createAnnotatedType(HealthReporterProducer.class);
bbd.addAnnotatedType(reporterProducer, HealthReporterProducer.class.getName());
bbd.addAnnotatedType(bm.createAnnotatedType(AsyncHealthCheckFactory.class), AsyncHealthCheckFactory.class.getName());
bbd.addAnnotatedType(bm.createAnnotatedType(LivenessHealthRegistry.class), LivenessHealthRegistry.class.getName());
bbd.addAnnotatedType(bm.createAnnotatedType(ReadinessHealthRegistry.class), ReadinessHealthRegistry.class.getName());
bbd.addAnnotatedType(bm.createAnnotatedType(StartupHealthRegistry.class), StartupHealthRegistry.class.getName());
bbd.addAnnotatedType(bm.createAnnotatedType(WellnessHealthRegistry.class), WellnessHealthRegistry.class.getName());
bbd.addAnnotatedType(bm.createAnnotatedType(HealthReporterProducer.class), HealthReporterProducer.class.getName());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Fujitsu Limited and/or its affiliates. All rights
* Copyright (c) 2019-2021 Fujitsu Limited and/or its affiliates. All rights
* reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -26,7 +26,7 @@

/**
* Provides the health check endpoints.
*
*
* @author Takahiro Nagao
*/
@WebServlet
Expand All @@ -35,6 +35,7 @@ public class HealthServlet extends HttpServlet {
public static final String HEALTH = "/health";
public static final String HEALTH_LIVE = "/health/live";
public static final String HEALTH_READY = "/health/ready";
public static final String HEALTH_STARTED = "/health/started";

@Inject
private SmallRyeHealthReporter reporter;
Expand Down Expand Up @@ -62,6 +63,8 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
report(response, reporter.getLiveness());
} else if (HEALTH_READY.equals(path)) {
report(response, reporter.getReadiness());
} else if (HEALTH_STARTED.equals(path)) {
report(response, reporter.getStartup());
} else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.getWriter().write("Endpoint " + path + " not found");
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<mp.config.version>2.0</mp.config.version>
<mp.fault-tolerance.version>2.0.1</mp.fault-tolerance.version>
<mp.health.version>2.0.1</mp.health.version>
<mp.health.version>3.1</mp.health.version>
<mp.jwt-auth.version>1.2.2</mp.jwt-auth.version>
<mp.metrics.version>2.0.1</mp.metrics.version>
<mp.openapi.version>1.1.2</mp.openapi.version>
Expand All @@ -41,7 +41,7 @@
<jaxws-api.version>2.3.2</jaxws-api.version>
<smallrye.config.version>2.4.4</smallrye.config.version>
<smallrye.fault-tolerance.version>1.0.1</smallrye.fault-tolerance.version>
<smallrye.health.version>2.0.0</smallrye.health.version>
<smallrye.health.version>3.1.1</smallrye.health.version>
<smallrye.jwt.version>3.3.0</smallrye.jwt.version>
<smallrye.metrics.version>1.1.0</smallrye.metrics.version>
<smallrye.openapi.version>1.0.2</smallrye.openapi.version>
Expand Down

0 comments on commit 251dcfd

Please sign in to comment.