Search in sources :

Example 1 with ReaderInterceptorContextImpl

use of org.apache.cxf.jaxrs.impl.ReaderInterceptorContextImpl in project cxf by apache.

the class XmlSecInInterceptor method aroundReadFrom.

@Override
public Object aroundReadFrom(ReaderInterceptorContext ctx) throws IOException, WebApplicationException {
    Message message = ((ReaderInterceptorContextImpl) ctx).getMessage();
    if (!canDocumentBeRead(message)) {
        return ctx.proceed();
    }
    prepareMessage(message);
    Object object = ctx.proceed();
    new StaxActionInInterceptor(requireSignature, requireEncryption).handleMessage(message);
    return object;
}
Also used : Message(org.apache.cxf.message.Message) ReaderInterceptorContextImpl(org.apache.cxf.jaxrs.impl.ReaderInterceptorContextImpl)

Example 2 with ReaderInterceptorContextImpl

use of org.apache.cxf.jaxrs.impl.ReaderInterceptorContextImpl in project cxf by apache.

the class JAXRSUtils method readFromMessageBodyReader.

@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);
}
Also used : ReaderInterceptor(javax.ws.rs.ext.ReaderInterceptor) ReaderInterceptorContextImpl(org.apache.cxf.jaxrs.impl.ReaderInterceptorContextImpl) ReaderInterceptorMBR(org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR) ReaderInterceptorContext(javax.ws.rs.ext.ReaderInterceptorContext) HttpHeadersImpl(org.apache.cxf.jaxrs.impl.HttpHeadersImpl)

Aggregations

ReaderInterceptorContextImpl (org.apache.cxf.jaxrs.impl.ReaderInterceptorContextImpl)2 ReaderInterceptor (javax.ws.rs.ext.ReaderInterceptor)1 ReaderInterceptorContext (javax.ws.rs.ext.ReaderInterceptorContext)1 HttpHeadersImpl (org.apache.cxf.jaxrs.impl.HttpHeadersImpl)1 ReaderInterceptorMBR (org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR)1 Message (org.apache.cxf.message.Message)1