All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.reactive.server.providers.serialisers.ServerInputStreamMessageBodyHandler Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package org.jboss.resteasy.reactive.server.providers.serialisers;

import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.common.providers.serialisers.InputStreamMessageBodyHandler;
import org.jboss.resteasy.reactive.server.spi.ResteasyReactiveResourceInfo;
import org.jboss.resteasy.reactive.server.spi.ServerMessageBodyReader;
import org.jboss.resteasy.reactive.server.spi.ServerMessageBodyWriter;
import org.jboss.resteasy.reactive.server.spi.ServerRequestContext;

public class ServerInputStreamMessageBodyHandler extends InputStreamMessageBodyHandler
        implements ServerMessageBodyReader, ServerMessageBodyWriter {

    @Override
    public boolean isReadable(Class type, Type genericType, ResteasyReactiveResourceInfo lazyMethod, MediaType mediaType) {
        return true;
    }

    @Override
    public InputStream readFrom(Class type, Type genericType, MediaType mediaType,
            ServerRequestContext context) throws WebApplicationException, IOException {
        return context.getInputStream();
    }

    @Override
    public long getSize(InputStream inputStream, Class type, Type genericType, Annotation[] annotations,
            MediaType mediaType) {
        return -1;
    }

    @Override
    public boolean isWriteable(Class type, Type genericType, ResteasyReactiveResourceInfo target,
            MediaType mediaType) {
        return super.isWriteable(type, null, null, null);
    }

    @Override
    public void writeResponse(InputStream is, Type genericType, ServerRequestContext context)
            throws WebApplicationException, IOException {
        writeTo(is, context.getOrCreateOutputStream());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy