From 86c7988ea28b5b78c8706a50da41dd1d95cb4b74 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Thu, 9 Feb 2023 11:36:15 +0100 Subject: [PATCH] ArC: remove deprecated @AlternativePriority --- docs/src/main/asciidoc/cdi-reference.adoc | 6 +--- ...ty-oidc-bearer-authentication-concept.adoc | 3 +- ...oidc-code-flow-authentication-concept.adoc | 6 ++-- .../io/quarkus/arc/deployment/ArcConfig.java | 3 +- .../runtime/CompositeRegistryCreator.java | 6 ++-- .../oidc/test/CustomTokenStateManager.java | 6 ++-- .../runtime/OidcTokenCredentialProducer.java | 6 ++-- .../QuarkusAsyncHealthCheckFactory.java | 6 ++-- .../test/TestJWTCallerPrincipalFactory.java | 6 ++-- .../runtime/QuarkusWorkerPoolRegistry.java | 5 +-- .../quarkus/arc/processor/BeanDeployment.java | 3 -- .../quarkus/arc/processor/BeanProcessor.java | 4 +-- .../java/io/quarkus/arc/processor/Beans.java | 33 +++++-------------- .../io/quarkus/arc/processor/DotNames.java | 2 -- .../io/quarkus/arc/AlternativePriority.java | 26 --------------- .../main/java/io/quarkus/arc/Priority.java | 2 +- .../AlternativePriorityAnnotationTest.java | 15 ++++----- .../AlternativePriorityResolutionTest.java | 4 +-- .../ComputedAlternativePriorityTest.java | 3 -- .../SyntheticBeanWithStereotypeTest.java | 5 +-- .../StereotypeAlternativeArcPriorityTest.java | 6 ++-- .../CustomIntrospectionUserInfoCache.java | 6 ++-- .../it/opentracing/MockTracerProvider.java | 6 ++-- 23 files changed, 65 insertions(+), 103 deletions(-) delete mode 100644 independent-projects/arc/runtime/src/main/java/io/quarkus/arc/AlternativePriority.java diff --git a/docs/src/main/asciidoc/cdi-reference.adoc b/docs/src/main/asciidoc/cdi-reference.adoc index 3aff6c6727aed..44959104b90fc 100644 --- a/docs/src/main/asciidoc/cdi-reference.adoc +++ b/docs/src/main/asciidoc/cdi-reference.adoc @@ -655,14 +655,10 @@ NOTE: Properties set at runtime have absolutely no effect on the bean resolution In CDI, an alternative bean may be selected either globally for an application by means of `@Priority`, or for a bean archive using a `beans.xml` descriptor. Quarkus has a simplified bean discovery and the content of `beans.xml` is ignored. -The disadvantage of `@jakarta.annotation.Priority` is that it has `@Target({ TYPE, PARAMETER })` and so it cannot be used for producer methods and fields. -This problem should be fixed in Common Annotations 2.1. -Users are encouraged to use `@io.quarkus.arc.Priority` instead, until Quarkus upgrades to this version of `jakarta.annotation-api`. - However, it is also possible to select alternatives for an application using the unified configuration. The `quarkus.arc.selected-alternatives` property accepts a list of string values that are used to match alternative beans. If any value matches then the priority of `Integer#MAX_VALUE` is used for the relevant bean. -The priority declared via `@Priority` or `@AlternativePriority` is overridden. +The priority declared via `@Priority` or inherited from a stereotype is overridden. .Value Examples |=== diff --git a/docs/src/main/asciidoc/security-oidc-bearer-authentication-concept.adoc b/docs/src/main/asciidoc/security-oidc-bearer-authentication-concept.adoc index d7b691799709d..4b9a50a1dff0d 100644 --- a/docs/src/main/asciidoc/security-oidc-bearer-authentication-concept.adoc +++ b/docs/src/main/asciidoc/security-oidc-bearer-authentication-concept.adoc @@ -161,7 +161,8 @@ If it is the case in your production then it can be recommended that the token i [source, java] ---- @ApplicationScoped -@AlternativePriority(1) +@Alternative +@Priority(1) public class CustomIntrospectionUserInfoCache implements TokenIntrospectionCache, UserInfoCache { ... } diff --git a/docs/src/main/asciidoc/security-oidc-code-flow-authentication-concept.adoc b/docs/src/main/asciidoc/security-oidc-code-flow-authentication-concept.adoc index b11e52f5339a2..8c30eecb0f2fd 100644 --- a/docs/src/main/asciidoc/security-oidc-code-flow-authentication-concept.adoc +++ b/docs/src/main/asciidoc/security-oidc-code-flow-authentication-concept.adoc @@ -395,10 +395,11 @@ Here is a simple example: ---- package io.quarkus.oidc.test; +import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.inject.Inject; -import io.quarkus.arc.AlternativePriority; import io.quarkus.oidc.AuthorizationCodeTokens; import io.quarkus.oidc.OidcTenantConfig; import io.quarkus.oidc.TokenStateManager; @@ -407,7 +408,8 @@ import io.smallrye.mutiny.Uni; import io.vertx.ext.web.RoutingContext; @ApplicationScoped -@AlternativePriority(1) +@Alternative +@Priority(1) public class CustomTokenStateManager implements TokenStateManager { @Inject diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java index f8dab3754211b..6ba1b0325211f 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java @@ -97,8 +97,7 @@ public class ArcConfig { * * Each element value is used to match an alternative bean class, an alternative stereotype annotation type or a bean class * 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} or - * {@link io.quarkus.arc.AlternativePriority} is overridden. + * the relevant bean. The priority declared via {@link jakarta.annotation.Priority} is overridden. */ @ConfigItem public Optional> selectedAlternatives; diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/CompositeRegistryCreator.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/CompositeRegistryCreator.java index 7cdfef7a67fe6..59e5f839137a4 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/CompositeRegistryCreator.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/CompositeRegistryCreator.java @@ -2,12 +2,13 @@ import static jakarta.interceptor.Interceptor.Priority.PLATFORM_AFTER; +import jakarta.annotation.Priority; +import jakarta.enterprise.inject.Alternative; import jakarta.enterprise.inject.Produces; import jakarta.inject.Singleton; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Metrics; -import io.quarkus.arc.AlternativePriority; /** * @return the single resolvable "root" MeterRegistry @@ -15,7 +16,8 @@ public class CompositeRegistryCreator { @Produces @Singleton - @AlternativePriority(PLATFORM_AFTER) + @Alternative + @Priority(PLATFORM_AFTER) public MeterRegistry produceRootRegistry() { return Metrics.globalRegistry; } diff --git a/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTokenStateManager.java b/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTokenStateManager.java index 97a487e18dfd4..78a07c8ecf1b7 100644 --- a/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTokenStateManager.java +++ b/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTokenStateManager.java @@ -1,9 +1,10 @@ package io.quarkus.oidc.test; +import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.inject.Inject; -import io.quarkus.arc.AlternativePriority; import io.quarkus.oidc.AuthorizationCodeTokens; import io.quarkus.oidc.OidcRequestContext; import io.quarkus.oidc.OidcTenantConfig; @@ -13,7 +14,8 @@ import io.vertx.ext.web.RoutingContext; @ApplicationScoped -@AlternativePriority(1) +@Alternative +@Priority(1) public class CustomTokenStateManager implements TokenStateManager { @Inject diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcTokenCredentialProducer.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcTokenCredentialProducer.java index c317fced2fc76..2c5513e10aed8 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcTokenCredentialProducer.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcTokenCredentialProducer.java @@ -1,12 +1,13 @@ package io.quarkus.oidc.runtime; +import jakarta.annotation.Priority; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; import org.jboss.logging.Logger; -import io.quarkus.arc.AlternativePriority; import io.quarkus.oidc.AccessTokenCredential; import io.quarkus.oidc.IdTokenCredential; import io.quarkus.oidc.RefreshToken; @@ -38,7 +39,8 @@ IdTokenCredential currentIdToken() { @Produces @RequestScoped - @AlternativePriority(1) + @Alternative + @Priority(1) AccessTokenCredential currentAccessToken() { AccessTokenCredential cred = identity.getCredential(AccessTokenCredential.class); if (cred == null || cred.getToken() == null) { diff --git a/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/QuarkusAsyncHealthCheckFactory.java b/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/QuarkusAsyncHealthCheckFactory.java index 90c64a7d5939f..31ebd6dda6afc 100644 --- a/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/QuarkusAsyncHealthCheckFactory.java +++ b/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/QuarkusAsyncHealthCheckFactory.java @@ -1,12 +1,13 @@ package io.quarkus.smallrye.health.runtime; +import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.inject.Inject; import org.eclipse.microprofile.health.HealthCheck; import org.eclipse.microprofile.health.HealthCheckResponse; -import io.quarkus.arc.AlternativePriority; import io.quarkus.runtime.BlockingOperationControl; import io.smallrye.health.AsyncHealthCheckFactory; import io.smallrye.health.api.AsyncHealthCheck; @@ -19,7 +20,8 @@ * health checks with different executors provided by {@link MutinyHelper}. */ @ApplicationScoped -@AlternativePriority(1) +@Alternative +@Priority(1) public class QuarkusAsyncHealthCheckFactory extends AsyncHealthCheckFactory { @Inject diff --git a/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/TestJWTCallerPrincipalFactory.java b/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/TestJWTCallerPrincipalFactory.java index 9e7aafd1776d5..e8b66d782fa3d 100644 --- a/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/TestJWTCallerPrincipalFactory.java +++ b/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/TestJWTCallerPrincipalFactory.java @@ -3,11 +3,12 @@ import java.nio.charset.StandardCharsets; import java.util.Base64; +import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import org.jose4j.jwt.JwtClaims; -import io.quarkus.arc.AlternativePriority; import io.smallrye.jwt.auth.principal.DefaultJWTCallerPrincipal; import io.smallrye.jwt.auth.principal.JWTAuthContextInfo; import io.smallrye.jwt.auth.principal.JWTCallerPrincipal; @@ -15,7 +16,8 @@ import io.smallrye.jwt.auth.principal.ParseException; @ApplicationScoped -@AlternativePriority(1) +@Alternative +@Priority(1) public class TestJWTCallerPrincipalFactory extends JWTCallerPrincipalFactory { @Override diff --git a/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/QuarkusWorkerPoolRegistry.java b/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/QuarkusWorkerPoolRegistry.java index f2fbc4307e620..7a596d10ac02f 100644 --- a/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/QuarkusWorkerPoolRegistry.java +++ b/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/QuarkusWorkerPoolRegistry.java @@ -11,12 +11,12 @@ import jakarta.enterprise.context.BeforeDestroyed; import jakarta.enterprise.event.Observes; import jakarta.enterprise.event.Reception; +import jakarta.enterprise.inject.Alternative; import jakarta.inject.Inject; import org.eclipse.microprofile.config.ConfigProvider; import org.slf4j.LoggerFactory; -import io.quarkus.arc.AlternativePriority; import io.smallrye.mutiny.Uni; import io.smallrye.reactive.messaging.annotations.Blocking; import io.smallrye.reactive.messaging.providers.connectors.ExecutionHolder; @@ -25,7 +25,8 @@ import io.vertx.mutiny.core.Context; import io.vertx.mutiny.core.WorkerExecutor; -@AlternativePriority(1) +@Alternative +@Priority(1) @ApplicationScoped // TODO: create a different entry for WorkerPoolRegistry than `analyzeWorker` and drop this class public class QuarkusWorkerPoolRegistry extends WorkerPoolRegistry { diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java index d3d087150f52b..f8321adb5df60 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java @@ -830,9 +830,6 @@ private Map findStereotypes(Map int alternativePriority = annotation.value().asInt(); } else if (DotNames.ARC_PRIORITY.equals(annotation.name()) && alternativePriority == null) { alternativePriority = annotation.value().asInt(); - } else if (DotNames.ALTERNATIVE_PRIORITY.equals(annotation.name())) { - isAlternative = true; - alternativePriority = annotation.value().asInt(); } else { final ScopeInfo scope = getScope(annotation.name(), customContexts); if (scope != null) { diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java index 54fb313bceb20..4f5f20bd1ab76 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java @@ -31,7 +31,6 @@ import org.jboss.jandex.IndexView; import org.jboss.logging.Logger; -import io.quarkus.arc.AlternativePriority; import io.quarkus.arc.InjectableBean; import io.quarkus.arc.processor.BeanDeploymentValidator.ValidationContext; import io.quarkus.arc.processor.BuildExtension.BuildContext; @@ -754,8 +753,7 @@ public Builder setGenerateSources(boolean value) { /** * Can be used to compute a priority of an alternative bean. A non-null computed value always - * takes precedence over the priority defined by {@link Priority}, {@link AlternativePriority} or an alternative - * stereotype. + * takes precedence over the priority defined by {@link Priority} or a stereotype. * * @param priorities * @return self diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java index 9e26c06a3ead4..008b41ffee585 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java @@ -119,12 +119,7 @@ static BeanInfo createProducerMethod(Set beanTypes, MethodInfo producerMet isAlternative = true; continue; } - if (DotNames.ALTERNATIVE_PRIORITY.equals(annotationName)) { - isAlternative = true; - priority = annotation.value().asInt(); - continue; - } - if ((!isAlternative || priority == null) && annotationName.equals(DotNames.PRIORITY)) { + if (DotNames.PRIORITY.equals(annotationName)) { priority = annotation.value().asInt(); continue; } @@ -179,7 +174,7 @@ static BeanInfo createProducerMethod(Set beanTypes, MethodInfo producerMet if (priority == null) { // after all attempts, priority is still null, bean will be ignored LOGGER.debugf( - "Ignoring producer method %s - declared as an @Alternative but not selected by @AlternativePriority or quarkus.arc.selected-alternatives", + "Ignoring producer method %s - declared as an @Alternative but not selected by @Priority or quarkus.arc.selected-alternatives", declaringBean.getTarget().get().asClass().name() + "#" + producerMethod.name()); return null; } @@ -234,12 +229,7 @@ static BeanInfo createProducerField(FieldInfo producerField, BeanInfo declaringB isAlternative = true; continue; } - if (DotNames.ALTERNATIVE_PRIORITY.equals(annotationName)) { - isAlternative = true; - priority = annotation.value().asInt(); - continue; - } - if ((!isAlternative || priority == null) && annotation.name().equals(DotNames.PRIORITY)) { + if (DotNames.PRIORITY.equals(annotation.name())) { priority = annotation.value().asInt(); continue; } @@ -293,7 +283,7 @@ static BeanInfo createProducerField(FieldInfo producerField, BeanInfo declaringB // after all attempts, priority is still null if (priority == null) { LOGGER.debugf( - "Ignoring producer field %s - declared as an @Alternative but not selected by @AlternativePriority or quarkus.arc.selected-alternatives", + "Ignoring producer field %s - declared as an @Alternative but not selected by @Priority or quarkus.arc.selected-alternatives", producerField); return null; } @@ -938,7 +928,7 @@ private static Integer initAlternativePriority(AnnotationTarget target, Integer if (computedPriority != null) { if (alternativePriority != null) { LOGGER.infof( - "Computed priority [%s] overrides the priority [%s] declared via @Priority or @AlternativePriority", + "Computed priority [%s] overrides the priority [%s] declared via @Priority", computedPriority, alternativePriority); } alternativePriority = computedPriority; @@ -1124,24 +1114,19 @@ void processAnnotation(AnnotationInstance annotation, // we needn't process it further, the annotation was a qualifier (or multiple repeating ones) return; } - if (annotationName.equals(DotNames.ALTERNATIVE)) { - isAlternative = true; - return; - } - if (annotationName.equals(DotNames.ALTERNATIVE_PRIORITY)) { + if (DotNames.ALTERNATIVE.equals(annotationName)) { isAlternative = true; - priority = annotation.value().asInt(); return; } if (DotNames.DEFAULT_BEAN.equals(annotationName)) { isDefaultBean = true; return; } - if ((!isAlternative || priority == null) && annotationName.equals(DotNames.PRIORITY)) { + if (DotNames.PRIORITY.equals(annotationName)) { priority = annotation.value().asInt(); return; } - if (priority == null && annotationName.equals(DotNames.ARC_PRIORITY)) { + if (priority == null && DotNames.ARC_PRIORITY.equals(annotationName)) { priority = annotation.value().asInt(); return; } @@ -1204,7 +1189,7 @@ BeanInfo create() { if (priority == null) { // after all attempts, priority is still null, bean will be ignored LOGGER.debugf( - "Ignoring bean defined via %s - declared as an @Alternative but not selected by @Priority, @AlternativePriority or quarkus.arc.selected-alternatives", + "Ignoring bean defined via %s - declared as an @Alternative but not selected by @Priority or quarkus.arc.selected-alternatives", beanClass.name()); return null; } diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DotNames.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DotNames.java index da22e32021567..2959a12dfe7ce 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DotNames.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DotNames.java @@ -53,7 +53,6 @@ import org.jboss.jandex.DotName; import io.quarkus.arc.All; -import io.quarkus.arc.AlternativePriority; import io.quarkus.arc.ArcInvocationContext; import io.quarkus.arc.DefaultBean; import io.quarkus.arc.InjectableBean; @@ -100,7 +99,6 @@ public final class DotNames { public static final DotName EVENT = create(Event.class); public static final DotName EVENT_METADATA = create(EventMetadata.class); public static final DotName ALTERNATIVE = create(Alternative.class); - public static final DotName ALTERNATIVE_PRIORITY = create(AlternativePriority.class); public static final DotName DEFAULT_BEAN = create(DefaultBean.class); public static final DotName SINGLETON = create(Singleton.class); public static final DotName APPLICATION_SCOPED = create(ApplicationScoped.class); diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/AlternativePriority.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/AlternativePriority.java deleted file mode 100644 index 5fd701beb4c1b..0000000000000 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/AlternativePriority.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.quarkus.arc; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import jakarta.enterprise.inject.Alternative; - -/** - * If a bean is annotated with this annotation, it is considered an enabled alternative with given priority. - * Effectively, this is a shortcut for {@code Alternative} plus {@code Priority} annotations. - *

- * This annotation can be used not only on bean classes, but also method and field producers. - * - * @deprecated Use {@link Alternative} and {@link jakarta.annotation.Priority} instead - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD, ElementType.TYPE, ElementType.FIELD }) -@Deprecated -public @interface AlternativePriority { - /** - * The priority value of this alternative - */ - int value(); -} diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Priority.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Priority.java index f90be54b65afa..175be33f12008 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Priority.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Priority.java @@ -14,7 +14,7 @@ * Since Common Annotations 2.1, the {@code jakarta.annotation.Priority} is no longer * meta-annotated {@code @Target}, so these two annotations are equivalent. *

- * A priority specified by {@link AlternativePriority} and {@link jakarta.annotation.Priority} takes precedence. + * A priority specified by {@link jakarta.annotation.Priority} takes precedence. * * @deprecated use {@link jakarta.annotation.Priority}; this annotation will be removed at some time after Quarkus 3.6 */ diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityAnnotationTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityAnnotationTest.java index d8c6b6661b2ce..f9fca3512c432 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityAnnotationTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityAnnotationTest.java @@ -15,12 +15,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.quarkus.arc.AlternativePriority; import io.quarkus.arc.test.ArcTestContainer; -/** - * Tests {@link io.quarkus.arc.AlternativePriority} annotation. - */ public class AlternativePriorityAnnotationTest { @RegisterExtension @@ -56,7 +52,8 @@ public String ping() { } @ApplicationScoped - @AlternativePriority(2) + @Alternative + @Priority(2) static class AlternativeClassBean implements MyInterface { @Override @@ -74,8 +71,8 @@ static class ProducerWithClashingAnnotations { // this should be the selected alternative @Produces @ApplicationScoped - @AlternativePriority(1000) @Alternative + @Priority(1000) public TheUltimateImpl createUltimateImpl() { return new TheUltimateImpl(); } @@ -87,12 +84,14 @@ public TheUltimateImpl createUltimateImpl() { static class MyProducer { @Produces @ApplicationScoped - @AlternativePriority(3) + @Alternative + @Priority(3) AlternativeProducerFieldBean bar = new AlternativeProducerFieldBean(); @Produces @ApplicationScoped - @AlternativePriority(4) + @Alternative + @Priority(4) public AlternativeProducerMethodBean createBar() { return new AlternativeProducerMethodBean(); } diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityResolutionTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityResolutionTest.java index c46a10fc9b37f..17f1260dec248 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityResolutionTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/AlternativePriorityResolutionTest.java @@ -13,7 +13,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.quarkus.arc.AlternativePriority; import io.quarkus.arc.Arc; import io.quarkus.arc.test.ArcTestContainer; @@ -57,7 +56,8 @@ static class NoParentAlternativePriorityProducer2 { @Produces @Singleton - @AlternativePriority(2) + @Alternative + @Priority(2) public MessageBean createBar() { return new MessageBean("far"); } diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/ComputedAlternativePriorityTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/ComputedAlternativePriorityTest.java index 469b5b5e8f02e..44d4c5988cba2 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/ComputedAlternativePriorityTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/alternatives/priority/ComputedAlternativePriorityTest.java @@ -15,9 +15,6 @@ import io.quarkus.arc.InstanceHandle; import io.quarkus.arc.test.ArcTestContainer; -/** - * Tests {@link io.quarkus.arc.AlternativePriority} annotation. - */ public class ComputedAlternativePriorityTest { @RegisterExtension diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/buildextension/beans/SyntheticBeanWithStereotypeTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/buildextension/beans/SyntheticBeanWithStereotypeTest.java index b194d77b2279f..ef91c0ba05473 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/buildextension/beans/SyntheticBeanWithStereotypeTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/buildextension/beans/SyntheticBeanWithStereotypeTest.java @@ -15,6 +15,7 @@ import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.inject.Named; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; @@ -27,7 +28,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.quarkus.arc.AlternativePriority; import io.quarkus.arc.Arc; import io.quarkus.arc.InstanceHandle; import io.quarkus.arc.processor.AnnotationsTransformer; @@ -110,7 +110,8 @@ public void transform(TransformationContext transformationContext) { .add(ApplicationScoped.class) .add(SimpleBinding.class) .add(Named.class) - .add(AlternativePriority.class, AnnotationValue.createIntegerValue("value", 11)) + .add(Alternative.class) + .add(Priority.class, AnnotationValue.createIntegerValue("value", 11)) .done(); } } diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/stereotypes/StereotypeAlternativeArcPriorityTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/stereotypes/StereotypeAlternativeArcPriorityTest.java index f29115abf3be3..5d8d33e851720 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/stereotypes/StereotypeAlternativeArcPriorityTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/stereotypes/StereotypeAlternativeArcPriorityTest.java @@ -18,12 +18,11 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.quarkus.arc.AlternativePriority; import io.quarkus.arc.Arc; import io.quarkus.arc.Priority; import io.quarkus.arc.test.ArcTestContainer; -// copy of `StereotypeAlternativeTest` that uses ArC `@Priority` and `@AlternativePriority` +// copy of `StereotypeAlternativeTest` that uses ArC `@Priority` // instead of Jakarta Common Annotations `@Priority` public class StereotypeAlternativeArcPriorityTest { @@ -49,7 +48,8 @@ public void testStereotype() { public @interface BeAlternative { } - @AlternativePriority(1) + @Alternative + @Priority(1) @Stereotype @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) diff --git a/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomIntrospectionUserInfoCache.java b/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomIntrospectionUserInfoCache.java index 90521b83c25d1..6ebf4f3fec948 100644 --- a/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomIntrospectionUserInfoCache.java +++ b/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomIntrospectionUserInfoCache.java @@ -1,9 +1,10 @@ package io.quarkus.it.keycloak; +import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.inject.Inject; -import io.quarkus.arc.AlternativePriority; import io.quarkus.oidc.OidcRequestContext; import io.quarkus.oidc.OidcTenantConfig; import io.quarkus.oidc.TokenIntrospection; @@ -14,7 +15,8 @@ import io.smallrye.mutiny.Uni; @ApplicationScoped -@AlternativePriority(1) +@Alternative +@Priority(1) public class CustomIntrospectionUserInfoCache implements TokenIntrospectionCache, UserInfoCache { @Inject DefaultTokenIntrospectionUserInfoCache tokenCache; diff --git a/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/opentracing/MockTracerProvider.java b/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/opentracing/MockTracerProvider.java index 248b94d9bc24f..1eb5145dbca5b 100644 --- a/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/opentracing/MockTracerProvider.java +++ b/integration-tests/smallrye-opentracing/src/main/java/io/quarkus/it/opentracing/MockTracerProvider.java @@ -1,19 +1,21 @@ package io.quarkus.it.opentracing; +import jakarta.annotation.Priority; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import jakarta.enterprise.inject.Produces; import jakarta.inject.Singleton; import io.opentracing.mock.MockTracer; import io.opentracing.util.GlobalTracer; -import io.quarkus.arc.AlternativePriority; @ApplicationScoped public class MockTracerProvider { @Produces @Singleton - @AlternativePriority(1) + @Alternative + @Priority(1) public MockTracer createInMemoryExporter() { MockTracer tracer = new MockTracer(); GlobalTracer.registerIfAbsent(tracer);