diff --git a/docs/modules/ROOT/pages/reference/extensions/openapi-java.adoc b/docs/modules/ROOT/pages/reference/extensions/openapi-java.adoc index a7441c199e36..a7d38d7cdc25 100644 --- a/docs/modules/ROOT/pages/reference/extensions/openapi-java.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/openapi-java.adoc @@ -77,7 +77,8 @@ Also, it can not use CDI injection in the RouteBuilder `configure()` since we ge |icon:lock[title=Fixed at build time] [[quarkus.camel.openapi.expose.enabled]]`link:#quarkus.camel.openapi.expose.enabled[quarkus.camel.openapi.expose.enabled]` -Expose the Camel REST DSL services to quarkus openapi at build time if 'quarkus.smallrye-openapi' is available. +When set to true, Camel REST DSL OpenAPI specifications are exposed under the Quarkus OpenAPI HTTP endpoint +(/q/openapi). This requires quarkus-smallrye-openapi to be added to your application. | `boolean` | `false` |=== diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java index 6a3d1b0dfaa1..d95ed848bd0e 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelContextProcessor.java @@ -196,7 +196,7 @@ public static final class EventBridgeEnabled implements BooleanSupplier { @Override public boolean getAsBoolean() { - return config.eventBridge.enabled; + return config.eventBridge().enabled(); } } @@ -205,7 +205,7 @@ public static final class SourceLocationEnabled implements BooleanSupplier { @Override public boolean getAsBoolean() { - return config.sourceLocationEnabled; + return config.sourceLocationEnabled(); } } @@ -214,7 +214,7 @@ public static final class TraceEnabled implements BooleanSupplier { @Override public boolean getAsBoolean() { - return config.trace.enabled || config.trace.standby; + return config.trace().enabled() || config.trace().standby(); } } } diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelNativeImageProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelNativeImageProcessor.java index 5d551123ff63..af3a58a0e30a 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelNativeImageProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelNativeImageProcessor.java @@ -176,6 +176,7 @@ List camelRuntimeCatalog( PathFilter.Builder::combine) .build(); + CamelConfig.RuntimeCatalogConfig runtimeCatalog = config.runtimeCatalog(); CamelSupport.services(archives, pathFilter) .filter(service -> service.name != null && service.type != null && service.path != null) .forEach(service -> { @@ -183,29 +184,29 @@ List camelRuntimeCatalog( String packageName = getPackageName(service.type); String jsonPath = String.format("META-INF/%s/%s.json", packageName.replace('.', '/'), service.name); - if (config.runtimeCatalog.components + if (runtimeCatalog.components() && service.path.startsWith(DefaultComponentResolver.RESOURCE_PATH)) { resources.add(new NativeImageResourceBuildItem(jsonPath)); } - if (config.runtimeCatalog.dataformats + if (runtimeCatalog.dataformats() && service.path.startsWith(DefaultDataFormatResolver.DATAFORMAT_RESOURCE_PATH)) { resources.add(new NativeImageResourceBuildItem(jsonPath)); } - if (config.runtimeCatalog.devconsoles + if (runtimeCatalog.devconsoles() && service.path.startsWith(DefaultDevConsoleResolver.DEV_CONSOLE_RESOURCE_PATH)) { resources.add(new NativeImageResourceBuildItem(jsonPath)); } - if (config.runtimeCatalog.languages + if (runtimeCatalog.languages() && service.path.startsWith(DefaultLanguageResolver.LANGUAGE_RESOURCE_PATH)) { resources.add(new NativeImageResourceBuildItem(jsonPath)); } - if (config.runtimeCatalog.transformers + if (runtimeCatalog.transformers() && service.path.startsWith(DefaultTransformerResolver.DATA_TYPE_TRANSFORMER_RESOURCE_PATH)) { resources.add(new NativeImageResourceBuildItem(jsonPath)); } }); - if (config.runtimeCatalog.models) { + if (runtimeCatalog.models()) { for (ApplicationArchive archive : archives.getAllApplicationArchives()) { for (Path root : archive.getRootDirectories()) { final Path resourcePath = root.resolve(CamelContextHelper.MODEL_DOCUMENTATION_PREFIX); @@ -237,20 +238,20 @@ List camelRuntimeCatalog( void reflection(CamelConfig config, ApplicationArchivesBuildItem archives, BuildProducer reflectiveClasses) { - final ReflectionConfig reflectionConfig = config.native_.reflection; - if (!reflectionConfig.includePatterns.isPresent()) { + final ReflectionConfig reflectionConfig = config.native_().reflection(); + if (reflectionConfig.includePatterns().isEmpty()) { LOGGER.debug("No classes registered for reflection via quarkus.camel.native.reflection.include-patterns"); return; } LOGGER.debug("Scanning resources for native inclusion from include-patterns {}", - reflectionConfig.includePatterns.get()); + reflectionConfig.includePatterns().get()); final PathFilter.Builder builder = new PathFilter.Builder(); - reflectionConfig.includePatterns.map(Collection::stream).orElseGet(Stream::empty) + reflectionConfig.includePatterns().map(Collection::stream).orElseGet(Stream::empty) .map(className -> className.replace('.', '/')) .forEach(builder::include); - reflectionConfig.excludePatterns.map(Collection::stream).orElseGet(Stream::empty) + reflectionConfig.excludePatterns().map(Collection::stream).orElseGet(Stream::empty) .map(className -> className.replace('.', '/')) .forEach(builder::exclude); final PathFilter pathFilter = builder.build(); diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java index 2a57f58be533..a56a587a2027 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java @@ -185,22 +185,24 @@ void userServicePatterns( CamelConfig camelConfig, BuildProducer services) { - camelConfig.service.discovery.includePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem( + CamelConfig.ServiceDiscoveryConfig discovery = camelConfig.service().discovery(); + discovery.includePatterns().ifPresent(list -> services.produce(new CamelServicePatternBuildItem( CamelServiceDestination.DISCOVERY, true, list))); - camelConfig.service.discovery.excludePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem( + discovery.excludePatterns().ifPresent(list -> services.produce(new CamelServicePatternBuildItem( CamelServiceDestination.DISCOVERY, false, list))); - camelConfig.service.registry.includePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem( + CamelConfig.ServiceRegistryConfig registry = camelConfig.service().registry(); + registry.includePatterns().ifPresent(list -> services.produce(new CamelServicePatternBuildItem( CamelServiceDestination.REGISTRY, true, list))); - camelConfig.service.registry.excludePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem( + registry.excludePatterns().ifPresent(list -> services.produce(new CamelServicePatternBuildItem( CamelServiceDestination.REGISTRY, false, list))); @@ -256,7 +258,7 @@ CamelTypeConverterRegistryBuildItem typeConverterRegistry( IndexView index = combinedIndex.getIndex(); RuntimeValue typeConverterRegistry = recorder - .createTypeConverterRegistry(config.typeConverter.statisticsEnabled); + .createTypeConverterRegistry(config.typeConverter().statisticsEnabled()); // // This should be simplified by searching for classes implementing TypeConverterLoader but that @@ -394,8 +396,8 @@ public List discoverRoutesBuilderClassNames( routesBuilderClassExcludes.stream() .map(RoutesBuilderClassExcludeBuildItem::getPattern) .collect(Collectors.toList())) - .exclude(camelConfig.routesDiscovery.excludePatterns) - .include(camelConfig.routesDiscovery.includePatterns) + .exclude(camelConfig.routesDiscovery().excludePatterns()) + .include(camelConfig.routesDiscovery().includePatterns()) .build().asDotNamePredicate(); return allKnownImplementors @@ -418,7 +420,7 @@ CamelComponentNameResolverBuildItem componentNameResolver( PathFilter pathFilter = new PathFilter.Builder() .include("META-INF/services/org/apache/camel/component/*") - .exclude(camelConfig.service.registry.excludePatterns) + .exclude(camelConfig.service().registry().excludePatterns()) .build(); Set componentNames = CamelSupport.services(applicationArchives, pathFilter) diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryProcessor.java index 72e858f6b89a..9b08e7e97a26 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryProcessor.java @@ -92,8 +92,8 @@ public void bindBeansToRegistry( PathFilter.Builder::new, (builder, patterns) -> builder.patterns(patterns.isInclude(), patterns.getPatterns()), PathFilter.Builder::combine) - .include(camelConfig.service.registry.includePatterns) - .exclude(camelConfig.service.registry.excludePatterns) + .include(camelConfig.service().registry().includePatterns()) + .exclude(camelConfig.service().registry().excludePatterns()) .build(); CamelSupport.services(applicationArchives, pathFilter) diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSerializationProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSerializationProcessor.java index fb94db5ac65d..c17844ed8e7f 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSerializationProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSerializationProcessor.java @@ -72,8 +72,8 @@ public class CamelSerializationProcessor { @BuildStep void produceSerializationBuildItem(CamelConfig config, BuildProducer serializationBuildItems) { - final CamelConfig.ReflectionConfig reflectionConfig = config.native_.reflection; - if (reflectionConfig.serializationEnabled) { + final CamelConfig.ReflectionConfig reflectionConfig = config.native_().reflection(); + if (reflectionConfig.serializationEnabled()) { LOGGER.debug( "Registration of basic types for serialization is enabled via quarkus.camel.native.reflection.serialization-enabled"); serializationBuildItems.produce(new CamelSerializationBuildItem()); diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainProcessor.java index cc6194f989e5..fe8d84fe2ca9 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainProcessor.java @@ -69,7 +69,7 @@ void unremovableBeans(BuildProducer beanProducer) { @BuildStep @Record(value = ExecutionTime.STATIC_INIT, optional = true) public CamelRoutesLoaderBuildItems.Registry routesLoader(CamelConfig config, CamelRecorder recorder) { - return config.routesDiscovery.enabled + return config.routesDiscovery().enabled() ? new CamelRoutesLoaderBuildItems.Registry(recorder.newDefaultRegistryRoutesLoader()) : new CamelRoutesLoaderBuildItems.Registry(recorder.newDisabledRegistryRoutesLoader()); } @@ -113,7 +113,7 @@ CamelMainBuildItem main( context.getCamelContext(), routesCollector.getValue(), beanContainer.getValue(), - config.arguments.onUnknown); + config.arguments().onUnknown()); for (CamelRoutesBuilderClassBuildItem item : routesBuilderClasses) { // don't add routes builders that are known by the container @@ -189,7 +189,7 @@ CamelRuntimeBuildItem runtime( recorder.createRuntime( beanContainer.getValue(), main.getInstance(), - camelMainConfig.shutdown.timeout.toMillis()), + camelMainConfig.shutdown().timeout().toMillis()), index.getIndex().getAnnotations(DotName.createSimple(QuarkusMain.class.getName())).isEmpty()); } diff --git a/extensions-core/core/runtime/pom.xml b/extensions-core/core/runtime/pom.xml index ac8d0907f26e..9e7e53381333 100644 --- a/extensions-core/core/runtime/pom.xml +++ b/extensions-core/core/runtime/pom.xml @@ -117,9 +117,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelBootstrapRecorder.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelBootstrapRecorder.java index 913e197562f5..7bf652a36a34 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelBootstrapRecorder.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelBootstrapRecorder.java @@ -40,7 +40,7 @@ public void run() { public void start(CamelRuntimeConfig camelRuntimeConfig, RuntimeValue runtime, Supplier arguments, String camelQuarkusVersion) { - if (camelRuntimeConfig.bootstrap.enabled) { + if (camelRuntimeConfig.bootstrap().enabled()) { try { Logger logger = Logger.getLogger(CamelBootstrapRecorder.class); logger.infof("Apache Camel Quarkus %s is starting", camelQuarkusVersion); diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java index d1617daa8f67..ca2ea5418e64 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java @@ -19,16 +19,16 @@ import java.util.List; import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; - -@ConfigRoot(name = "camel", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class CamelConfig { - - public enum FailureRemedy { - +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import io.smallrye.config.WithName; + +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel") +public interface CamelConfig { + enum FailureRemedy { fail, warn, ignore } @@ -37,32 +37,29 @@ public enum FailureRemedy { * * @asciidoclet */ - @ConfigItem - public ServiceConfig service; + ServiceConfig service(); /** * Build time configuration options for `org.apache.camel.catalog.RuntimeCamelCatalog`. * * @asciidoclet */ - @ConfigItem - public RuntimeCatalogConfig runtimeCatalog; + RuntimeCatalogConfig runtimeCatalog(); /** * Build time configuration options for routes discovery. * * @asciidoclet */ - @ConfigItem - public RoutesDiscoveryConfig routesDiscovery; + RoutesDiscoveryConfig routesDiscovery(); /** * Build time configuration options related to the building of native executable. * * @asciidoclet */ - @ConfigItem(name = "native") - public NativeConfig native_; + @WithName("native") + NativeConfig native_(); /** * Build time configuration options for the Camel CSimple language. @@ -70,59 +67,52 @@ public enum FailureRemedy { * @asciidoclet */ @Deprecated(forRemoval = true) - @ConfigItem - public CSimpleConfig csimple; + CSimpleConfig csimple(); /** * Build time configuration options for the extraction of Camel expressions. * * @asciidoclet */ - @ConfigItem - public ExpressionConfig expression; + ExpressionConfig expression(); /** * Build time configuration options for the Camel CDI event bridge. * * @asciidoclet */ - @ConfigItem - public EventBridgeConfig eventBridge; + EventBridgeConfig eventBridge(); /** * Build time configuration options for enable/disable camel source location. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean sourceLocationEnabled; + @WithDefault("false") + boolean sourceLocationEnabled(); /** * Build time configuration options for the Camel tracing. * * @asciidoclet */ - @ConfigItem - public TraceConfig trace; + TraceConfig trace(); /** * Build time configuration options for Camel type converters. * * @asciidoclet */ - @ConfigItem - public TypeConverterConfig typeConverter; - - @ConfigGroup - public static class RoutesDiscoveryConfig { + TypeConverterConfig typeConverter(); + interface RoutesDiscoveryConfig { /** * Enable automatic discovery of routes during static initialization. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); /** * Used for exclusive filtering scanning of RouteBuilder classes. The exclusive filtering takes precedence over @@ -134,8 +124,7 @@ public static class RoutesDiscoveryConfig { * * @asciidoclet */ - @ConfigItem - public Optional> excludePatterns; + Optional> excludePatterns(); /** * Used for inclusive filtering scanning of RouteBuilder classes. The exclusive filtering takes precedence over @@ -147,34 +136,27 @@ public static class RoutesDiscoveryConfig { * * @asciidoclet */ - @ConfigItem - public Optional> includePatterns; + Optional> includePatterns(); } - @ConfigGroup - public static class ServiceConfig { - + interface ServiceConfig { /** * Build time configuration related to discoverability of Camel services via the `org.apache.camel.spi.FactoryFinder` * mechanism * * @asciidoclet */ - @ConfigItem - public ServiceDiscoveryConfig discovery; + ServiceDiscoveryConfig discovery(); /** * Build time configuration related to registering of Camel services to the Camel registry * * @asciidoclet */ - @ConfigItem - public ServiceRegistryConfig registry; + ServiceRegistryConfig registry(); } - @ConfigGroup - public static class ServiceDiscoveryConfig { - + interface ServiceDiscoveryConfig { /** * A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The * services defined in the matching files will *not* be discoverable via the **`org.apache.camel.spi.FactoryFinder` @@ -187,8 +169,7 @@ public static class ServiceDiscoveryConfig { * * @asciidoclet */ - @ConfigItem - public Optional> excludePatterns; + Optional> excludePatterns(); /** * A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The @@ -202,13 +183,10 @@ public static class ServiceDiscoveryConfig { * * @asciidoclet */ - @ConfigItem - public Optional> includePatterns; + Optional> includePatterns(); } - @ConfigGroup - public static class ServiceRegistryConfig { - + interface ServiceRegistryConfig { /** * A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The * services defined in the matching files will *not* be added to Camel registry during application's static @@ -221,8 +199,7 @@ public static class ServiceRegistryConfig { * * @asciidoclet */ - @ConfigItem - public Optional> excludePatterns; + Optional> excludePatterns(); /** * A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The @@ -236,25 +213,19 @@ public static class ServiceRegistryConfig { * * @asciidoclet */ - @ConfigItem - public Optional> includePatterns; + Optional> includePatterns(); } - @ConfigGroup - public static class NativeConfig { - + interface NativeConfig { /** * Register classes for reflection. * * @asciidoclet */ - @ConfigItem - public ReflectionConfig reflection; + ReflectionConfig reflection(); } - @ConfigGroup - public static class ReflectionConfig { - + interface ReflectionConfig { /** * A comma separated list of Ant-path style patterns to match class names that should be *excluded* from registering for * reflection. Use the class name format as returned by the `java.lang.Class.getName()` method: package segments @@ -266,8 +237,7 @@ public static class ReflectionConfig { * * @asciidoclet */ - @ConfigItem - public Optional> excludePatterns; + Optional> excludePatterns(); /** * A comma separated list of Ant-path style patterns to match class names that should be registered for reflection. Use @@ -299,8 +269,7 @@ public static class ReflectionConfig { * * @asciidoclet */ - @ConfigItem - public Optional> includePatterns; + public Optional> includePatterns(); /** * If `true`, basic classes are registered for serialization; otherwise basic classes won't be registered automatically @@ -311,13 +280,11 @@ public static class ReflectionConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean serializationEnabled; + @WithDefault("false") + boolean serializationEnabled(); } - @ConfigGroup - public static class RuntimeCatalogConfig { - + interface RuntimeCatalogConfig { /** * If `true` the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel components * available in the application; otherwise component JSON schemas will not be available in the Runtime Camel Catalog and @@ -328,8 +295,8 @@ public static class RuntimeCatalogConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean components; + @WithDefault("true") + boolean components(); /** * If `true` the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel languages @@ -341,8 +308,8 @@ public static class RuntimeCatalogConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean languages; + @WithDefault("true") + boolean languages(); /** * If `true` the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel data formats @@ -354,8 +321,8 @@ public static class RuntimeCatalogConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean dataformats; + @WithDefault("true") + boolean dataformats(); /** * If `true` the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel dev consoles @@ -367,8 +334,8 @@ public static class RuntimeCatalogConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean devconsoles; + @WithDefault("true") + boolean devconsoles(); /** * If `true` the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel EIP models @@ -380,8 +347,8 @@ public static class RuntimeCatalogConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean models; + @WithDefault("true") + boolean models(); /** * If `true` the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel transformers @@ -393,36 +360,32 @@ public static class RuntimeCatalogConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean transformers; + @WithDefault("true") + boolean transformers(); } /** * @deprecated use {@link ExpressionConfig} instead */ @Deprecated(forRemoval = true) - @ConfigGroup - public static class CSimpleConfig { - + interface CSimpleConfig { /** * What to do if it is not possible to extract CSimple expressions from a route definition at build time. * * @asciidoclet */ - @ConfigItem(defaultValue = "warn") - public FailureRemedy onBuildTimeAnalysisFailure; + @WithDefault("warn") + FailureRemedy onBuildTimeAnalysisFailure(); } - @ConfigGroup - public static class ExpressionConfig { - + interface ExpressionConfig { /** * What to do if it is not possible to extract expressions from a route definition at build time. * * @asciidoclet */ - @ConfigItem(defaultValue = "warn") - public FailureRemedy onBuildTimeAnalysisFailure; + @WithDefault("warn") + FailureRemedy onBuildTimeAnalysisFailure(); /** * Indicates whether the expression extraction from the route definitions at build time must be done. If disabled, the @@ -430,13 +393,11 @@ public static class ExpressionConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean extractionEnabled; + @WithDefault("true") + boolean extractionEnabled(); } - @ConfigGroup - public static class EventBridgeConfig { - + interface EventBridgeConfig { /** * Whether to enable the bridging of Camel events to CDI events. * @@ -449,20 +410,18 @@ public static class EventBridgeConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); } - @ConfigGroup - public static class TraceConfig { - + interface TraceConfig { /** * Enables tracer in your Camel application. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean enabled; + @WithDefault("false") + boolean enabled(); /** * To set the tracer in standby mode, where the tracer will be installed, but not automatically enabled. The tracer can @@ -470,16 +429,16 @@ public static class TraceConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean standby; + @WithDefault("false") + boolean standby(); /** * Defines how many of the last messages to keep in the tracer. * * @asciidoclet */ - @ConfigItem(defaultValue = "1000") - public int backlogSize; + @WithDefault("1000") + int backlogSize(); /** * Whether all traced messages should be removed when the tracer is dumping. By default, the messages are removed, which @@ -487,16 +446,16 @@ public static class TraceConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean removeOnDump; + @WithDefault("true") + boolean removeOnDump(); /** * To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size. * * @asciidoclet */ - @ConfigItem(defaultValue = "131072") - public int bodyMaxChars; + @WithDefault("131072") + int bodyMaxChars(); /** * Whether to include the message body of stream based messages. If enabled then beware the stream may not be @@ -504,8 +463,8 @@ public static class TraceConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean bodyIncludeStreams; + @WithDefault("false") + boolean bodyIncludeStreams(); /** * Whether to include the message body of file based messages. The overhead is that the file content has to be read from @@ -513,76 +472,72 @@ public static class TraceConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean bodyIncludeFiles; + @WithDefault("true") + boolean bodyIncludeFiles(); /** * Whether to include the exchange properties in the traced message. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean includeExchangeProperties; + @WithDefault("true") + boolean includeExchangeProperties(); /** * Whether to include the exchange variables in the traced message. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean includeExchangeVariables; + @WithDefault("true") + boolean includeExchangeVariables(); /** * Whether to include the exception in the traced message in case of failed exchange. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean includeException; + @WithDefault("true") + boolean includeException(); /** * Whether to trace routes that is created from Rest DSL. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean traceRests; + @WithDefault("false") + boolean traceRests(); /** * Whether to trace routes that is created from route templates or kamelets. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean traceTemplates; + @WithDefault("false") + boolean traceTemplates(); /** * Filter for tracing by route or node id. * * @asciidoclet */ - @ConfigItem - public Optional tracePattern; + Optional tracePattern(); /** * Filter for tracing messages. * * @asciidoclet */ - @ConfigItem - public Optional traceFilter; + Optional traceFilter(); } - @ConfigGroup - public static class TypeConverterConfig { - + interface TypeConverterConfig { /** * Whether type converter statistics are enabled. By default, type converter utilization statistics are disabled. Note * that enabling statistics incurs a minor performance impact under very heavy load. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean statisticsEnabled; + @WithDefault("false") + boolean statisticsEnabled(); } } diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java index a4ef5f22949a..b944975b82c5 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java @@ -75,7 +75,7 @@ public RuntimeValue createContext( ExtendedCamelContext extendedCamelContext = context.getCamelContextExtension(); context.setApplicationContextClassLoader(tccl); extendedCamelContext.addContextPlugin(FactoryFinderResolver.class, factoryFinderResolver.getValue()); - extendedCamelContext.addContextPlugin(RuntimeCamelCatalog.class, new CamelRuntimeCatalog(config.runtimeCatalog)); + extendedCamelContext.addContextPlugin(RuntimeCamelCatalog.class, new CamelRuntimeCatalog(config.runtimeCatalog())); //variable repository factory depends on factoryFinder and classLoader, therefore has to be initialized afterwards extendedCamelContext.addContextPlugin(VariableRepositoryFactory.class, new DefaultVariableRepositoryFactory(context)); extendedCamelContext.setRegistry(registry.getValue()); @@ -138,25 +138,26 @@ public RuntimeValue createBacklogTracerCustomizer(CamelC context.setSourceLocationEnabled(true); // enable tracer on camel - context.setBacklogTracing(config.trace.enabled); - context.setBacklogTracingStandby(config.trace.standby); - context.setBacklogTracingTemplates(config.trace.traceTemplates); + CamelConfig.TraceConfig trace = config.trace(); + context.setBacklogTracing(trace.enabled()); + context.setBacklogTracingStandby(trace.standby()); + context.setBacklogTracingTemplates(trace.traceTemplates()); BacklogTracer tracer = BacklogTracer.createTracer(context); - tracer.setEnabled(config.trace.enabled); - tracer.setStandby(config.trace.standby); - tracer.setBacklogSize(config.trace.backlogSize); - tracer.setRemoveOnDump(config.trace.removeOnDump); - tracer.setBodyMaxChars(config.trace.bodyMaxChars); - tracer.setBodyIncludeStreams(config.trace.bodyIncludeStreams); - tracer.setBodyIncludeFiles(config.trace.bodyIncludeFiles); - tracer.setIncludeExchangeProperties(config.trace.includeExchangeProperties); - tracer.setIncludeExchangeVariables(config.trace.includeExchangeVariables); - tracer.setIncludeException(config.trace.includeException); - tracer.setTraceRests(config.trace.traceRests); - tracer.setTraceTemplates(config.trace.traceTemplates); - tracer.setTracePattern(config.trace.tracePattern.orElse(null)); - tracer.setTraceFilter(config.trace.traceFilter.orElse(null)); + tracer.setEnabled(trace.enabled()); + tracer.setStandby(trace.standby()); + tracer.setBacklogSize(trace.backlogSize()); + tracer.setRemoveOnDump(trace.removeOnDump()); + tracer.setBodyMaxChars(trace.bodyMaxChars()); + tracer.setBodyIncludeStreams(trace.bodyIncludeStreams()); + tracer.setBodyIncludeFiles(trace.bodyIncludeFiles()); + tracer.setIncludeExchangeProperties(trace.includeExchangeProperties()); + tracer.setIncludeExchangeVariables(trace.includeExchangeVariables()); + tracer.setIncludeException(trace.includeException()); + tracer.setTraceRests(trace.traceRests()); + tracer.setTraceTemplates(trace.traceTemplates()); + tracer.setTracePattern(trace.tracePattern().orElse(null)); + tracer.setTraceFilter(trace.traceFilter().orElse(null)); context.getCamelContextExtension().addContextPlugin(BacklogTracer.class, tracer); }); diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java index 04820f06f1d2..2963ba6348b2 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java @@ -27,7 +27,7 @@ public CamelRuntimeCatalog(CamelConfig.RuntimeCatalogConfig config) { @Override public String modelJSonSchema(String name) { - if (!config.models) { + if (!config.models()) { throw new RuntimeException( "Accessing model JSON schemas was disabled via quarkus.camel.runtime-catalog.models = false"); } @@ -37,7 +37,7 @@ public String modelJSonSchema(String name) { @Override public String componentJSonSchema(String name) { - if (!config.components) { + if (!config.components()) { throw new RuntimeException( "Accessing component JSON schemas was disabled via quarkus.camel.runtime-catalog.components = false"); } @@ -47,7 +47,7 @@ public String componentJSonSchema(String name) { @Override public String dataFormatJSonSchema(String name) { - if (!config.dataformats) { + if (!config.dataformats()) { throw new RuntimeException( "Accessing data format JSON schemas was disabled via quarkus.camel.runtime-catalog.dataformats = false"); } @@ -57,7 +57,7 @@ public String dataFormatJSonSchema(String name) { @Override public String languageJSonSchema(String name) { - if (!config.languages) { + if (!config.languages()) { throw new RuntimeException( "Accessing language JSON schemas was disabled via quarkus.camel.runtime-catalog.languages = false"); } diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeConfig.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeConfig.java index 7c22fb2c3914..b13804f675a9 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeConfig.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeConfig.java @@ -16,29 +16,28 @@ */ package org.apache.camel.quarkus.core; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel", phase = ConfigPhase.RUN_TIME) -public class CamelRuntimeConfig { +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +@ConfigMapping(prefix = "quarkus.camel") +public interface CamelRuntimeConfig { /** * Runtime configuration options for {@link CamelRuntime} bootstrap. * * @asciidoclet */ - @ConfigItem - public BootstrapConfig bootstrap; + BootstrapConfig bootstrap(); - @ConfigGroup - public static class BootstrapConfig { + interface BootstrapConfig { /** * When set to true, the {@link CamelRuntime} will be started automatically. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); } } diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainConfig.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainConfig.java index 87ab786b278f..27a5f594b4bb 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainConfig.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainConfig.java @@ -18,46 +18,40 @@ import java.time.Duration; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; import org.apache.camel.quarkus.core.CamelConfig.FailureRemedy; -@ConfigRoot(name = "camel.main", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class CamelMainConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.main") +public interface CamelMainConfig { /** * Build time configuration options for `CamelMain` shutdown. * * @asciidoclet */ - @ConfigItem - public ShutdownConfig shutdown; + ShutdownConfig shutdown(); /** * Build time configuration options for `CamelMain` arguments * * @asciidoclet */ - @ConfigItem - public ArgumentConfig arguments; - - @ConfigGroup - public static class ShutdownConfig { + ArgumentConfig arguments(); + interface ShutdownConfig { /** * A timeout (with millisecond precision) to wait for `CamelMain++#++stop()` to finish * * @asciidoclet */ - @ConfigItem(defaultValue = "PT3S") - public Duration timeout; + @WithDefault("PT3S") + Duration timeout(); } - @ConfigGroup - public static class ArgumentConfig { - + interface ArgumentConfig { /** * The action to take when `CamelMain` encounters an unknown argument. fail - Prints the `CamelMain` usage statement and * throws a `RuntimeException` ignore - Suppresses any warnings and the application startup proceeds as normal warn - @@ -65,7 +59,7 @@ public static class ArgumentConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "warn") - public FailureRemedy onUnknown; + @WithDefault("warn") + FailureRemedy onUnknown(); } } diff --git a/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java b/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java index dcad85e99dda..8461d504f39b 100644 --- a/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java +++ b/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java @@ -65,7 +65,7 @@ static class CliConnectorEnabled implements BooleanSupplier { CamelCliConnectorConfig config; public boolean getAsBoolean() { - return config.enabled; + return config.enabled(); } } } diff --git a/extensions-jvm/cli-connector/runtime/pom.xml b/extensions-jvm/cli-connector/runtime/pom.xml index 8d196ff98523..e0e80f6dc7da 100644 --- a/extensions-jvm/cli-connector/runtime/pom.xml +++ b/extensions-jvm/cli-connector/runtime/pom.xml @@ -70,9 +70,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java index 141d2d269086..61f2f7c2f231 100644 --- a/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java +++ b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java @@ -16,18 +16,19 @@ */ package org.apache.camel.quarkus.component.cli.connector; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.cli", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class CamelCliConnectorConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.cli") +public interface CamelCliConnectorConfig { /** * Sets whether to enable Camel CLI Connector support. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); } diff --git a/extensions-support/language/deployment/src/main/java/org/apache/camel/quarkus/support/language/deployment/LanguageSupportProcessor.java b/extensions-support/language/deployment/src/main/java/org/apache/camel/quarkus/support/language/deployment/LanguageSupportProcessor.java index 7f95d71d4099..0155b7c4c293 100644 --- a/extensions-support/language/deployment/src/main/java/org/apache/camel/quarkus/support/language/deployment/LanguageSupportProcessor.java +++ b/extensions-support/language/deployment/src/main/java/org/apache/camel/quarkus/support/language/deployment/LanguageSupportProcessor.java @@ -40,7 +40,8 @@ ExpressionExtractionResultBuildItem extractExpressions(CamelConfig config, List routesBuilderClasses, BuildProducer expressions, BuildProducer scripts) throws Exception { - if (config.expression.extractionEnabled) { + CamelConfig.ExpressionConfig expression = config.expression(); + if (expression.extractionEnabled()) { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (!(loader instanceof QuarkusClassLoader)) { throw new IllegalStateException( @@ -79,7 +80,7 @@ ExpressionExtractionResultBuildItem extractExpressions(CamelConfig config, } return new ExpressionExtractionResultBuildItem(true); } catch (Exception e) { - switch (config.expression.onBuildTimeAnalysisFailure) { + switch (expression.onBuildTimeAnalysisFailure()) { case fail: throw new RuntimeException( "Could not extract language expressions." @@ -93,7 +94,7 @@ ExpressionExtractionResultBuildItem extractExpressions(CamelConfig config, break; default: throw new IllegalStateException("Unexpected " + CamelConfig.FailureRemedy.class.getSimpleName() + ": " - + config.expression.onBuildTimeAnalysisFailure); + + expression.onBuildTimeAnalysisFailure()); } } } diff --git a/extensions/cxf-soap/deployment/pom.xml b/extensions/cxf-soap/deployment/pom.xml index 3e34c9067c07..c676f77a331c 100644 --- a/extensions/cxf-soap/deployment/pom.xml +++ b/extensions/cxf-soap/deployment/pom.xml @@ -57,9 +57,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfBuildTimeConfig.java b/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfBuildTimeConfig.java index c795ac0f123a..1c19bf801d3e 100644 --- a/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfBuildTimeConfig.java +++ b/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfBuildTimeConfig.java @@ -18,25 +18,22 @@ import java.util.List; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.cxf", phase = ConfigPhase.BUILD_TIME) -public class CxfBuildTimeConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +@ConfigMapping(prefix = "quarkus.camel.cxf") +public interface CxfBuildTimeConfig { /** * Configuration options related to build time class generation * * @asciidoclet */ - @ConfigItem - public ClassGeneration classGeneration; - - @ConfigGroup - public static class ClassGeneration { + ClassGeneration classGeneration(); + interface ClassGeneration { /** * For CXF service interfaces to work properly, some ancillary classes (such as request and response wrappers) need to * be generated at build time. Camel Quarkus lets the `quarkus-cxf` extension to do this for all service interfaces @@ -47,7 +44,7 @@ public static class ClassGeneration { * * @asciidoclet */ - @ConfigItem(defaultValue = "org.apache.cxf.ws.security.sts.provider.SecurityTokenService") - List excludePatterns; + @WithDefault("org.apache.cxf.ws.security.sts.provider.SecurityTokenService") + List excludePatterns(); } } diff --git a/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java b/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java index 7ffbadf04c51..b6cb4ad893de 100644 --- a/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java +++ b/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java @@ -80,9 +80,10 @@ void registerForReflection( * to pass a {@link ServiceSeiBuildItem} holding a service interface to {@code quarkus-cxf} ourselves. That's enough * for {@code quarkus-cxf} to generate the necessary ancillary classes for us. * - * @param combinedIndex - * @param endpointImplementations - * @param serviceSeis + * @param cxfBuildTimeConfig The {@link CxfBuildTimeConfig} instance + * @param combinedIndex The combined Jandex index + * @param endpointImplementations List of {@link CxfEndpointImplementationBuildItem} + * @param serviceSeis {@link BuildProducer} for {@link ServiceSeiBuildItem} */ @BuildStep void serviceSeis( @@ -92,7 +93,7 @@ void serviceSeis( BuildProducer serviceSeis) { final Builder b = new PathFilter.Builder(); - cxfBuildTimeConfig.classGeneration.excludePatterns + cxfBuildTimeConfig.classGeneration().excludePatterns() .stream() .map(pattern -> pattern.replace('.', '/')) .forEach(b::include); @@ -109,7 +110,7 @@ void serviceSeis( CxfDeploymentUtils.webServiceAnnotations(index) .map(annotation -> annotation.target().asClass()) .filter(wsClassInfo -> Modifier.isInterface(wsClassInfo.flags())) - .map(wsClassInfo -> wsClassInfo.name()) + .map(ClassInfo::name) .filter(seiFilter) .map(DotName::toString) .filter(intf -> !alreadyRegisteredInterfaces.contains(intf)) @@ -133,7 +134,7 @@ static void walkParents(IndexView index, DotName className, Set alreadyR if (cl.superName() != null) { walkParents(index, cl.superName(), alreadyRegisteredInterfaces); } - cl.interfaceNames().stream().forEach(intf -> walkParents(index, intf, alreadyRegisteredInterfaces)); + cl.interfaceNames().forEach(intf -> walkParents(index, intf, alreadyRegisteredInterfaces)); } @BuildStep diff --git a/extensions/debug/deployment/src/main/java/org/apache/camel/quarkus/component/debug/deployment/DebugProcessor.java b/extensions/debug/deployment/src/main/java/org/apache/camel/quarkus/component/debug/deployment/DebugProcessor.java index d2d0a56c22fd..c4ee4348b40a 100644 --- a/extensions/debug/deployment/src/main/java/org/apache/camel/quarkus/component/debug/deployment/DebugProcessor.java +++ b/extensions/debug/deployment/src/main/java/org/apache/camel/quarkus/component/debug/deployment/DebugProcessor.java @@ -55,7 +55,7 @@ CamelServicePatternBuildItem camelDebuggerFactoryServicePattern() { @BuildStep(onlyIf = DebugEnabled.class) void configureSystemProperties(BuildProducer producer, DebugConfig config) { producer.produce( - new SystemPropertyBuildItem(BacklogDebugger.SUSPEND_MODE_SYSTEM_PROP_NAME, Boolean.toString(config.suspend))); + new SystemPropertyBuildItem(BacklogDebugger.SUSPEND_MODE_SYSTEM_PROP_NAME, Boolean.toString(config.suspend()))); producer.produce(new SystemPropertyBuildItem(JmxSystemPropertyKeys.DISABLED, "false")); } @@ -65,7 +65,7 @@ static class DebugEnabled implements BooleanSupplier { @Override public boolean getAsBoolean() { - return (launchMode.equals(LaunchMode.DEVELOPMENT)) || (config.enabled + return (launchMode.equals(LaunchMode.DEVELOPMENT)) || (config.enabled() || ConfigProvider.getConfig().getOptionalValue("camel.debug.enabled", boolean.class).orElse(false)); } } diff --git a/extensions/debug/runtime/pom.xml b/extensions/debug/runtime/pom.xml index b2e0fba5dc7d..8b57c055aa52 100644 --- a/extensions/debug/runtime/pom.xml +++ b/extensions/debug/runtime/pom.xml @@ -67,9 +67,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/debug/runtime/src/main/java/org/apache/camel/quarkus/component/debug/DebugConfig.java b/extensions/debug/runtime/src/main/java/org/apache/camel/quarkus/component/debug/DebugConfig.java index 659ed57b67f6..e3ff6f9278df 100644 --- a/extensions/debug/runtime/src/main/java/org/apache/camel/quarkus/component/debug/DebugConfig.java +++ b/extensions/debug/runtime/src/main/java/org/apache/camel/quarkus/component/debug/DebugConfig.java @@ -18,16 +18,19 @@ import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.debug", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class DebugConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.debug") +public interface DebugConfig { /** * Set whether to enable Camel debugging support. * * @asciidoclet */ - public boolean enabled; + @WithDefault("false") + boolean enabled(); /** * Indicates whether the _suspend mode_ is enabled or not. If `true` the message processing is immediately suspended @@ -35,5 +38,6 @@ public class DebugConfig { * * @asciidoclet */ - public boolean suspend; + @WithDefault("false") + boolean suspend(); } diff --git a/extensions/fhir/runtime/pom.xml b/extensions/fhir/runtime/pom.xml index 421c462a6cf4..f742ddfd7769 100644 --- a/extensions/fhir/runtime/pom.xml +++ b/extensions/fhir/runtime/pom.xml @@ -96,9 +96,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirConfig.java b/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirConfig.java index b94f1e74af57..8239598a8953 100644 --- a/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirConfig.java +++ b/extensions/fhir/runtime/src/main/java/org/apache/camel/quarkus/component/fhir/FhirConfig.java @@ -16,58 +16,67 @@ */ package org.apache.camel.quarkus.component.fhir; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import io.smallrye.config.WithName; -@ConfigRoot(name = "camel.fhir", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public final class FhirConfig { +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.fhir") +public interface FhirConfig { /** * Enable FHIR DSTU2 Specs in native mode. * * @asciidoclet */ - @ConfigItem(name = "enable-dstu2", defaultValue = "false") - public boolean enableDstu2; + @WithName("enable-dstu2") + @WithDefault("false") + boolean enableDstu2(); /** * Enable FHIR DSTU2_HL7ORG Specs in native mode. * * @asciidoclet */ - @ConfigItem(name = "enable-dstu2_hl7org", defaultValue = "false") - public boolean enableDstu2Hl7Org; + @WithName("enable-dstu2_hl7org") + @WithDefault("false") + boolean enableDstu2Hl7Org(); /** * Enable FHIR DSTU2_1 Specs in native mode. * * @asciidoclet */ - @ConfigItem(name = "enable-dstu2_1", defaultValue = "false") - public boolean enableDstu2_1; + @WithName("enable-dstu2_1") + @WithDefault("false") + boolean enableDstu2_1(); /** * Enable FHIR DSTU3 Specs in native mode. * * @asciidoclet */ - @ConfigItem(name = "enable-dstu3", defaultValue = "false") - public boolean enableDstu3; + @WithName("enable-dstu3") + @WithDefault("false") + boolean enableDstu3(); /** * Enable FHIR R4 Specs in native mode. * * @asciidoclet */ - @ConfigItem(name = "enable-r4", defaultValue = "true") - public boolean enableR4; + @WithName("enable-r4") + @WithDefault("true") + boolean enableR4(); /** * Enable FHIR R5 Specs in native mode. * * @asciidoclet */ - @ConfigItem(name = "enable-r5", defaultValue = "false") - public boolean enableR5; + @WithName("enable-r5") + @WithDefault("false") + boolean enableR5(); } diff --git a/extensions/file-cluster-service/runtime/pom.xml b/extensions/file-cluster-service/runtime/pom.xml index f62690f4a3f3..92ba1e09e4d7 100644 --- a/extensions/file-cluster-service/runtime/pom.xml +++ b/extensions/file-cluster-service/runtime/pom.xml @@ -63,9 +63,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java b/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java index 271450756a67..ba989998b3e0 100644 --- a/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java +++ b/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java @@ -20,12 +20,14 @@ import java.util.Optional; import java.util.function.BooleanSupplier; -import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.cluster.file") -public class FileLockClusterServiceConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.cluster.file") +public interface FileLockClusterServiceConfig { /** * Whether a File Lock Cluster Service should be automatically configured according to * 'quarkus.camel.cluster.file.++*++' configurations. @@ -35,64 +37,57 @@ public class FileLockClusterServiceConfig { * @asciidoclet */ @Deprecated(since = "3.10.0", forRemoval = true) - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); /** * The cluster service ID (defaults to null). * * @asciidoclet */ - @ConfigItem - public Optional id; + Optional id(); /** * The root path (defaults to null). * * @asciidoclet */ - @ConfigItem - public Optional root; + Optional root(); /** * The service lookup order/priority (defaults to 2147482647). * * @asciidoclet */ - @ConfigItem - public Optional order; + Optional order(); /** * The custom attributes associated to the service (defaults to empty map). * * @asciidoclet */ - @ConfigItem - public Map attributes; + Map attributes(); /** * The time to wait before starting to try to acquire lock (defaults to 1000ms). * * @asciidoclet */ - @ConfigItem - public Optional acquireLockDelay; + Optional acquireLockDelay(); /** * The time to wait between attempts to try to acquire lock (defaults to 10000ms). * * @asciidoclet */ - @ConfigItem - public Optional acquireLockInterval; - - public static final class Enabled implements BooleanSupplier { + Optional acquireLockInterval(); + final class Enabled implements BooleanSupplier { FileLockClusterServiceConfig config; @Override public boolean getAsBoolean() { - return config.enabled; + return config.enabled(); } } } diff --git a/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java b/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java index 5744961c5d42..c9636063b88d 100644 --- a/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java +++ b/extensions/file-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java @@ -25,25 +25,21 @@ @Recorder public class FileLockClusterServiceRecorder { - public RuntimeValue createFileLockClusterService(FileLockClusterServiceConfig config) { FileLockClusterService flcs = new FileLockClusterService(); - config.id.ifPresent(id -> flcs.setId(id)); - config.root.ifPresent(root -> flcs.setRoot(root)); - config.order.ifPresent(order -> flcs.setOrder(order)); - config.acquireLockDelay.ifPresent(delay -> { + config.id().ifPresent(flcs::setId); + config.root().ifPresent(flcs::setRoot); + config.order().ifPresent(flcs::setOrder); + config.acquireLockDelay().ifPresent(delay -> { flcs.setAcquireLockDelay(TimePatternConverter.toMilliSeconds(delay), TimeUnit.MILLISECONDS); }); - config.acquireLockInterval.ifPresent(interval -> { + config.acquireLockInterval().ifPresent(interval -> { flcs.setAcquireLockInterval(TimePatternConverter.toMilliSeconds(interval), TimeUnit.MILLISECONDS); }); - config.attributes.forEach((key, value) -> { - flcs.setAttribute(key, value); - }); + config.attributes().forEach(flcs::setAttribute); - return new RuntimeValue(flcs); + return new RuntimeValue<>(flcs); } - } diff --git a/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java b/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java index 8cec413c34f8..8141df566f07 100644 --- a/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java +++ b/extensions/graphql/deployment/src/main/java/org/apache/camel/quarkus/component/graphql/deployment/GraphQLProcessor.java @@ -39,11 +39,11 @@ ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { @BuildStep void nativeImageResources(BuildProducer nativeImage, CamelGraphQLConfig config) { - if (!config.queryFiles.isPresent()) { + if (config.queryFiles().isEmpty()) { return; } - config.queryFiles.get() + config.queryFiles().get() .stream() .map(scriptFile -> new NativeImageResourceBuildItem(scriptFile.replace("classpath:", ""))) .forEach(nativeImage::produce); diff --git a/extensions/graphql/runtime/pom.xml b/extensions/graphql/runtime/pom.xml index 56a2a4c71ad8..e6d568aaa0bb 100644 --- a/extensions/graphql/runtime/pom.xml +++ b/extensions/graphql/runtime/pom.xml @@ -66,9 +66,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java b/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java index ee5134e1970a..978cf3d99cb9 100644 --- a/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java +++ b/extensions/graphql/runtime/src/main/java/org/apache/camel/quarkus/component/graphql/CamelGraphQLConfig.java @@ -19,13 +19,13 @@ import java.util.List; import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; -@ConfigRoot(name = "camel.graphql", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class CamelGraphQLConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.graphql") +public interface CamelGraphQLConfig { /** * A comma separated list of paths to files containing GraphQL queries for use by GraphQL endpoints. Query files that * only need to be accessible from the classpath should be specified on this property. Paths can either be schemeless @@ -34,6 +34,5 @@ public class CamelGraphQLConfig { * * @asciidoclet */ - @ConfigItem - public Optional> queryFiles; + Optional> queryFiles(); } diff --git a/extensions/grpc/deployment/src/main/java/org/apache/camel/quarkus/component/grpc/deployment/GrpcProcessor.java b/extensions/grpc/deployment/src/main/java/org/apache/camel/quarkus/component/grpc/deployment/GrpcProcessor.java index 0361b6b793dc..f04f98803205 100644 --- a/extensions/grpc/deployment/src/main/java/org/apache/camel/quarkus/component/grpc/deployment/GrpcProcessor.java +++ b/extensions/grpc/deployment/src/main/java/org/apache/camel/quarkus/component/grpc/deployment/GrpcProcessor.java @@ -73,7 +73,7 @@ FeatureBuildItem feature() { @BuildStep CamelGrpcServiceExcludesBuildItem camelGrpcServiceExcludes(GrpcBuildTimeConfig config) { - return new CamelGrpcServiceExcludesBuildItem(config.serviceExcludes.orElse(Collections.emptySet())); + return new CamelGrpcServiceExcludesBuildItem(config.serviceExcludes().orElse(Collections.emptySet())); } @BuildStep diff --git a/extensions/grpc/runtime/pom.xml b/extensions/grpc/runtime/pom.xml index 3da55355214d..4505d52884be 100644 --- a/extensions/grpc/runtime/pom.xml +++ b/extensions/grpc/runtime/pom.xml @@ -97,9 +97,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/grpc/runtime/src/main/java/org/apache/camel/quarkus/grpc/runtime/GrpcBuildTimeConfig.java b/extensions/grpc/runtime/src/main/java/org/apache/camel/quarkus/grpc/runtime/GrpcBuildTimeConfig.java index f5ade10762b2..146c19f4be9a 100644 --- a/extensions/grpc/runtime/src/main/java/org/apache/camel/quarkus/grpc/runtime/GrpcBuildTimeConfig.java +++ b/extensions/grpc/runtime/src/main/java/org/apache/camel/quarkus/grpc/runtime/GrpcBuildTimeConfig.java @@ -21,14 +21,14 @@ import java.util.Optional; import java.util.Set; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.grpc", phase = ConfigPhase.BUILD_TIME) -public class GrpcBuildTimeConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +@ConfigMapping(prefix = "quarkus.camel.grpc") +public interface GrpcBuildTimeConfig { /** * Excludes classes from the build time scanning of gRPC service classes. * This can be useful if there are gRPC services that you want to exclude from participating in Camel gRPC route @@ -43,20 +43,16 @@ public class GrpcBuildTimeConfig { * * @asciidoclet */ - @ConfigItem - public Optional> serviceExcludes; + Optional> serviceExcludes(); /** * Build time configuration options for Camel Quarkus gRPC code generator. * * @asciidoclet */ - @ConfigItem - public CodeGenConfig codegen; - - @ConfigGroup - public static class CodeGenConfig { + CodeGenConfig codegen(); + interface CodeGenConfig { /** * If `true`, Camel Quarkus gRPC code generation is run for .proto files discovered from the `proto` directory, or from * dependencies specified in the `scan-for-proto` or `scan-for-imports` options. When `false`, code generation for @@ -64,8 +60,8 @@ public static class CodeGenConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); /** * Camel Quarkus gRPC code generation can scan application dependencies for .proto files to generate Java stubs from @@ -77,8 +73,8 @@ public static class CodeGenConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "none") - public String scanForProto; + @WithDefault("none") + String scanForProto(); /** * Camel Quarkus gRPC code generation can scan dependencies for .proto files that can be imported by protos in this @@ -90,23 +86,21 @@ public static class CodeGenConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "com.google.protobuf:protobuf-java") - public String scanForImports; + @WithDefault("com.google.protobuf:protobuf-java") + String scanForImports(); /** * Package path or file glob pattern includes per dependency containing .proto files to be considered for inclusion. * * @asciidoclet */ - @ConfigItem - public Map> scanForProtoIncludes; + Map> scanForProtoIncludes(); /** * Package path or file glob pattern includes per dependency containing .proto files to be considered for exclusion. * * @asciidoclet */ - @ConfigItem - public Map> scanForProtoExcludes; + Map> scanForProtoExcludes(); } } diff --git a/extensions/jfr/runtime/pom.xml b/extensions/jfr/runtime/pom.xml index 1f8a6efb4037..f777461b7e59 100644 --- a/extensions/jfr/runtime/pom.xml +++ b/extensions/jfr/runtime/pom.xml @@ -63,9 +63,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/CamelJfrRecorder.java b/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/CamelJfrRecorder.java index 011e594c61ff..069b47bb1e0d 100644 --- a/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/CamelJfrRecorder.java +++ b/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/CamelJfrRecorder.java @@ -31,24 +31,24 @@ public RuntimeValue createStartupStepRecorder(RuntimeCam public void configure(CamelContext camelContext) { FlightRecorderStartupStepRecorder flightRecorder = new FlightRecorderStartupStepRecorder(); - if (config.startupRecorderRecording.isPresent()) { - flightRecorder.setRecording(config.startupRecorderRecording.get()); + if (config.startupRecorderRecording().isPresent()) { + flightRecorder.setRecording(config.startupRecorderRecording().get()); } - if (config.startupRecorderProfile.isPresent()) { - flightRecorder.setRecordingProfile(config.startupRecorderProfile.get()); + if (config.startupRecorderProfile().isPresent()) { + flightRecorder.setRecordingProfile(config.startupRecorderProfile().get()); } - if (config.startupRecorderMaxDepth.isPresent()) { - flightRecorder.setMaxDepth(config.startupRecorderMaxDepth.get()); + if (config.startupRecorderMaxDepth().isPresent()) { + flightRecorder.setMaxDepth(config.startupRecorderMaxDepth().get()); } - if (config.startupRecorderDuration.isPresent()) { - flightRecorder.setStartupRecorderDuration(config.startupRecorderDuration.get()); + if (config.startupRecorderDuration().isPresent()) { + flightRecorder.setStartupRecorderDuration(config.startupRecorderDuration().get()); } - if (config.startupRecorderDir.isPresent()) { - flightRecorder.setRecordingDir(config.startupRecorderDir.get()); + if (config.startupRecorderDir().isPresent()) { + flightRecorder.setRecordingDir(config.startupRecorderDir().get()); } camelContext.getCamelContextExtension().setStartupStepRecorder(flightRecorder); diff --git a/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/RuntimeCamelJfrConfig.java b/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/RuntimeCamelJfrConfig.java index e0a97e656003..5af6c13c24d2 100644 --- a/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/RuntimeCamelJfrConfig.java +++ b/extensions/jfr/runtime/src/main/java/org/apache/camel/quarkus/component/jfr/RuntimeCamelJfrConfig.java @@ -18,12 +18,13 @@ import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; -@ConfigRoot(name = "camel.jfr", phase = ConfigPhase.RUN_TIME) -public class RuntimeCamelJfrConfig { +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +@ConfigMapping(prefix = "quarkus.camel.jfr") +public interface RuntimeCamelJfrConfig { /** * Directory to store the recording. By default the current directory will be used. Use false to turn off saving the @@ -31,8 +32,7 @@ public class RuntimeCamelJfrConfig { * * @asciidoclet */ - @ConfigItem - Optional startupRecorderDir; + Optional startupRecorderDir(); /** * How long time to run the startup recorder. Use 0 (default) to keep the recorder running until the JVM is exited. Use @@ -42,8 +42,7 @@ public class RuntimeCamelJfrConfig { * * @asciidoclet */ - @ConfigItem - Optional startupRecorderDuration; + Optional startupRecorderDuration(); /** * To filter our sub steps at a maximum depth. Use -1 for no maximum. Use 0 for no sub steps. Use 1 for max 1 sub step, @@ -51,16 +50,14 @@ public class RuntimeCamelJfrConfig { * * @asciidoclet */ - @ConfigItem - Optional startupRecorderMaxDepth; + Optional startupRecorderMaxDepth(); /** * To use a specific Java Flight Recorder profile configuration, such as default or profile. The default is default. * * @asciidoclet */ - @ConfigItem - Optional startupRecorderProfile; + Optional startupRecorderProfile(); /** * To enable Java Flight Recorder to start a recording and automatic dump the recording to disk after startup is @@ -68,6 +65,5 @@ public class RuntimeCamelJfrConfig { * * @asciidoclet */ - @ConfigItem - Optional startupRecorderRecording; + Optional startupRecorderRecording(); } diff --git a/extensions/joor/deployment/src/main/java/org/apache/camel/quarkus/component/joor/deployment/JoorProcessor.java b/extensions/joor/deployment/src/main/java/org/apache/camel/quarkus/component/joor/deployment/JoorProcessor.java index b97ce0b86de4..8f3bd1a579e1 100644 --- a/extensions/joor/deployment/src/main/java/org/apache/camel/quarkus/component/joor/deployment/JoorProcessor.java +++ b/extensions/joor/deployment/src/main/java/org/apache/camel/quarkus/component/joor/deployment/JoorProcessor.java @@ -88,8 +88,8 @@ void collectExpressions(JoorExpressionConfig config, CamelContext ctx = new DefaultCamelContext(); try (JavaLanguage language = new JavaLanguage()) { language.setCamelContext(ctx); - language.setSingleQuotes(config.singleQuotes); - config.configResource.ifPresent(language::setConfigResource); + language.setSingleQuotes(config.singleQuotes()); + config.configResource().ifPresent(language::setConfigResource); language.setPreCompile(false); language.init(); JoorCompiler compiler = language.getCompiler(); @@ -200,7 +200,7 @@ public static final class CompileAtBuildTime implements BooleanSupplier { @Override public boolean getAsBoolean() { - return config.compileAtBuildTime || nativeConfig.enabled(); + return config.compileAtBuildTime() || nativeConfig.enabled(); } } } diff --git a/extensions/joor/runtime/pom.xml b/extensions/joor/runtime/pom.xml index 2c05e6d239cc..2fcb8181987b 100644 --- a/extensions/joor/runtime/pom.xml +++ b/extensions/joor/runtime/pom.xml @@ -67,9 +67,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionConfig.java b/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionConfig.java index 53d6f93f40fa..c0f86b2cf863 100644 --- a/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionConfig.java +++ b/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionConfig.java @@ -18,37 +18,37 @@ import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; /** * Build time configuration options for the Camel jOOR language. */ -@ConfigRoot(name = "camel.joor", phase = ConfigPhase.BUILD_TIME) -public class JoorExpressionConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.joor") +public interface JoorExpressionConfig { /** * Indicates whether a jOOR expression can use single quotes instead of double quotes. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean singleQuotes; + @WithDefault("true") + boolean singleQuotes(); /** * The specific location of the configuration of the jOOR language. * * @asciidoclet */ - @ConfigItem - public Optional configResource; + Optional configResource(); /** * In JVM mode, indicates whether the expressions must be compiled at build time. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean compileAtBuildTime; + @WithDefault("false") + boolean compileAtBuildTime(); } diff --git a/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionRecorder.java b/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionRecorder.java index cd8faaa372e3..985d85171ec9 100644 --- a/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionRecorder.java +++ b/extensions/joor/runtime/src/main/java/org/apache/camel/quarkus/component/joor/runtime/JoorExpressionRecorder.java @@ -31,8 +31,8 @@ public RuntimeValue languageNewInstance(JoorExpressionConfig confi RuntimeValue scriptingCompilerBuilder) { RuntimeValue language = new RuntimeValue<>( new JavaLanguage(compilerBuilder.getValue().build(), scriptingCompilerBuilder.getValue().build())); - language.getValue().setSingleQuotes(config.singleQuotes); - config.configResource.ifPresent(language.getValue()::setConfigResource); + language.getValue().setSingleQuotes(config.singleQuotes()); + config.configResource().ifPresent(language.getValue()::setConfigResource); return language; } diff --git a/extensions/kafka/runtime/pom.xml b/extensions/kafka/runtime/pom.xml index d9415bd42865..91c998595a59 100644 --- a/extensions/kafka/runtime/pom.xml +++ b/extensions/kafka/runtime/pom.xml @@ -71,9 +71,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRuntimeConfig.java b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRuntimeConfig.java index 62ae704de105..ba1862ebf83d 100644 --- a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRuntimeConfig.java +++ b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRuntimeConfig.java @@ -17,24 +17,25 @@ package org.apache.camel.quarkus.component.kafka; import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.kafka", phase = ConfigPhase.RUN_TIME) -public final class CamelKafkaRuntimeConfig { +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +@ConfigMapping(prefix = "quarkus.camel.kafka") +public interface CamelKafkaRuntimeConfig { /** * Kafka Kubernetes Service Binding configuration options * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public KafkaServiceBindingConfig kubernetesServiceBinding; + @WithDefault("true") + KafkaServiceBindingConfig kubernetesServiceBinding(); @ConfigGroup - public static final class KafkaServiceBindingConfig { - + interface KafkaServiceBindingConfig { /** * If `true` then any Kafka configuration properties discovered by the Quarkus Kubernetes Service Binding extension (if * configured) will be merged with those set via Camel Kafka component or endpoint options. If `false` then any Kafka @@ -43,7 +44,7 @@ public static final class KafkaServiceBindingConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean mergeConfiguration; + @WithDefault("true") + boolean mergeConfiguration(); } } diff --git a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/KafkaClientFactoryProducer.java b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/KafkaClientFactoryProducer.java index d049101cf809..9d1a713a7602 100644 --- a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/KafkaClientFactoryProducer.java +++ b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/KafkaClientFactoryProducer.java @@ -56,7 +56,7 @@ private boolean isQuarkusKafkaClientFactoryRequired() { Boolean.class); return kafkaConfig != null && !kafkaConfig.isEmpty() - && camelKafkaRuntimeConfig.kubernetesServiceBinding.mergeConfiguration + && camelKafkaRuntimeConfig.kubernetesServiceBinding().mergeConfiguration() && serviceBindingEnabled.isPresent() && serviceBindingEnabled.get(); } diff --git a/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java b/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java index 10d4b773c0ea..57b9e99368c9 100644 --- a/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java +++ b/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java @@ -76,7 +76,7 @@ void kameletNativeModeSupport( .getOptionalValues("camel.component.kamelet.location", String.class) .orElse(List.of("classpath:kamelets")); - Set identifiers = kameletConfig.identifiers + Set identifiers = kameletConfig.identifiers() .stream() .map(String::trim) .map(identifier -> identifier.replace(KAMELET_FILE_EXTENSION, "")) diff --git a/extensions/kamelet/runtime/pom.xml b/extensions/kamelet/runtime/pom.xml index 425448ebb5d6..a060aae2f51e 100644 --- a/extensions/kamelet/runtime/pom.xml +++ b/extensions/kamelet/runtime/pom.xml @@ -63,9 +63,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletConfiguration.java b/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletConfiguration.java index 4a4e4331073f..49ab55f133a4 100644 --- a/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletConfiguration.java +++ b/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletConfiguration.java @@ -18,12 +18,14 @@ import java.util.List; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.kamelet", phase = ConfigPhase.BUILD_TIME) -public class KameletConfiguration { +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +@ConfigMapping(prefix = "quarkus.camel.kamelet") +public interface KameletConfiguration { /** * Optional comma separated list of kamelet identifiers to configure for native mode support. * A kamelet identifier is the Kamelet file name without the .kamelet.yaml suffix. @@ -32,6 +34,6 @@ public class KameletConfiguration { * Note that this configuration option is only relevant when producing a native application. *

*/ - @ConfigItem(defaultValue = "*") - public List identifiers; + @WithDefault("*") + List identifiers(); } diff --git a/extensions/kubernetes-cluster-service/deployment/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/deployment/KubernetesClusterServiceProcessor.java b/extensions/kubernetes-cluster-service/deployment/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/deployment/KubernetesClusterServiceProcessor.java index 96a9c34b9a2c..7d2eaca6a225 100644 --- a/extensions/kubernetes-cluster-service/deployment/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/deployment/KubernetesClusterServiceProcessor.java +++ b/extensions/kubernetes-cluster-service/deployment/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/deployment/KubernetesClusterServiceProcessor.java @@ -39,7 +39,7 @@ CamelRuntimeBeanBuildItem setupKubernetesClusterService( KubernetesClusterServiceRuntimeConfig runtimeConfig, KubernetesClusterServiceRecorder recorder) { - if (buildTimeConfig.rebalancing) { + if (buildTimeConfig.rebalancing()) { final RuntimeValue krcs = recorder .createKubernetesRebalancingClusterService(runtimeConfig); return new CamelRuntimeBeanBuildItem("kubernetesRebalancingClusterService", diff --git a/extensions/kubernetes-cluster-service/runtime/pom.xml b/extensions/kubernetes-cluster-service/runtime/pom.xml index 8b5fab9dcedf..4248d9c8494e 100644 --- a/extensions/kubernetes-cluster-service/runtime/pom.xml +++ b/extensions/kubernetes-cluster-service/runtime/pom.xml @@ -75,9 +75,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceBuildTimeConfig.java b/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceBuildTimeConfig.java index f69a401c94d2..d2025a327fff 100644 --- a/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceBuildTimeConfig.java +++ b/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceBuildTimeConfig.java @@ -18,13 +18,14 @@ import java.util.function.BooleanSupplier; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.cluster.kubernetes", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class KubernetesClusterServiceBuildTimeConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.cluster.kubernetes") +public interface KubernetesClusterServiceBuildTimeConfig { /** * Whether a Kubernetes Cluster Service should be automatically configured according to * 'quarkus.camel.cluster.kubernetes.++*++' configurations. @@ -34,24 +35,23 @@ public class KubernetesClusterServiceBuildTimeConfig { * @asciidoclet */ @Deprecated(since = "3.10.0", forRemoval = true) - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); /** * Whether the camel master namespace leaders should be distributed evenly across all the camel contexts in the cluster. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean rebalancing; - - public static final class Enabled implements BooleanSupplier { + @WithDefault("true") + boolean rebalancing(); + final class Enabled implements BooleanSupplier { KubernetesClusterServiceBuildTimeConfig config; @Override public boolean getAsBoolean() { - return config.enabled; + return config.enabled(); } } } diff --git a/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRecorder.java b/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRecorder.java index 548cf332ff87..4079c7823c0a 100644 --- a/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRecorder.java +++ b/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRecorder.java @@ -26,7 +26,7 @@ public class KubernetesClusterServiceRecorder { public RuntimeValue createKubernetesClusterService(KubernetesClusterServiceRuntimeConfig config) { KubernetesClusterService kcs = setupKubernetesClusterServiceFromConfig(config); - return new RuntimeValue(kcs); + return new RuntimeValue<>(kcs); } public RuntimeValue createKubernetesRebalancingClusterService( @@ -34,26 +34,26 @@ public RuntimeValue createKubernetesRebalancingC KubernetesClusterService kcs = setupKubernetesClusterServiceFromConfig(config); RebalancingCamelClusterService rebalancingService = new RebalancingCamelClusterService(kcs, kcs.getRenewDeadlineMillis()); - return new RuntimeValue(rebalancingService); + return new RuntimeValue<>(rebalancingService); } private KubernetesClusterService setupKubernetesClusterServiceFromConfig(KubernetesClusterServiceRuntimeConfig config) { KubernetesClusterService clusterService = new KubernetesClusterService(); - config.id.ifPresent(clusterService::setId); - config.masterUrl.ifPresent(clusterService::setMasterUrl); - config.connectionTimeoutMillis.ifPresent(clusterService::setConnectionTimeoutMillis); - config.namespace.ifPresent(clusterService::setKubernetesNamespace); - config.podName.ifPresent(clusterService::setPodName); - config.jitterFactor.ifPresent(clusterService::setJitterFactor); - config.leaseDurationMillis.ifPresent(clusterService::setLeaseDurationMillis); - config.renewDeadlineMillis.ifPresent(clusterService::setRenewDeadlineMillis); - config.retryPeriodMillis.ifPresent(clusterService::setRetryPeriodMillis); - config.order.ifPresent(clusterService::setOrder); - config.resourceName.ifPresent(clusterService::setKubernetesResourceName); - config.leaseResourceType.ifPresent(clusterService::setLeaseResourceType); - - clusterService.setClusterLabels(config.labels); + config.id().ifPresent(clusterService::setId); + config.masterUrl().ifPresent(clusterService::setMasterUrl); + config.connectionTimeoutMillis().ifPresent(clusterService::setConnectionTimeoutMillis); + config.namespace().ifPresent(clusterService::setKubernetesNamespace); + config.podName().ifPresent(clusterService::setPodName); + config.jitterFactor().ifPresent(clusterService::setJitterFactor); + config.leaseDurationMillis().ifPresent(clusterService::setLeaseDurationMillis); + config.renewDeadlineMillis().ifPresent(clusterService::setRenewDeadlineMillis); + config.retryPeriodMillis().ifPresent(clusterService::setRetryPeriodMillis); + config.order().ifPresent(clusterService::setOrder); + config.resourceName().ifPresent(clusterService::setKubernetesResourceName); + config.leaseResourceType().ifPresent(clusterService::setLeaseResourceType); + + clusterService.setClusterLabels(config.labels()); return clusterService; } diff --git a/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRuntimeConfig.java b/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRuntimeConfig.java index b627523b4048..e57b19092816 100644 --- a/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRuntimeConfig.java +++ b/extensions/kubernetes-cluster-service/runtime/src/main/java/org/apache/camel/quarkus/component/kubernetes/cluster/KubernetesClusterServiceRuntimeConfig.java @@ -19,53 +19,48 @@ import java.util.Map; import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; import org.apache.camel.component.kubernetes.cluster.LeaseResourceType; -@ConfigRoot(name = "camel.cluster.kubernetes", phase = ConfigPhase.RUN_TIME) -public class KubernetesClusterServiceRuntimeConfig { - +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +@ConfigMapping(prefix = "quarkus.camel.cluster.kubernetes") +public interface KubernetesClusterServiceRuntimeConfig { /** * The cluster service ID (defaults to null). * * @asciidoclet */ - @ConfigItem - public Optional id; + Optional id(); /** * The URL of the Kubernetes master (read from Kubernetes client properties by default). * * @asciidoclet */ - @ConfigItem - public Optional masterUrl; + Optional masterUrl(); /** * The connection timeout in milliseconds to use when making requests to the Kubernetes API server. * * @asciidoclet */ - @ConfigItem - public Optional connectionTimeoutMillis; + Optional connectionTimeoutMillis(); /** * The name of the Kubernetes namespace containing the pods and the configmap (autodetected by default). * * @asciidoclet */ - @ConfigItem - public Optional namespace; + Optional namespace(); /** * The name of the current pod (autodetected from container host name by default). * * @asciidoclet */ - @ConfigItem - public Optional podName; + Optional podName(); /** * The jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant (defaults to @@ -73,16 +68,14 @@ public class KubernetesClusterServiceRuntimeConfig { * * @asciidoclet */ - @ConfigItem - public Optional jitterFactor; + Optional jitterFactor(); /** * The default duration of the lease for the current leader (defaults to 15000). * * @asciidoclet */ - @ConfigItem - public Optional leaseDurationMillis; + Optional leaseDurationMillis(); /** * The deadline after which the leader must stop its services because it may have lost the leadership (defaults to @@ -90,8 +83,7 @@ public class KubernetesClusterServiceRuntimeConfig { * * @asciidoclet */ - @ConfigItem - public Optional renewDeadlineMillis; + Optional renewDeadlineMillis(); /** * The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter @@ -99,16 +91,14 @@ public class KubernetesClusterServiceRuntimeConfig { * * @asciidoclet */ - @ConfigItem - public Optional retryPeriodMillis; + Optional retryPeriodMillis(); /** * Service lookup order/priority (defaults to 2147482647). * * @asciidoclet */ - @ConfigItem - public Optional order; + Optional order(); /** * The name of the lease resource used to do optimistic locking (defaults to 'leaders'). The resource name is used as @@ -116,22 +106,19 @@ public class KubernetesClusterServiceRuntimeConfig { * * @asciidoclet */ - @ConfigItem - public Optional resourceName; + Optional resourceName(); /** * The lease resource type used in Kubernetes, either 'config-map' or 'lease' (defaults to 'lease'). * * @asciidoclet */ - @ConfigItem - public Optional leaseResourceType; + Optional leaseResourceType(); /** * The labels key/value used to identify the pods composing the cluster, defaults to empty map. * * @asciidoclet */ - @ConfigItem - public Map labels; + Map labels(); } diff --git a/extensions/micrometer/runtime/pom.xml b/extensions/micrometer/runtime/pom.xml index 9e2a7ad16b57..28e44b6482b7 100644 --- a/extensions/micrometer/runtime/pom.xml +++ b/extensions/micrometer/runtime/pom.xml @@ -71,9 +71,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java index d10d224d0d84..94d9db32240c 100644 --- a/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java +++ b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java @@ -18,20 +18,21 @@ import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.metrics", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class CamelMicrometerConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.metrics") +public interface CamelMicrometerConfig { /** * Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enableRoutePolicy; + @WithDefault("true") + boolean enableRoutePolicy(); /** * Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing @@ -40,16 +41,16 @@ public class CamelMicrometerConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean enableMessageHistory; + @WithDefault("false") + boolean enableMessageHistory(); /** * Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times. * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enableExchangeEventNotifier; + @WithDefault("true") + boolean enableExchangeEventNotifier(); /** * Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total @@ -57,16 +58,16 @@ public class CamelMicrometerConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enableRouteEventNotifier; + @WithDefault("true") + boolean enableRouteEventNotifier(); /** * Set whether to gather performance information about Camel Thread Pools by injecting an InstrumentedThreadPoolFactory. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean enableInstrumentedThreadPoolFactory; + @WithDefault("false") + boolean enableInstrumentedThreadPoolFactory(); /** * Controls the naming style to use for metrics. The available values are `default` and `legacy`. `default` uses the @@ -74,8 +75,8 @@ public class CamelMicrometerConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "default") - public MetricsNamingStrategy namingStrategy; + @WithDefault("default") + MetricsNamingStrategy namingStrategy(); /** * Sets the level of metrics to capture. The available values are `all` ,`context` and `route`. `all` captures metrics @@ -84,24 +85,21 @@ public class CamelMicrometerConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "all") - public RoutePolicyLevel routePolicyLevel; + @WithDefault("all") + RoutePolicyLevel routePolicyLevel(); /** * Comma separated list of route IDs to exclude from metrics collection. * * @asciidoclet */ - @ConfigItem - public Optional routePolicyExcludePattern; - - public enum MetricsNamingStrategy { + Optional routePolicyExcludePattern(); + enum MetricsNamingStrategy { DEFAULT, LEGACY } - public enum RoutePolicyLevel { - + enum RoutePolicyLevel { ALL, CONTEXT, ROUTE } } diff --git a/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.java b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.java index 30158d1164f7..d1449bc9e165 100644 --- a/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.java +++ b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.java @@ -65,20 +65,20 @@ public MicrometerContextCustomizer(CamelMicrometerConfig config) { @Override public void configure(CamelContext camelContext) { - if (config.enableRoutePolicy) { + if (config.enableRoutePolicy()) { MicrometerRoutePolicyFactory factory = new MicrometerRoutePolicyFactory(); factory.setCamelContext(camelContext); camelContext.addRoutePolicyFactory(factory); - if (config.namingStrategy.equals(MetricsNamingStrategy.LEGACY)) { + if (config.namingStrategy().equals(MetricsNamingStrategy.LEGACY)) { factory.setNamingStrategy(MicrometerRoutePolicyNamingStrategy.LEGACY); } MicrometerRoutePolicyConfiguration policyConfiguration = factory.getPolicyConfiguration(); - if (config.routePolicyLevel.equals(RoutePolicyLevel.ALL)) { + if (config.routePolicyLevel().equals(RoutePolicyLevel.ALL)) { factory.getPolicyConfiguration().setContextEnabled(true); factory.getPolicyConfiguration().setRouteEnabled(true); - } else if (config.routePolicyLevel.equals(RoutePolicyLevel.CONTEXT)) { + } else if (config.routePolicyLevel().equals(RoutePolicyLevel.CONTEXT)) { factory.getPolicyConfiguration().setContextEnabled(true); factory.getPolicyConfiguration().setRouteEnabled(false); } else { @@ -86,21 +86,21 @@ public void configure(CamelContext camelContext) { policyConfiguration.setRouteEnabled(true); } - config.routePolicyExcludePattern.ifPresent(policyConfiguration::setExcludePattern); + config.routePolicyExcludePattern().ifPresent(policyConfiguration::setExcludePattern); } ManagementStrategy managementStrategy = camelContext.getManagementStrategy(); - if (config.enableExchangeEventNotifier) { + if (config.enableExchangeEventNotifier()) { MicrometerExchangeEventNotifier eventNotifier = new MicrometerExchangeEventNotifier(); - if (config.namingStrategy.equals(MetricsNamingStrategy.LEGACY)) { + if (config.namingStrategy().equals(MetricsNamingStrategy.LEGACY)) { eventNotifier.setNamingStrategy(MicrometerExchangeEventNotifierNamingStrategy.LEGACY); } managementStrategy.addEventNotifier(eventNotifier); } - if (config.enableRouteEventNotifier) { + if (config.enableRouteEventNotifier()) { MicrometerRouteEventNotifier eventNotifier = new MicrometerRouteEventNotifier(); - if (config.namingStrategy.equals(MetricsNamingStrategy.LEGACY)) { + if (config.namingStrategy().equals(MetricsNamingStrategy.LEGACY)) { eventNotifier.setNamingStrategy(MicrometerRouteEventNotifierNamingStrategy.LEGACY); } managementStrategy.addEventNotifier(eventNotifier); @@ -119,13 +119,13 @@ public MicrometerRuntimeContextCustomizer(CamelMicrometerConfig config, MeterReg @Override public void configure(CamelContext camelContext) { - if (config.enableInstrumentedThreadPoolFactory) { + if (config.enableInstrumentedThreadPoolFactory()) { InstrumentedThreadPoolFactory instrumentedThreadPoolFactory = new InstrumentedThreadPoolFactory(meterRegistry, camelContext.getExecutorServiceManager().getThreadPoolFactory()); camelContext.getExecutorServiceManager().setThreadPoolFactory(instrumentedThreadPoolFactory); } - if (!config.enableMessageHistory) { + if (!config.enableMessageHistory()) { return; } @@ -134,7 +134,7 @@ public void configure(CamelContext camelContext) { } MicrometerMessageHistoryFactory messageHistoryFactory = new MicrometerMessageHistoryFactory(); - if (config.namingStrategy.equals(MetricsNamingStrategy.LEGACY)) { + if (config.namingStrategy().equals(MetricsNamingStrategy.LEGACY)) { messageHistoryFactory.setNamingStrategy(MicrometerMessageHistoryNamingStrategy.LEGACY); } camelContext.setMessageHistoryFactory(messageHistoryFactory); diff --git a/extensions/microprofile-health/deployment/src/main/java/org/apache/camel/quarkus/component/microprofile/health/deployment/MicroProfileHealthProcessor.java b/extensions/microprofile-health/deployment/src/main/java/org/apache/camel/quarkus/component/microprofile/health/deployment/MicroProfileHealthProcessor.java index cce62463de09..1be7493e4f6a 100644 --- a/extensions/microprofile-health/deployment/src/main/java/org/apache/camel/quarkus/component/microprofile/health/deployment/MicroProfileHealthProcessor.java +++ b/extensions/microprofile-health/deployment/src/main/java/org/apache/camel/quarkus/component/microprofile/health/deployment/MicroProfileHealthProcessor.java @@ -69,7 +69,7 @@ public boolean getAsBoolean() { .getOptionalValue("camel.health.enabled", boolean.class) .orElse(true); - return !mpHealthDisabled && camelHealthEnabled && camelHealthConfig.enabled + return !mpHealthDisabled && camelHealthEnabled && camelHealthConfig.enabled() && quarkusHealthConfig.enabled; } } diff --git a/extensions/microprofile-health/runtime/pom.xml b/extensions/microprofile-health/runtime/pom.xml index dd4ccf26f3ae..e4912d3345f1 100644 --- a/extensions/microprofile-health/runtime/pom.xml +++ b/extensions/microprofile-health/runtime/pom.xml @@ -68,9 +68,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/microprofile-health/runtime/src/main/java/org/apache/camel/quarkus/component/microprofile/health/runtime/CamelMicroProfileHealthConfig.java b/extensions/microprofile-health/runtime/src/main/java/org/apache/camel/quarkus/component/microprofile/health/runtime/CamelMicroProfileHealthConfig.java index 92e023b1f76d..ef5af07c759e 100644 --- a/extensions/microprofile-health/runtime/src/main/java/org/apache/camel/quarkus/component/microprofile/health/runtime/CamelMicroProfileHealthConfig.java +++ b/extensions/microprofile-health/runtime/src/main/java/org/apache/camel/quarkus/component/microprofile/health/runtime/CamelMicroProfileHealthConfig.java @@ -16,18 +16,19 @@ */ package org.apache.camel.quarkus.component.microprofile.health.runtime; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.health", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public final class CamelMicroProfileHealthConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.health") +public interface CamelMicroProfileHealthConfig { /** * Set whether to enable Camel health checks * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); } diff --git a/extensions/openapi-java/deployment/pom.xml b/extensions/openapi-java/deployment/pom.xml index b68a78a4904a..e5213db3c565 100644 --- a/extensions/openapi-java/deployment/pom.xml +++ b/extensions/openapi-java/deployment/pom.xml @@ -91,9 +91,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaBuildTimeConfig.java b/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaBuildTimeConfig.java index 765dbb7679b8..c8102288a1e2 100644 --- a/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaBuildTimeConfig.java +++ b/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaBuildTimeConfig.java @@ -16,17 +16,27 @@ */ package org.apache.camel.quarkus.component.openapi.java.deployment; -import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.openapi") -public class OpenApiJavaBuildTimeConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +@ConfigMapping(prefix = "quarkus.camel.openapi") +interface OpenApiJavaBuildTimeConfig { /** - * Expose the Camel REST DSL services to quarkus openapi at build time if 'quarkus.smallrye-openapi' is available. + * Build time configuration options for Camel REST DSL OpenAPI specifications. * * @asciidoclet */ - @ConfigItem(name = "expose.enabled", defaultValue = "false") - public boolean enabled = false; + Exposure expose(); + + interface Exposure { + /** + * When set to true, Camel REST DSL OpenAPI specifications are exposed under the Quarkus OpenAPI HTTP endpoint + * (/q/openapi). This requires quarkus-smallrye-openapi to be added to your application. + */ + @WithDefault("false") + boolean enabled(); + } } diff --git a/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java b/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java index 95da4b0e54b9..0f9f3082d4a4 100644 --- a/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java +++ b/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java @@ -196,7 +196,7 @@ public static final class ExposeOpenApiEnabled implements BooleanSupplier { @Override public boolean getAsBoolean() { - return config.enabled; + return config.expose().enabled(); } } } diff --git a/extensions/opentelemetry/runtime/pom.xml b/extensions/opentelemetry/runtime/pom.xml index 7600f27be962..659e73448ea9 100644 --- a/extensions/opentelemetry/runtime/pom.xml +++ b/extensions/opentelemetry/runtime/pom.xml @@ -77,9 +77,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/CamelOpenTelemetryConfig.java b/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/CamelOpenTelemetryConfig.java index 9dcde8021252..6809e5d23fca 100644 --- a/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/CamelOpenTelemetryConfig.java +++ b/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/CamelOpenTelemetryConfig.java @@ -18,12 +18,14 @@ import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.opentelemetry", phase = ConfigPhase.RUN_TIME) -public final class CamelOpenTelemetryConfig { +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +@ConfigMapping(prefix = "quarkus.camel.opentelemetry") +public interface CamelOpenTelemetryConfig { /** * Sets whether header names need to be encoded. Can be useful in situations where OpenTelemetry propagators potentially @@ -32,8 +34,8 @@ public final class CamelOpenTelemetryConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean encoding; + @WithDefault("false") + boolean encoding(); /** * Sets whether to disable tracing for endpoint URIs or Processor ids that match the given comma separated patterns. The @@ -47,8 +49,7 @@ public final class CamelOpenTelemetryConfig { * * @asciidoclet */ - @ConfigItem - public Optional excludePatterns; + Optional excludePatterns(); /** * Sets whether to create new OpenTelemetry spans for each Camel Processor. Use the excludePatterns property to filter @@ -56,6 +57,6 @@ public final class CamelOpenTelemetryConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean traceProcessors; + @WithDefault("false") + boolean traceProcessors(); } diff --git a/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/OpenTelemetryTracerProducer.java b/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/OpenTelemetryTracerProducer.java index 7b6ea59435d1..db1d4d8765f1 100644 --- a/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/OpenTelemetryTracerProducer.java +++ b/extensions/opentelemetry/runtime/src/main/java/org/apache/camel/quarkus/component/opentelemetry/OpenTelemetryTracerProducer.java @@ -46,17 +46,17 @@ public OpenTelemetryTracer getOpenTelemetry() { OpenTelemetryTracer openTelemetryTracer = new CamelQuarkusOpenTelemetryTracer(); if (tracer != null) { openTelemetryTracer.setTracer(tracer); - if (config.excludePatterns.isPresent()) { - openTelemetryTracer.setExcludePatterns(config.excludePatterns.get()); + if (config.excludePatterns().isPresent()) { + openTelemetryTracer.setExcludePatterns(config.excludePatterns().get()); } - if (config.traceProcessors) { + if (config.traceProcessors()) { OpenTelemetryTracingStrategy tracingStrategy = new OpenTelemetryTracingStrategy(openTelemetryTracer); tracingStrategy.setPropagateContext(true); openTelemetryTracer.setTracingStrategy(tracingStrategy); } - openTelemetryTracer.setEncoding(config.encoding); + openTelemetryTracer.setEncoding(config.encoding()); } return openTelemetryTracer; } diff --git a/extensions/rest-openapi/runtime/pom.xml b/extensions/rest-openapi/runtime/pom.xml index 89c84c9f047b..e414f2c58627 100644 --- a/extensions/rest-openapi/runtime/pom.xml +++ b/extensions/rest-openapi/runtime/pom.xml @@ -70,9 +70,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/rest-openapi/runtime/src/main/java/org/apache/camel/quarkus/rest/openapi/runtime/RestOpenApiBuildTimeConfig.java b/extensions/rest-openapi/runtime/src/main/java/org/apache/camel/quarkus/rest/openapi/runtime/RestOpenApiBuildTimeConfig.java index 2a70dae1596c..0b1c00d48936 100644 --- a/extensions/rest-openapi/runtime/src/main/java/org/apache/camel/quarkus/rest/openapi/runtime/RestOpenApiBuildTimeConfig.java +++ b/extensions/rest-openapi/runtime/src/main/java/org/apache/camel/quarkus/rest/openapi/runtime/RestOpenApiBuildTimeConfig.java @@ -20,24 +20,23 @@ import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.openapi", phase = ConfigPhase.BUILD_TIME) -public class RestOpenApiBuildTimeConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +@ConfigMapping(prefix = "quarkus.camel.openapi") +public interface RestOpenApiBuildTimeConfig { /** * Build time configuration options for Camel Quarkus REST OpenAPI code generator. * * @asciidoclet */ - @ConfigItem - public CodeGenConfig codegen; + CodeGenConfig codegen(); @ConfigGroup - public static class CodeGenConfig { - + interface CodeGenConfig { /** * If `true`, Camel Quarkus OpenAPI code generation is run for .json and .yaml files discovered from the `openapi` * directory. When @@ -45,63 +44,60 @@ public static class CodeGenConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "true") - public boolean enabled; + @WithDefault("true") + boolean enabled(); /** * The package to use for generated model classes. * * @asciidoclet */ - @ConfigItem(defaultValue = "org.apache.camel.quarkus") - public String modelPackage; + @WithDefault("org.apache.camel.quarkus") + String modelPackage(); /** * A comma separated list of models to generate. The default is empty list for all models. * * @asciidoclet */ - @ConfigItem - public Optional models; + Optional models(); /** * If `true`, use bean validation annotations in the generated model classes. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean useBeanValidation; + @WithDefault("false") + boolean useBeanValidation(); /** * If `true`, use NON_NULL Jackson annotation in the generated model classes. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean notNullJackson; + @WithDefault("false") + boolean notNullJackson(); /** * If `true`, use JsonIgnoreProperties(ignoreUnknown = true) annotation in the generated model classes. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean ignoreUnknownProperties; + @WithDefault("false") + boolean ignoreUnknownProperties(); /** * Additional properties to be used in the mustache templates. * * @asciidoclet */ - @ConfigItem - public Map additionalProperties; + Map additionalProperties(); /** * A comma separated list of OpenAPI spec locations. * * @asciidoclet */ - @ConfigItem - public Optional locations; + Optional locations(); } } diff --git a/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java b/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java index a7ab69969f7b..6c86c4bbb8ae 100644 --- a/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java +++ b/extensions/servlet/deployment/src/main/java/org/apache/camel/quarkus/component/servlet/deployment/ServletProcessor.java @@ -55,13 +55,13 @@ void build(BuildProducer servlet, WebMetadataBuildItem webMeta .anyMatch(meta -> meta.getServletClass().equals(DEFAULT_SERVLET_CLASS)); } - if (camelServletConfig.defaultServlet.isValid()) { + if (camelServletConfig.defaultServlet().isValid()) { servlet.produce( - newServlet(ServletConfig.DEFAULT_SERVLET_NAME, camelServletConfig.defaultServlet)); + newServlet(ServletConfig.DEFAULT_SERVLET_NAME, camelServletConfig.defaultServlet())); servletCreated = true; } - for (Entry e : camelServletConfig.namedServlets.entrySet()) { + for (Entry e : camelServletConfig.namedServlets().entrySet()) { if (ServletConfig.DEFAULT_SERVLET_NAME.equals(e.getKey())) { throw new IllegalStateException( String.format("Use quarkus.camel.servlet.url-patterns instead of quarkus.camel.servlet.%s.url-patterns", @@ -79,43 +79,43 @@ void build(BuildProducer servlet, WebMetadataBuildItem webMeta static ServletBuildItem newServlet(String key, ServletConfig servletConfig) { final String servletName = servletConfig.getEffectiveServletName(key); - final Optional> urlPatterns = servletConfig.urlPatterns; + final Optional> urlPatterns = servletConfig.urlPatterns(); if (!urlPatterns.isPresent() || urlPatterns.get().isEmpty()) { throw new IllegalStateException( String.format("Missing quarkus.camel.servlet%s.url-patterns", ServletConfig.DEFAULT_SERVLET_NAME.equals(servletName) ? "" : "." + servletName)); } - final Builder builder = ServletBuildItem.builder(servletName, servletConfig.servletClass); + final Builder builder = ServletBuildItem.builder(servletName, servletConfig.servletClass()); for (String pattern : urlPatterns.get()) { builder.addMapping(pattern); } // NOTE: We only configure loadOnStartup, async & forceAwait if the default values were overridden - if (servletConfig.loadOnStartup > -1) { - builder.setLoadOnStartup(servletConfig.loadOnStartup); + if (servletConfig.loadOnStartup() > -1) { + builder.setLoadOnStartup(servletConfig.loadOnStartup()); } - if (servletConfig.async) { - builder.setAsyncSupported(servletConfig.async); + if (servletConfig.async()) { + builder.setAsyncSupported(servletConfig.async()); builder.addInitParam("async", "true"); } - if (servletConfig.forceAwait) { + if (servletConfig.forceAwait()) { builder.addInitParam("forceAwait", "true"); } - servletConfig.executorRef.ifPresent(executorRef -> { + servletConfig.executorRef().ifPresent(executorRef -> { builder.addInitParam("executorRef", executorRef); }); - MultipartConfig multipartConfig = servletConfig.multipart; + MultipartConfig multipartConfig = servletConfig.multipart(); if (multipartConfig != null) { builder.setMultipartConfig(new MultipartConfigElement( - multipartConfig.location, - multipartConfig.maxFileSize, - multipartConfig.maxRequestSize, - multipartConfig.fileSizeThreshold)); + multipartConfig.location(), + multipartConfig.maxFileSize(), + multipartConfig.maxRequestSize(), + multipartConfig.fileSizeThreshold())); } return builder.build(); diff --git a/extensions/servlet/runtime/pom.xml b/extensions/servlet/runtime/pom.xml index 5b99539907e4..dc0e4109bc28 100644 --- a/extensions/servlet/runtime/pom.xml +++ b/extensions/servlet/runtime/pom.xml @@ -68,9 +68,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java b/extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java index 83cf30ca2442..22285df300ea 100644 --- a/extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java +++ b/extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java @@ -20,42 +20,41 @@ import java.util.Map; import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import io.smallrye.config.WithParentName; /** * {@link ConfigRoot} for {@link #defaultServlet}. */ -@ConfigRoot(name = "camel.servlet", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public final class CamelServletConfig { +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.servlet") +public interface CamelServletConfig { /** * The default servlet with implicit name `ServletConfig.DEFAULT_SERVLET_NAME` * * @asciidoclet */ - @ConfigItem(name = ConfigItem.PARENT) - public ServletConfig defaultServlet; + @WithParentName + ServletConfig defaultServlet(); /** * A collection of named servlets * * @asciidoclet */ - @ConfigItem(name = ConfigItem.PARENT) - public Map namedServlets; + @WithParentName + Map namedServlets(); /** * {@code camel-servlet} component configuration */ - @ConfigGroup - public static class ServletConfig { - - public static final String DEFAULT_SERVLET_NAME = "CamelServlet"; - - public static final String DEFAULT_SERVLET_CLASS = "org.apache.camel.component.servlet.CamelHttpTransportServlet"; + interface ServletConfig { + String DEFAULT_SERVLET_NAME = "CamelServlet"; + String DEFAULT_SERVLET_CLASS = "org.apache.camel.component.servlet.CamelHttpTransportServlet"; /** * A comma separated list of path patterns under which the CamelServlet should be accessible. Example path patterns: @@ -63,16 +62,15 @@ public static class ServletConfig { * * @asciidoclet */ - @ConfigItem - public Optional> urlPatterns; + Optional> urlPatterns(); /** * A fully qualified name of a servlet class to serve paths that match `url-patterns` * * @asciidoclet */ - @ConfigItem(defaultValue = DEFAULT_SERVLET_CLASS) - public String servletClass; + @WithDefault(DEFAULT_SERVLET_CLASS) + String servletClass(); /** * A servletName as it would be defined in a `web.xml` file or in the `jakarta.servlet.annotation.WebServlet++#++name()` @@ -80,8 +78,8 @@ public static class ServletConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = DEFAULT_SERVLET_NAME) - public String servletName; + @WithDefault(DEFAULT_SERVLET_NAME) + String servletName(); /** * Sets the loadOnStartup priority on the Servlet. A loadOnStartup is a value greater than or equal to zero, indicates @@ -90,16 +88,16 @@ public static class ServletConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "-1") - public Integer loadOnStartup; + @WithDefault("-1") + Integer loadOnStartup(); /** * Enables Camel to benefit from asynchronous Servlet support. * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean async; + @WithDefault("false") + boolean async(); /** * When set to `true` used in conjunction with `quarkus.camel.servlet.async = true`, this will force route processing to @@ -107,23 +105,22 @@ public static class ServletConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "false") - public boolean forceAwait; + @WithDefault("false") + boolean forceAwait(); /** * The name of a bean to configure an optional custom thread pool for handling Camel Servlet processing. * * @asciidoclet */ - @ConfigItem - public Optional executorRef; + Optional executorRef(); /** * Servlet multipart request configuration. * * @asciidoclet */ - public MultipartConfig multipart; + MultipartConfig multipart(); /** * @return {@code true} if this {@link ServletConfig} is valid as a whole. This currently translates to @@ -131,8 +128,8 @@ public static class ServletConfig { * default values. Otherwise returns {@code false}. * @asciidoclet */ - public boolean isValid() { - return urlPatterns.isPresent() && !urlPatterns.get().isEmpty(); + default boolean isValid() { + return urlPatterns().isPresent() && !urlPatterns().get().isEmpty(); } /** @@ -142,36 +139,34 @@ public boolean isValid() { * as the servlet name. * * @param key the key used in - * {@link org.apache.camel.quarkus.servlet.runtime.CamelServletConfig.ServletsConfig#namedServlets} + * {@link org.apache.camel.quarkus.servlet.runtime.CamelServletConfig#namedServlets} * @return the effective servlet name to use * @asciidoclet */ - public String getEffectiveServletName(final String key) { - return DEFAULT_SERVLET_NAME.equals(servletName) ? key : servletName; + default String getEffectiveServletName(final String key) { + return DEFAULT_SERVLET_NAME.equals(servletName()) ? key : servletName(); } /** * Servlet multipart request configuration. */ - @ConfigGroup - public static class MultipartConfig { - + interface MultipartConfig { /** * An absolute path to a directory on the file system to store files temporarily while the parts are processed or * when the size of the file exceeds the specified file-size-threshold configuration value. * * @asciidoclet */ - @ConfigItem(defaultValue = "${java.io.tmpdir}") - public String location; + @WithDefault("${java.io.tmpdir}") + String location(); /** * The maximum size allowed in bytes for uploaded files. The default size (-1) allows an unlimited size. * * @asciidoclet */ - @ConfigItem(defaultValue = "-1") - public long maxFileSize; + @WithDefault("-1") + long maxFileSize(); /** * The maximum size allowed in bytes for a multipart/form-data request. The default size (-1) allows an unlimited @@ -179,16 +174,16 @@ public static class MultipartConfig { * * @asciidoclet */ - @ConfigItem(defaultValue = "-1") - public long maxRequestSize; + @WithDefault("-1") + long maxRequestSize(); /** * The file size in bytes after which the file will be temporarily stored on disk. * * @asciidoclet */ - @ConfigItem(defaultValue = "0") - public int fileSizeThreshold; + @WithDefault("0") + int fileSizeThreshold(); } } } diff --git a/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltNativeImageProcessor.java b/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltNativeImageProcessor.java index 8c7a3448fd09..b42de0fb4260 100644 --- a/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltNativeImageProcessor.java +++ b/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltNativeImageProcessor.java @@ -51,11 +51,11 @@ void xsltResources( CamelXsltConfig config, BuildProducer nativeResources, BuildProducer nativeResourceBundles) { - if (!config.sources.isPresent()) { + if (config.sources().isEmpty()) { return; } - final List sources = config.sources.get(); + final List sources = config.sources().get(); List paths = new ArrayList<>(sources.size() + 5); for (String source : sources) { String scheme = ResourceHelper.getScheme(source); diff --git a/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java b/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java index 5fcfe0235787..9338fc667a23 100644 --- a/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java +++ b/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java @@ -91,7 +91,7 @@ void xsltResources( final Set translets = new LinkedHashSet<>(); try { final BuildTimeUriResolver resolver = new BuildTimeUriResolver(); - for (String uri : config.sources.orElse(Collections.emptyList())) { + for (String uri : config.sources().orElse(Collections.emptyList())) { ResolutionResult resolvedUri = resolver.resolve(uri); uriResolverEntries.produce(resolvedUri.toBuildItem()); @@ -105,13 +105,13 @@ void xsltResources( try { TransformerFactory tf = new XalanTransformerFactory(); - for (Map.Entry entry : config.features.entrySet()) { + for (Map.Entry entry : config.features().entrySet()) { tf.setFeature(entry.getKey(), entry.getValue()); } tf.setAttribute("generate-translet", true); tf.setAttribute("translet-name", resolvedUri.transletClassName); - tf.setAttribute("package-name", config.packageName); + tf.setAttribute("package-name", config.packageName()); tf.setAttribute("destination-directory", destination.toString()); tf.setErrorListener(new CamelXsltErrorListener()); tf.newTemplates(resolvedUri.source); diff --git a/extensions/xslt/runtime/pom.xml b/extensions/xslt/runtime/pom.xml index bb5a4aeb90af..098d94b52adf 100644 --- a/extensions/xslt/runtime/pom.xml +++ b/extensions/xslt/runtime/pom.xml @@ -66,9 +66,6 @@ ${quarkus.version} - - -AlegacyConfigRoot=true - diff --git a/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltConfig.java b/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltConfig.java index dcfc5fe4a104..0478225aa7a7 100644 --- a/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltConfig.java +++ b/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltConfig.java @@ -20,34 +20,33 @@ import java.util.Map; import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(name = "camel.xslt", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class CamelXsltConfig { - +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.camel.xslt") +public interface CamelXsltConfig { /** * A comma separated list of templates to compile. * * @asciidoclet */ - @ConfigItem - public Optional> sources; + Optional> sources(); /** * The package name for the generated classes. * * @asciidoclet */ - @ConfigItem(defaultValue = "org.apache.camel.quarkus.component.xslt.generated") - public String packageName; + @WithDefault("org.apache.camel.quarkus.component.xslt.generated") + String packageName(); /** * TransformerFactory features. * * @asciidoclet */ - @ConfigItem - public Map features; + Map features(); } diff --git a/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java b/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java index af551b3e7d93..00965c9fcb94 100644 --- a/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java +++ b/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java @@ -38,7 +38,7 @@ public RuntimeValue createXsltComponent(CamelXsltConfig config, RuntimeValue uriResolverBuilder) { final RuntimeUriResolver uriResolver = uriResolverBuilder.getValue().build(); final QuarkusTransformerFactoryConfigurationStrategy strategy = new QuarkusTransformerFactoryConfigurationStrategy( - config.packageName, config.features, uriResolver); + config.packageName(), config.features(), uriResolver); final XsltComponent component = new XsltComponent(); component.setUriResolverFactory(new QuarkusXsltUriResolverFactory(uriResolver)); component.setTransformerFactoryConfigurationStrategy(strategy);