diff --git a/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java b/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java index 8fbaa8e3f20db1..e3e76e3af19304 100644 --- a/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java +++ b/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveProcessor.java @@ -13,6 +13,7 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.nio.file.Path; import java.util.ArrayDeque; import java.util.ArrayList; @@ -64,6 +65,7 @@ import org.jboss.jandex.MethodInfo; import org.jboss.jandex.Type; import org.jboss.logging.Logger; +import org.jboss.resteasy.reactive.RestEasyParamsFilter; import org.jboss.resteasy.reactive.common.core.Serialisers; import org.jboss.resteasy.reactive.common.core.SingletonBeanFactory; import org.jboss.resteasy.reactive.common.model.InjectableBean; @@ -230,6 +232,7 @@ public class ResteasyReactiveProcessor { DotName.createSimple(RoutingContext.class.getName())); private static final DotName FILE = DotName.createSimple(File.class.getName()); private static final DotName ENDPOINT_DISABLED = DotName.createSimple(EndpointDisabled.class.getName()); + private static final DotName RESTEASY_PARAM_FILTER = DotName.createSimple(RestEasyParamsFilter.class.getName()); private static final int SECURITY_EXCEPTION_MAPPERS_PRIORITY = Priorities.USER + 1; private static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -634,6 +637,19 @@ public Supplier apply(ClassInfo classInfo) { } }); + for (AnnotationInstance ann : index.getAnnotations(RESTEASY_PARAM_FILTER)) { + Class>> predicate = loadClass(ann.target().asClass().name()); + if (predicate == null) { + break; + } + try { + serverEndpointIndexerBuilder.setSkipMethodParameter(predicate.getDeclaredConstructor().newInstance()); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + break; + } + if (!serverDefaultProducesHandlers.isEmpty()) { List handlers = new ArrayList<>(serverDefaultProducesHandlers.size()); for (ServerDefaultProducesHandlerBuildItem bi : serverDefaultProducesHandlers) { @@ -740,6 +756,14 @@ public Supplier apply(ClassInfo classInfo) { handleDateFormatReflection(reflectiveClassBuildItemBuildProducer, index); } + private static Class loadClass(DotName filterDotName) { + try { + return (Class) Class.forName(filterDotName.toString(), false, Thread.currentThread().getContextClassLoader()); + } catch (ClassNotFoundException classNotFoundException) { + return null; + } + } + private boolean filtersAccessResourceMethod(ResourceInterceptors resourceInterceptors) { AtomicBoolean ab = new AtomicBoolean(false); ResourceInterceptors.FiltersVisitor visitor = new ResourceInterceptors.FiltersVisitor() { diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/RestEasyParamsFilter.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/RestEasyParamsFilter.java new file mode 100644 index 00000000000000..ed2cfa8c464b84 --- /dev/null +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/RestEasyParamsFilter.java @@ -0,0 +1,11 @@ +package org.jboss.resteasy.reactive; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface RestEasyParamsFilter { +} diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java index e1bb21511e916b..041796659ddf34 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java @@ -353,6 +353,8 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz, addHandlers(handlers, clazz, method, info, HandlerChainCustomizer.Phase.RESOLVE_METHOD_PARAMETERS); for (int i = 0; i < parameters.length; i++) { ServerMethodParameter param = (ServerMethodParameter) parameters[i]; + if (param.parameterType.equals(ParameterType.SKIPPED)) + continue; ParameterExtractor extractor = parameterExtractor(pathParameterIndexes, locatableResource, param); ParameterConverter converter = null; ParamConverterProviders paramConverterProviders = info.getParamConverterProviders();