use of org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR in project tomee by apache.
the class ProviderFactory method createMessageBodyReaderInterceptor.
public <T> List<ReaderInterceptor> createMessageBodyReaderInterceptor(Class<T> bodyType, Type parameterType, Annotation[] parameterAnnotations, MediaType mediaType, Message m, boolean checkMbrNow, Set<String> names) {
MessageBodyReader<T> mr = !checkMbrNow ? null : createMessageBodyReader(bodyType, parameterType, parameterAnnotations, mediaType, m);
int size = readerInterceptors.size();
if (mr != null || size > 0) {
ReaderInterceptor mbrReader = new ReaderInterceptorMBR(mr, getResponseMessage(m));
final List<ReaderInterceptor> interceptors;
if (size > 0) {
interceptors = new ArrayList<>(size + 1);
List<ProviderInfo<ReaderInterceptor>> readers = getBoundFilters(readerInterceptors, names);
for (ProviderInfo<ReaderInterceptor> p : readers) {
injectContextValues(p, m);
interceptors.add(p.getProvider());
}
interceptors.add(mbrReader);
} else {
interceptors = Collections.singletonList(mbrReader);
}
return interceptors;
}
return null;
}
use of org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR in project cxf by apache.
the class ProviderFactory method createMessageBodyReaderInterceptor.
public <T> List<ReaderInterceptor> createMessageBodyReaderInterceptor(Class<T> bodyType, Type parameterType, Annotation[] parameterAnnotations, MediaType mediaType, Message m, boolean checkMbrNow, Set<String> names) {
MessageBodyReader<T> mr = !checkMbrNow ? null : createMessageBodyReader(bodyType, parameterType, parameterAnnotations, mediaType, m);
int size = readerInterceptors.size();
if (mr != null || size > 0) {
ReaderInterceptor mbrReader = new ReaderInterceptorMBR(mr, getResponseMessage(m));
final List<ReaderInterceptor> interceptors;
if (size > 0) {
interceptors = new ArrayList<>(size + 1);
List<ProviderInfo<ReaderInterceptor>> readers = getBoundFilters(readerInterceptors, names);
for (ProviderInfo<ReaderInterceptor> p : readers) {
injectContextValues(p, m);
interceptors.add(p.getProvider());
}
interceptors.add(mbrReader);
} else {
interceptors = Collections.singletonList(mbrReader);
}
return interceptors;
}
return null;
}
use of org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR in project tomee 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);
}
use of org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR 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);
}
Aggregations