From 86e15fbd3e5082580e0692323d0b98cadbb7e6e2 Mon Sep 17 00:00:00 2001 From: Marco Bungart Date: Wed, 6 Mar 2024 20:19:32 +0100 Subject: [PATCH] Refactoring: extract constant for config key --- .../deployment/SmallRyeHealthProcessor.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java index 39d8fdb367df6..b6444f1cf3483 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java @@ -82,6 +82,8 @@ class SmallRyeHealthProcessor { private static final Logger LOG = Logger.getLogger(SmallRyeHealthProcessor.class); + private static final String CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED = "quarkus.smallrye-health.management.enabled"; + private static final DotName LIVENESS = DotName.createSimple(Liveness.class.getName()); private static final DotName READINESS = DotName.createSimple(Readiness.class.getName()); private static final DotName STARTUP = DotName.createSimple(Startup.class.getName()); @@ -211,7 +213,7 @@ public void defineHealthRoutes(BuildProducer routes, // Register the health handler routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .route(healthConfig.rootPath) .routeConfigKey("quarkus.smallrye-health.root-path") .handler(new SmallRyeHealthHandler()) @@ -220,7 +222,7 @@ public void defineHealthRoutes(BuildProducer routes, // Register the liveness handler routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .nestedRoute(healthConfig.rootPath, healthConfig.livenessPath) .handler(new SmallRyeLivenessHandler()) .displayOnNotFoundPage() @@ -228,7 +230,7 @@ public void defineHealthRoutes(BuildProducer routes, // Register the readiness handler routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .nestedRoute(healthConfig.rootPath, healthConfig.readinessPath) .handler(new SmallRyeReadinessHandler()) .displayOnNotFoundPage() @@ -236,7 +238,7 @@ public void defineHealthRoutes(BuildProducer routes, // Register the health group handlers routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .nestedRoute(healthConfig.rootPath, healthConfig.groupPath) .handler(new SmallRyeHealthGroupHandler()) .displayOnNotFoundPage() @@ -244,7 +246,7 @@ public void defineHealthRoutes(BuildProducer routes, SmallRyeIndividualHealthGroupHandler handler = new SmallRyeIndividualHealthGroupHandler(); routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .nestedRoute(healthConfig.rootPath, healthConfig.groupPath + "/*") .handler(handler) .displayOnNotFoundPage() @@ -252,7 +254,7 @@ public void defineHealthRoutes(BuildProducer routes, // Register the wellness handler routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .nestedRoute(healthConfig.rootPath, healthConfig.wellnessPath) .handler(new SmallRyeWellnessHandler()) .displayOnNotFoundPage() @@ -260,7 +262,7 @@ public void defineHealthRoutes(BuildProducer routes, // Register the startup handler routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .nestedRoute(healthConfig.rootPath, healthConfig.startupPath) .handler(new SmallRyeStartupHandler()) .displayOnNotFoundPage() @@ -420,7 +422,6 @@ void registerHealthUiHandler( LaunchModeBuildItem launchMode, SmallRyeHealthConfig healthConfig, BuildProducer smallryeHealthBuildProducer, ShutdownContextBuildItem shutdownContext) { - WebJarResultsBuildItem.WebJarResult result = webJarResultsBuildItem.byArtifactKey(HEALTH_UI_WEBJAR_ARTIFACT_KEY); if (result == null) { return; @@ -435,7 +436,7 @@ void registerHealthUiHandler( healthUiPath, result.getWebRootConfigurations(), runtimeConfig, shutdownContext); routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .route(healthConfig.ui.rootPath) .displayOnNotFoundPage("Health UI") .routeConfigKey("quarkus.smallrye-health.ui.root-path") @@ -443,7 +444,7 @@ void registerHealthUiHandler( .build()); routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder() - .management("quarkus.smallrye-health.management.enabled") + .management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED) .route(healthConfig.ui.rootPath + "*") .handler(handler) .build());