org.jboss.resteasy.reactive.server.handlers.ParameterHandler Maven / Gradle / Ivy
package org.jboss.resteasy.reactive.server.handlers;
import java.util.Collection;
import java.util.function.BiConsumer;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.WebApplicationException;
import org.jboss.logging.Logger;
import org.jboss.resteasy.reactive.common.model.ParameterType;
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;
import org.jboss.resteasy.reactive.server.core.parameters.ParameterExtractor;
import org.jboss.resteasy.reactive.server.core.parameters.converters.ParameterConverter;
import org.jboss.resteasy.reactive.server.spi.ServerRestHandler;
public class ParameterHandler implements ServerRestHandler {
private static final Logger log = Logger.getLogger(ParameterHandler.class);
private final int index;
private final String defaultValue;
private final ParameterExtractor extractor;
private final ParameterConverter converter;
private final ParameterType parameterType;
private final boolean isCollection;
private final boolean isOptional;
public ParameterHandler(int index, String defaultValue, ParameterExtractor extractor, ParameterConverter converter,
ParameterType parameterType, boolean isCollection, boolean isOptional) {
this.index = index;
this.defaultValue = defaultValue;
this.extractor = extractor;
this.converter = converter;
this.parameterType = parameterType;
this.isCollection = isCollection;
this.isOptional = isOptional;
}
@Override
public void handle(ResteasyReactiveRequestContext requestContext) {
// needed because user provided ParamConverter classes could use request scoped CDI beans
requestContext.requireCDIRequestScope();
try {
Object result = extractor.extractParameter(requestContext);
if (result instanceof ParameterExtractor.ParameterCallback) {
requestContext.suspend();
((ParameterExtractor.ParameterCallback) result).setListener(new BiConsumer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy