Class CustomResourceProducersGenerator
java.lang.Object
io.quarkus.resteasy.reactive.server.deployment.CustomResourceProducersGenerator
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidgenerate(Map<org.jboss.jandex.DotName, org.jboss.jandex.MethodInfo> resourcesThatNeedCustomProducer, Set<org.jboss.jandex.DotName> parameterContainersThatNeedCustomProducer, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.arc.deployment.GeneratedBeanBuildItem> generatedBeanBuildItemBuildProducer, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.arc.deployment.AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer) We generate a class that contains as many CDI producer methods as there are JAX-RS Resources that use JAX-RS params.
-
Method Details
-
generate
public static void generate(Map<org.jboss.jandex.DotName, org.jboss.jandex.MethodInfo> resourcesThatNeedCustomProducer, Set<org.jboss.jandex.DotName> parameterContainersThatNeedCustomProducer, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.arc.deployment.GeneratedBeanBuildItem> generatedBeanBuildItemBuildProducer, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.arc.deployment.AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer) We generate a class that contains as many CDI producer methods as there are JAX-RS Resources that use JAX-RS params. If for example there was a single such JAX-RS resource looking like:then the generated producer would look like this:@Path("/query") public class QueryParamResource { private final String queryParamValue; private final UriInfo uriInfo; public QueryParamResource(@QueryParam("p1") String headerValue, @Context UriInfo uriInfo) { this.headerValue = headerValue; } @GET public String get() { // DO something } }@Singleton public class ResourcesWithParamProducer { private String getHeaderParam(String name) { return (String)new HeaderParamExtractor(name, true).extractParameter(getContext()); } private String getQueryParam(String name) { return (String)new QueryParamExtractor(name, true, false, null).extractParameter(getContext()); } private String getPathParam(int index) { return (String)new PathParamExtractor(index, false, true).extractParameter(getContext()); } private String getMatrixParam(String name) { return (String)new MatrixParamExtractor(name, true, false).extractParameter(getContext()); } private String getCookieParam(String name) { return (String)new CookieParamExtractor(name, null).extractParameter(getContext()); } @Produces @RequestScoped public QueryParamResource producer_QueryParamResource_somehash(UriInfo uriInfo) { return new QueryParamResource(getQueryParam("p1"), uriInfo); } private ResteasyReactiveRequestContext getContext() { return CurrentRequestManager.get(); } }
-