From 39a1d15c4760a7d48b7f0e921ed3f792b3863b80 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Thu, 8 Aug 2024 11:39:04 +0200 Subject: [PATCH] Reorganize Hibernate Search management config for a Standalone mapper --- .../deployment/HibernateSearchStandaloneEnabled.java | 2 +- .../HibernateSearchStandaloneManagementEnabled.java | 9 ++------- .../HibernateSearchStandaloneProcessor.java | 7 ++++--- .../HibernateSearchStandaloneBuildTimeConfig.java | 6 ++++++ ...ateSearchStandaloneBuildTimeConfigManagement.java} | 11 ++++------- 5 files changed, 17 insertions(+), 18 deletions(-) rename extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/{management/HibernateSearchStandaloneManagementConfig.java => HibernateSearchStandaloneBuildTimeConfigManagement.java} (65%) diff --git a/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneEnabled.java b/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneEnabled.java index efd812577a5b0..ec3437fa25285 100644 --- a/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneEnabled.java +++ b/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneEnabled.java @@ -10,7 +10,7 @@ */ public class HibernateSearchStandaloneEnabled implements BooleanSupplier { - private final HibernateSearchStandaloneBuildTimeConfig config; + protected final HibernateSearchStandaloneBuildTimeConfig config; HibernateSearchStandaloneEnabled(HibernateSearchStandaloneBuildTimeConfig config) { this.config = config; diff --git a/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneManagementEnabled.java b/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneManagementEnabled.java index 45dcbeb708afa..cdac99e901a72 100644 --- a/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneManagementEnabled.java +++ b/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneManagementEnabled.java @@ -1,7 +1,6 @@ package io.quarkus.hibernate.search.standalone.elasticsearch.deployment; import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneBuildTimeConfig; -import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.management.HibernateSearchStandaloneManagementConfig; /** * Supplier that can be used to only run build steps @@ -9,17 +8,13 @@ */ public class HibernateSearchStandaloneManagementEnabled extends HibernateSearchStandaloneEnabled { - private final HibernateSearchStandaloneManagementConfig config; - - HibernateSearchStandaloneManagementEnabled(HibernateSearchStandaloneBuildTimeConfig config, - HibernateSearchStandaloneManagementConfig managementConfig) { + HibernateSearchStandaloneManagementEnabled(HibernateSearchStandaloneBuildTimeConfig config) { super(config); - this.config = managementConfig; } @Override public boolean getAsBoolean() { - return super.getAsBoolean() && config.enabled(); + return super.getAsBoolean() && config.management().enabled(); } } diff --git a/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneProcessor.java b/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneProcessor.java index e1357b9f3cb52..9b4f8b873bfba 100644 --- a/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneProcessor.java +++ b/extensions/hibernate-search-standalone-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/deployment/HibernateSearchStandaloneProcessor.java @@ -63,7 +63,6 @@ import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneBuildTimeConfig.ElasticsearchIndexBuildTimeConfig; import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneRecorder; import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneRuntimeConfig; -import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.management.HibernateSearchStandaloneManagementConfig; import io.quarkus.runtime.configuration.ConfigUtils; import io.quarkus.runtime.configuration.ConfigurationException; import io.quarkus.vertx.http.deployment.spi.RouteBuildItem; @@ -370,10 +369,12 @@ void devServices(Optional enabled, @BuildStep(onlyIf = HibernateSearchStandaloneManagementEnabled.class) void createManagementRoutes(BuildProducer routes, HibernateSearchStandaloneRecorder recorder, - HibernateSearchStandaloneManagementConfig managementConfig) { + HibernateSearchStandaloneBuildTimeConfig hibernateSearchStandaloneBuildTimeConfig) { + + String managementRootPath = hibernateSearchStandaloneBuildTimeConfig.management().rootPath(); routes.produce(RouteBuildItem.newManagementRoute( - managementConfig.rootPath() + (managementConfig.rootPath().endsWith("/") ? "" : "/") + "reindex") + managementRootPath + (managementRootPath.endsWith("/") ? "" : "/") + "reindex") .withRoutePathConfigKey("quarkus.hibernate-search-standalone.management.root-path") .withRequestHandler(recorder.managementHandler()) .displayOnNotFoundPage() diff --git a/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfig.java b/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfig.java index fc3de18ff9b91..466593d07f931 100644 --- a/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfig.java +++ b/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfig.java @@ -68,6 +68,12 @@ public interface HibernateSearchStandaloneBuildTimeConfig { */ Optional backgroundFailureHandler(); + /** + * Management interface. + */ + @ConfigDocSection + HibernateSearchStandaloneBuildTimeConfigManagement management(); + /** * Configuration related to the mapping. */ diff --git a/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/management/HibernateSearchStandaloneManagementConfig.java b/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfigManagement.java similarity index 65% rename from extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/management/HibernateSearchStandaloneManagementConfig.java rename to extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfigManagement.java index bc4e7f993f010..e16f4ec6fc634 100644 --- a/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/management/HibernateSearchStandaloneManagementConfig.java +++ b/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/HibernateSearchStandaloneBuildTimeConfigManagement.java @@ -1,13 +1,10 @@ -package io.quarkus.hibernate.search.standalone.elasticsearch.runtime.management; +package io.quarkus.hibernate.search.standalone.elasticsearch.runtime; -import io.quarkus.runtime.annotations.ConfigPhase; -import io.quarkus.runtime.annotations.ConfigRoot; -import io.smallrye.config.ConfigMapping; +import io.quarkus.runtime.annotations.ConfigGroup; import io.smallrye.config.WithDefault; -@ConfigMapping(prefix = "quarkus.hibernate-search-standalone.management") -@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface HibernateSearchStandaloneManagementConfig { +@ConfigGroup +public interface HibernateSearchStandaloneBuildTimeConfigManagement { /** * Root path for reindexing endpoints.