Search in sources :

Example 26 with ProviderInfo

use of org.apache.cxf.jaxrs.model.ProviderInfo in project cxf by apache.

the class ProviderFactory method createMessageBodyWriterInterceptor.

public <T> List<WriterInterceptor> createMessageBodyWriterInterceptor(Class<T> bodyType, Type parameterType, Annotation[] parameterAnnotations, MediaType mediaType, Message m, Set<String> names) {
    MessageBodyWriter<T> mw = createMessageBodyWriter(bodyType, parameterType, parameterAnnotations, mediaType, m);
    int size = writerInterceptors.size();
    if (mw != null || size > 0) {
        @SuppressWarnings({ "unchecked", "rawtypes" }) WriterInterceptor mbwWriter = new WriterInterceptorMBW((MessageBodyWriter) mw, m);
        final List<WriterInterceptor> interceptors;
        if (size > 0) {
            interceptors = new ArrayList<>(size + 1);
            List<ProviderInfo<WriterInterceptor>> writers = getBoundFilters(writerInterceptors, names);
            for (ProviderInfo<WriterInterceptor> p : writers) {
                injectContextValues(p, m);
                interceptors.add(p.getProvider());
            }
            interceptors.add(mbwWriter);
        } else {
            interceptors = Collections.singletonList(mbwWriter);
        }
        return interceptors;
    }
    return null;
}
Also used : WriterInterceptor(javax.ws.rs.ext.WriterInterceptor) WriterInterceptorMBW(org.apache.cxf.jaxrs.impl.WriterInterceptorMBW) FilterProviderInfo(org.apache.cxf.jaxrs.model.FilterProviderInfo) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) Endpoint(org.apache.cxf.endpoint.Endpoint)

Aggregations

ProviderInfo (org.apache.cxf.jaxrs.model.ProviderInfo)26 Endpoint (org.apache.cxf.endpoint.Endpoint)9 FilterProviderInfo (org.apache.cxf.jaxrs.model.FilterProviderInfo)7 Response (javax.ws.rs.core.Response)6 Message (org.apache.cxf.message.Message)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 Comparator (java.util.Comparator)4 Map (java.util.Map)4 WriterInterceptor (javax.ws.rs.ext.WriterInterceptor)4 MessageImpl (org.apache.cxf.message.MessageImpl)4 List (java.util.List)3 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)3 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)3 MessageBodyReader (javax.ws.rs.ext.MessageBodyReader)3 ReaderInterceptor (javax.ws.rs.ext.ReaderInterceptor)3 Bus (org.apache.cxf.Bus)3 ContainerRequestContextImpl (org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl)3 MetadataMap (org.apache.cxf.jaxrs.impl.MetadataMap)3 File (java.io.File)2