Java Code Examples for javax.ws.rs.ext.ReaderInterceptor#aroundReadFrom()

The following examples show how to use javax.ws.rs.ext.ReaderInterceptor#aroundReadFrom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXRSUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static Object readFromMessageBodyReader(List<ReaderInterceptor> readers,
                                               Class<?> targetTypeClass,
                                               Type parameterType,
                                               Annotation[] parameterAnnotations,
                                               InputStream is,
                                               MediaType mediaType,
                                               Message m) throws IOException, WebApplicationException {

    // Verbose but avoids an extra context instantiation for the typical path
    if (readers.size() > 1) {
        ReaderInterceptor first = readers.remove(0);
        ReaderInterceptorContext context = new ReaderInterceptorContextImpl(targetTypeClass,
                                                                        parameterType,
                                                                        parameterAnnotations,
                                                                        is,
                                                                        m,
                                                                        readers);

        return first.aroundReadFrom(context);
    }
    MessageBodyReader<?> provider = ((ReaderInterceptorMBR)readers.get(0)).getMBR();
    @SuppressWarnings("rawtypes")
    Class cls = targetTypeClass;
    return provider.readFrom(
              cls, parameterType, parameterAnnotations, mediaType,
              new HttpHeadersImpl(m).getRequestHeaders(), is);
}
 
Example 2
Source File: ReaderInterceptorContextImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public Object proceed() throws IOException {
    if (readers == null || readers.isEmpty()) {
        return null;
    }
    ReaderInterceptor next = readers.remove(0);
    return next.aroundReadFrom(this);
}