Repository: quarkusio/quarkus
Issue:  Discard providers without annotation when there are only excluded classes

### Describe the bug

In the resteasy-reactive extension, if we exclude providers using build time conditions, it doesn't check anymore if the class has been annotated with `@Provider` so Arc tries instantiate them all, even those that should be instantiated by a `DynamicFeature` which leads to errors of type `javax.enterprise.inject.UnsatisfiedResolutionException`. 

### Expected behavior

When providers are excluded thanks to build time conditions, Arc should only instantiate providers annotated with `@Provider`

### Actual behavior

When providers are excluded thanks to build time conditions, Arc instantiates all, even those that should be instantiated by a `DynamicFeature`

### How to Reproduce?

Steps to reproduce

1. Add a provider annotated with a build time condition to enable the class filtering by excluded classes
2. Add a `DynamicFeature` that instantiate a filter with parameters that Arc cannot find by itself

Result:

You get an error of type:

```
java.lang.RuntimeException: 
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type java.lang.String and qualifiers [@Default]
	- java member: io.quarkus.resteasy.reactive.server.test.simple.BuildProfileTest$ResponseFilter7#<init>()
	- declared on CLASS bean [types=[io.quarkus.resteasy.reactive.server.test.simple.BuildProfileTest$ResponseFilter7, java.lang.Object, javax.ws.rs.container.ContainerResponseFilter], qualifiers=[@Default, @Any], target=io.quarkus.resteasy.reactive.server.test.simple.BuildProfileTest$ResponseFilter7]
	The following beans match by type, but none have matching qualifiers:
		- Bean [class=java.lang.String, qualifiers=[@ConfigProperty, @Any]]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1149)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:266)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:129)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:418)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type java.lang.String and qualifiers [@Default]
	- java member: io.quarkus.resteasy.reactive.server.test.simple.BuildProfileTest$ResponseFilter7#<init>()
	- declared on CLASS bean [types=[io.quarkus.resteasy.reactive.server.test.simple.BuildProfileTest$ResponseFilter7, java.lang.Object, javax.ws.rs.container.ContainerResponseFilter], qualifiers=[@Default, @Any], target=io.quarkus.resteasy.reactive.server.test.simple.BuildProfileTest$ResponseFilter7]
	The following beans match by type, but none have matching qualifiers:
		- Bean [class=java.lang.String, qualifiers=[@ConfigProperty, @Any]]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:567)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:470)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:254)
	... 13 more
```

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ApplicationScanningResult.java
extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/BuildProfileTest.java

diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/BuildProfileTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/BuildProfileTest.java
index ba1a6bce17a..758b78ec603 100644
--- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/BuildProfileTest.java
+++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/simple/BuildProfileTest.java
@@ -60,6 +60,7 @@ void should_call_ok_of_resource_1() {
                 .header("X-RF-4", nullValue())
                 .header("X-RF-5", notNullValue())
                 .header("X-RF-6", nullValue())
+                .header("X-RF-7", notNullValue())
                 .body(Matchers.is("ok1"));
     }
 
@@ -176,6 +177,21 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont
         }
     }
 
+    public static class ResponseFilter7 implements ContainerResponseFilter {
+
+        private final String value;
+
+        public ResponseFilter7(String value) {
+            this.value = value;
+        }
+
+        @Override
+        public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
+                throws IOException {
+            responseContext.getHeaders().add("X-RF-7", value);
+        }
+    }
+
     @IfBuildProfile("test")
     @Provider
     public static class Feature1 implements Feature {
@@ -225,6 +241,7 @@ public static class DynamicFeature1 implements DynamicFeature {
         @Override
         public void configure(ResourceInfo resourceInfo, FeatureContext context) {
             context.register(ResponseFilter5.class);
+            context.register(new ResponseFilter7("Value"));
         }
     }
 
diff --git a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ApplicationScanningResult.java b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ApplicationScanningResult.java
index f603361330d..f01abb87935 100644
--- a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ApplicationScanningResult.java
+++ b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ApplicationScanningResult.java
@@ -32,14 +32,16 @@ public ApplicationScanningResult(Set<String> allowedClasses, Set<String> singlet
 
     public KeepProviderResult keepProvider(ClassInfo providerClass) {
         if (filterClasses) {
-            // we don't care about provider annotations, they're manually registered (but for the server only)
             if (allowedClasses.isEmpty()) {
-                // we only have only classes to exclude
-                return excludedClasses.contains(providerClass.name().toString()) ? KeepProviderResult.DISCARD
-                        : KeepProviderResult.SERVER_ONLY;
+                // we have only classes to exclude
+                if (excludedClasses.contains(providerClass.name().toString())) {
+                    return KeepProviderResult.DISCARD;
+                }
+            } else {
+                // we don't care about provider annotations, they're manually registered (but for the server only)
+                return allowedClasses.contains(providerClass.name().toString()) ? KeepProviderResult.SERVER_ONLY
+                        : KeepProviderResult.DISCARD;
             }
-            return allowedClasses.contains(providerClass.name().toString()) ? KeepProviderResult.SERVER_ONLY
-                    : KeepProviderResult.DISCARD;
         }
         return providerClass.classAnnotation(ResteasyReactiveDotNames.PROVIDER) != null ? KeepProviderResult.NORMAL
                 : KeepProviderResult.DISCARD;
@@ -48,7 +50,7 @@ public KeepProviderResult keepProvider(ClassInfo providerClass) {
     public boolean keepClass(String className) {
         if (filterClasses) {
             if (allowedClasses.isEmpty()) {
-                // we only have only classes to exclude
+                // we have only classes to exclude
                 return !excludedClasses.contains(className);
             }
             return allowedClasses.contains(className);