se.fortnox.reactivewizard.jaxrs.JaxRsResource Maven / Gradle / Ivy
package se.fortnox.reactivewizard.jaxrs;
import io.netty.handler.codec.http.HttpMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.http.server.HttpServerRequest;
import reactor.netty.http.server.HttpServerResponse;
import se.fortnox.reactivewizard.jaxrs.params.ParamResolver;
import se.fortnox.reactivewizard.jaxrs.params.ParamResolverFactories;
import se.fortnox.reactivewizard.jaxrs.response.JaxRsResult;
import se.fortnox.reactivewizard.jaxrs.response.JaxRsResultFactory;
import se.fortnox.reactivewizard.jaxrs.response.JaxRsResultFactoryFactory;
import se.fortnox.reactivewizard.util.FluxRxConverter;
import se.fortnox.reactivewizard.util.ReflectionUtil;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Pattern;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static se.fortnox.reactivewizard.util.FluxRxConverter.isFlux;
import static se.fortnox.reactivewizard.util.FluxRxConverter.isMono;
/**
* Represents a JaxRs resource. Maps to a method of a resource class. Use the call method with an incoming request to
* invoke the method of the resource. Returns null if the request does not match.
*/
public class JaxRsResource implements Comparable {
private static final Logger LOG = LoggerFactory.getLogger(JaxRsResource.class);
private static final Object EMPTY_ARG = new Object();
private final Pattern pathPattern;
private final Method method;
private final Method instanceMethod;
private final Integer paramCount;
private final List argumentExtractors;
private final JaxRsResultFactory resultFactory;
private final JaxRsMeta meta;
private final RequestLogger requestLogger;
private final Function
© 2015 - 2024 Weber Informatics LLC | Privacy Policy