Java Code Examples for org.apache.cxf.jaxrs.utils.JAXRSUtils#getProviderConsumeTypes()

The following examples show how to use org.apache.cxf.jaxrs.utils.JAXRSUtils#getProviderConsumeTypes() . 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: ProviderFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
public int compare(ProviderInfo<MessageBodyReader<?>> p1,
                   ProviderInfo<MessageBodyReader<?>> p2) {
    MessageBodyReader<?> e1 = p1.getProvider();
    MessageBodyReader<?> e2 = p2.getProvider();

    List<MediaType> types1 = JAXRSUtils.getProviderConsumeTypes(e1);
    types1 = JAXRSUtils.sortMediaTypes(types1, null);
    List<MediaType> types2 = JAXRSUtils.getProviderConsumeTypes(e2);
    types2 = JAXRSUtils.sortMediaTypes(types2, null);

    int result = JAXRSUtils.compareSortedMediaTypes(types1, types2, null);
    if (result != 0) {
        return result;
    }
    result = compareClasses(e1, e2);
    if (result != 0) {
        return result;
    }
    result = compareCustomStatus(p1, p2);
    if (result != 0) {
        return result;
    }
    return comparePriorityStatus(p1.getProvider().getClass(), p2.getProvider().getClass());
}
 
Example 2
Source File: ProviderFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
private <T> boolean matchesReaderMediaTypes(ProviderInfo<MessageBodyReader<?>> pi,
                                            MediaType mediaType) {
    MessageBodyReader<?> ep = pi.getProvider();
    List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderConsumeTypes(ep);

    return JAXRSUtils.doMimeTypesIntersect(Collections.singletonList(mediaType), supportedMediaTypes);
}