Skip to content

Commit

Permalink
ArC - Switch to @ConfigMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Feb 4, 2025
1 parent 3778750 commit a7e65ad
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,23 @@
import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class IndexDependencyConfig {
public interface IndexDependencyConfig {

/**
* The maven groupId of the artifact.
*/
@ConfigItem
public String groupId;
String groupId();

/**
* The maven artifactId of the artifact (optional).
*/
@ConfigItem
public Optional<String> artifactId;
Optional<String> artifactId();

/**
* The maven classifier of the artifact (optional).
*/
@ConfigItem
public Optional<String> classifier;
Optional<String> classifier();

}
3 changes: 0 additions & 3 deletions extensions/arc/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-AlegacyConfigRoot=true</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import java.util.Set;

import io.quarkus.deployment.index.IndexDependencyConfig;
import io.quarkus.runtime.annotations.ConfigDocIgnore;
import io.quarkus.runtime.annotations.ConfigDocMapKey;
import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

@ConfigRoot(phase = BUILD_TIME)
public class ArcConfig {
@ConfigMapping(prefix = "quarkus.arc")
public interface ArcConfig {

public static final Set<String> ALLOWED_REMOVE_UNUSED_BEANS_VALUES = Set.of("all", "true", "none", "false", "fwk",
"framework");
Expand Down Expand Up @@ -43,15 +46,15 @@ public class ArcConfig {
*
* @see UnremovableBeanBuildItem
*/
@ConfigItem(defaultValue = "all")
public String removeUnusedBeans;
@WithDefault("all")
String removeUnusedBeans();

/**
* If set to true {@code @Inject} is automatically added to all non-static non-final fields that are annotated with
* one of the annotations defined by {@link AutoInjectAnnotationBuildItem}.
*/
@ConfigItem(defaultValue = "true")
public boolean autoInjectFields;
@WithDefault("true")
boolean autoInjectFields();

/**
* If set to true, the bytecode of unproxyable beans will be transformed. This ensures that a proxy/subclass
Expand All @@ -65,25 +68,25 @@ public class ArcConfig {
* <li>Makes private no-args constructors package-private if necessary.
* </ul
*/
@ConfigItem(defaultValue = "true")
public boolean transformUnproxyableClasses;
@WithDefault("true")
boolean transformUnproxyableClasses();

/**
* If set to true, the bytecode of private fields that are injection points will be transformed to package private.
* This ensures that field injection can be performed completely reflection-free.
* If the value is set to false, then a reflection fallback is used to perform the injection.
*/
@ConfigItem(defaultValue = "true")
public boolean transformPrivateInjectedFields;
@WithDefault("true")
boolean transformPrivateInjectedFields();

/**
* If set to true (the default), the build fails if a private method that is neither an observer nor a producer, is
* annotated with an interceptor binding.
* An example of this is the use of {@code Transactional} on a private method of a bean.
* If set to false, Quarkus simply logs a warning that the annotation will be ignored.
*/
@ConfigItem(defaultValue = "true")
public boolean failOnInterceptedPrivateMethod;
@WithDefault("true")
boolean failOnInterceptedPrivateMethod();

/**
* The list of selected alternatives for an application.
Expand All @@ -99,16 +102,15 @@ public class ArcConfig {
* that declares an alternative producer. If any value matches then the priority of {@link Integer#MAX_VALUE} is used for
* the relevant bean. The priority declared via {@link jakarta.annotation.Priority} is overridden.
*/
@ConfigItem
public Optional<List<String>> selectedAlternatives;
Optional<List<String>> selectedAlternatives();

/**
* If set to true then {@code jakarta.enterprise.inject.Produces} is automatically added to all non-void methods that are
* annotated with a scope annotation, a stereotype or a qualifier, and are not annotated with {@code Inject} or
* {@code Produces}, and no parameter is annotated with {@code Disposes}, {@code Observes} or {@code ObservesAsync}.
*/
@ConfigItem(defaultValue = "true")
public boolean autoProducerMethods;
@WithDefault("true")
boolean autoProducerMethods();

/**
* The list of types that should be excluded from discovery.
Expand All @@ -123,8 +125,7 @@ public class ArcConfig {
* If any element value matches a discovered type then the type is excluded from discovery, i.e. no beans and observer
* methods are created from this type.
*/
@ConfigItem
public Optional<List<String>> excludeTypes;
Optional<List<String>> excludeTypes();

/**
* List of types that should be considered unremovable regardless of whether they are directly used or not.
Expand All @@ -143,28 +144,26 @@ public class ArcConfig {
* @see {@link #removeUnusedBeans}
* @see {@link io.quarkus.arc.Unremovable}
*/
@ConfigItem
public Optional<List<String>> unremovableTypes;
Optional<List<String>> unremovableTypes();

/**
* Artifacts that should be excluded from discovery.
* <p>
* These artifacts would be otherwise scanned for beans, i.e. they
* contain a Jandex index or a beans.xml descriptor.
*/
@ConfigItem
@ConfigDocSection
@ConfigDocMapKey("dependency-name")
Map<String, IndexDependencyConfig> excludeDependency;
Map<String, IndexDependencyConfig> excludeDependency();

/**
* If set to true then the container attempts to detect "unused removed beans" false positives during programmatic lookup at
* runtime. You can disable this feature to conserve some memory when running your application in production.
*
* @see ArcConfig#removeUnusedBeans
*/
@ConfigItem(defaultValue = "true")
public boolean detectUnusedFalsePositives;
@WithDefault("true")
boolean detectUnusedFalsePositives();

/**
* If set to true then the container attempts to detect <i>wrong</i> usages of annotations and eventually fails the build to
Expand All @@ -174,8 +173,8 @@ public class ArcConfig {
* result a component annotated with {@code @jakarta.ejb.Singleton} would be completely ignored. Another example is an inner
* class annotated with a scope annotation - this component would be again completely ignored.
*/
@ConfigItem(defaultValue = "true")
public boolean detectWrongAnnotations;
@WithDefault("true")
boolean detectWrongAnnotations();

/**
* If set to {@code true}, the container will perform additional validations mandated by the CDI specification.
Expand All @@ -190,20 +189,18 @@ public class ArcConfig {
* Note that {@link #transformUnproxyableClasses} and {@link #removeUnusedBeans} also has effect on specification
* compatibility. You may want to disable these features to get behavior closer to the specification.
*/
@ConfigItem(defaultValue = "false")
public boolean strictCompatibility;
@WithDefault("false")
boolean strictCompatibility();

/**
* Dev mode configuration.
*/
@ConfigItem
public ArcDevModeConfig devMode;
ArcDevModeConfig devMode();

/**
* Test mode configuration.
*/
@ConfigItem
public ArcTestConfig test;
ArcTestConfig test();

/**
* The list of packages that will not be checked for split package issues.
Expand All @@ -214,14 +211,12 @@ public class ArcConfig {
* <li>a package name with suffix {@code .*}, i.e. {@code org.acme.*}, which matches a package that starts with provided
* value</li>
*/
@ConfigItem
public Optional<List<String>> ignoredSplitPackages;
Optional<List<String>> ignoredSplitPackages();

/**
* Context propagation configuration.
*/
@ConfigItem
public ArcContextPropagationConfig contextPropagation;
ArcContextPropagationConfig contextPropagation();

/**
* If set to {@code true}, the container should try to optimize the contexts for some of the scopes. If set to {@code auto}
Expand All @@ -231,26 +226,27 @@ public class ArcConfig {
* Typically, some implementation parts of the context for {@link jakarta.enterprise.context.ApplicationScoped} could be
* pregenerated during build.
*/
@ConfigItem(defaultValue = "auto", generateDocumentation = false)
public OptimizeContexts optimizeContexts;
@WithDefault("auto")
@ConfigDocIgnore
OptimizeContexts optimizeContexts();

public enum OptimizeContexts {
TRUE,
FALSE,
AUTO
}

public final boolean isRemoveUnusedBeansFieldValid() {
return ALLOWED_REMOVE_UNUSED_BEANS_VALUES.contains(removeUnusedBeans.toLowerCase());
default boolean isRemoveUnusedBeansFieldValid() {
return ALLOWED_REMOVE_UNUSED_BEANS_VALUES.contains(removeUnusedBeans().toLowerCase());
}

public final boolean shouldEnableBeanRemoval() {
final String lowerCase = removeUnusedBeans.toLowerCase();
default boolean shouldEnableBeanRemoval() {
final String lowerCase = removeUnusedBeans().toLowerCase();
return "all".equals(lowerCase) || "true".equals(lowerCase) || "fwk".equals(lowerCase) || "framework".equals(lowerCase);
}

public final boolean shouldOnlyKeepAppBeans() {
final String lowerCase = removeUnusedBeans.toLowerCase();
default boolean shouldOnlyKeepAppBeans() {
final String lowerCase = removeUnusedBeans().toLowerCase();
return "fwk".equals(lowerCase) || "framework".equals(lowerCase);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.quarkus.arc.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.smallrye.config.WithDefault;

@ConfigGroup
public class ArcContextPropagationConfig {
public interface ArcContextPropagationConfig {

/**
* If set to true and the SmallRye Context Propagation extension is present then the CDI contexts will be propagated by
Expand All @@ -16,7 +16,7 @@ public class ArcContextPropagationConfig {
*
* Note that the CDI contexts may be propagated in a different way though. For example with the Vertx duplicated context.
*/
@ConfigItem(defaultValue = "true")
public boolean enabled;
@WithDefault("true")
boolean enabled();

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package io.quarkus.arc.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.smallrye.config.WithDefault;

@ConfigGroup
public class ArcDevModeConfig {
public interface ArcDevModeConfig {

/**
* If set to true then the container monitors business method invocations and fired events during the development mode.
* <p>
* NOTE: This config property should not be changed in the development mode as it requires a full rebuild of the application
*/
@ConfigItem(defaultValue = "false")
public boolean monitoringEnabled;
@WithDefault("false")
boolean monitoringEnabled();

/**
* If set to true then the dependency graphs are generated and available in the Dev UI.
*/
@ConfigItem(defaultValue = "true")
public boolean generateDependencyGraphs;
@WithDefault("true")
boolean generateDependencyGraphs();

}
Loading

0 comments on commit a7e65ad

Please sign in to comment.