Package org.apache.cxf.jaxrs.provider

Examples of org.apache.cxf.jaxrs.provider.ProviderFactory$MessageBodyWriterComparator


                                                  List<MediaType> consumeTypes,
                                                  Message m) throws IOException, WebApplicationException {
       
        List<MediaType> types = JAXRSUtils.intersectMimeTypes(consumeTypes, contentType);
       
        final ProviderFactory pf = ProviderFactory.getInstance(m);
        for (MediaType type : types) {
            List<ReaderInterceptor> readers = pf.createMessageBodyReaderInterceptor(
                                         targetTypeClass,
                                         parameterType,
                                         parameterAnnotations,
                                         type,
                                         m);
View Full Code Here


           
        }
    }
   
    private static ResponseExceptionMapper<?> findExceptionMapper(Message message, Class<?> exType) {
        ProviderFactory pf = ProviderFactory.getInstance(message);
        return pf.createResponseExceptionMapper(message, exType);
    }
View Full Code Here

        // A little scope for some optimization exists, particularly,
        // it is feasible a complex object may need to be repeatedly converted
        // so we can keep a map of ParamConverter on the bus, that said
        // it seems an over-optimization at this stage, it's a 5% case;
        // typical requests have a limited number of simple URI parameters
        ProviderFactory pf = ProviderFactory.getInstance(cfg.getBus());
        if (pf != null) {
            @SuppressWarnings("unchecked")
            ParamConverter<Object> prov = (ParamConverter<Object>)pf.createParameterHandler(pClass);
            if (prov != null) {
                return prov.toString(pValue);
            }
        }
        return pValue.toString();
View Full Code Here

       
    }
   
    private void processRequest(Message message) {
       
        ProviderFactory providerFactory = ProviderFactory.getInstance(message);
       
        RequestPreprocessor rp = providerFactory.getRequestPreprocessor();
        if (rp != null) {
            rp.preprocess(message, new UriInfoImpl(message, null));
            if (message.getExchange().get(Response.class) != null) {
                return;
            }
        }
       
        // Global pre-match request filters
        if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null)) {
            return;
        }
       
        String requestContentType = (String)message.get(Message.CONTENT_TYPE);
        if (requestContentType == null) {
            requestContentType = "*/*";
        }
       
        String rawPath = HttpUtils.getPathToMatch(message, true);
       
        //1. Matching target resource class
        Service service = message.getExchange().get(Service.class);
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();

        String acceptTypes = HttpUtils.getProtocolHeader(message, Message.ACCEPT_CONTENT_TYPE, null);
        if (acceptTypes == null) {
            acceptTypes = "*/*";
            message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes);
        }
        List<MediaType> acceptContentTypes = null;
        try {
            acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes);
        } catch (IllegalArgumentException ex) {
            throw new NotAcceptableException();
        }
        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);

        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources,
                                          rawPath,
                                          values,
                                          message);
        if (resource == null) {
            org.apache.cxf.common.i18n.Message errorMsg =
                new org.apache.cxf.common.i18n.Message("NO_ROOT_EXC",
                                                   BUNDLE,
                                                   message.get(Message.REQUEST_URI),
                                                   rawPath);
            LOG.warning(errorMsg.toString());
            Response resp = JAXRSUtils.createResponse(null, message, errorMsg.toString(),
                    Response.Status.NOT_FOUND.getStatusCode(), false);
            throw new NotFoundException(resp);
        }

        message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);

        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD, "POST");
        OperationResourceInfo ori = null;    
       
        boolean operChecked = false;
        List<ProviderInfo<RequestHandler>> shs = providerFactory.getRequestHandlers();
        for (ProviderInfo<RequestHandler> sh : shs) {
            if (ori == null && !operChecked) {
                try {               
                    ori = JAXRSUtils.findTargetMethod(resource,
                        message, httpMethod, values,
View Full Code Here

           
        }
    }
   
    private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
        ProviderFactory pf = ProviderFactory.getInstance(message);
        for (Class<?> exType : m.getExceptionTypes()) {
            ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
            if (mapper != null) {
                return mapper;
            }
        }
        return null;
View Full Code Here

       
        return null;
    }
   
    private Message createMessage() {
        ProviderFactory factory = ProviderFactory.getInstance();
        Message m = new MessageImpl();
        m.put("org.apache.cxf.http.case_insensitive_queries", false);
        Exchange e = new ExchangeImpl();
        m.setExchange(e);
        e.setInMessage(m);
View Full Code Here

           
        }
    }
   
    private static ResponseExceptionMapper<?> findExceptionMapper(Message message, Class<?> exType) {
        ProviderFactory pf = ProviderFactory.getInstance(message);
        return pf.createResponseExceptionMapper(exType);
    }
View Full Code Here

                                                  List<MediaType> consumeTypes,
                                                  Message m) throws IOException, WebApplicationException {
       
        List<MediaType> types = JAXRSUtils.intersectMimeTypes(consumeTypes, contentType);
       
        final ProviderFactory pf = ProviderFactory.getInstance(m);
        for (MediaType type : types) {
            List<ReaderInterceptor> readers = pf.createMessageBodyReaderInterceptor(
                                         targetTypeClass,
                                         parameterType,
                                         parameterAnnotations,
                                         type,
                                         m);
View Full Code Here

        // A little scope for some optimization exists, particularly,
        // it is feasible a complex object may need to be repeatedly converted
        // so we can keep a map of ParamConverter on the bus, that said
        // it seems an over-optimization at this stage, it's a 5% case;
        // typical requests have a limited number of simple URI parameters
        ProviderFactory pf = ProviderFactory.getInstance(cfg.getBus());
        if (pf != null) {
            @SuppressWarnings("unchecked")
            ParamConverter<Object> prov = (ParamConverter<Object>)pf.createParameterHandler(pClass);
            if (prov != null) {
                return prov.toString(pValue);
            }
        }
        return pValue.toString();
View Full Code Here

       
    }
   
    private void processRequest(Message message) {
       
        ProviderFactory providerFactory = ProviderFactory.getInstance(message);
       
        RequestPreprocessor rp = providerFactory.getRequestPreprocessor();
        if (rp != null) {
            rp.preprocess(message, new UriInfoImpl(message, null));
            if (message.getExchange().get(Response.class) != null) {
                return;
            }
        }
       
        // Global pre-match request filters
        if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null)) {
            return;
        }
        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
                                                        HttpMethod.POST, true);
       
        String requestContentType = (String)message.get(Message.CONTENT_TYPE);
        if (requestContentType == null) {
            requestContentType = MediaType.WILDCARD;
        }
       
        String rawPath = HttpUtils.getPathToMatch(message, true);
       
        //1. Matching target resource class
        Service service = message.getExchange().get(Service.class);
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();

        String acceptTypes = HttpUtils.getProtocolHeader(message, Message.ACCEPT_CONTENT_TYPE, null);
        if (acceptTypes == null) {
            acceptTypes = "*/*";
            message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes);
        }
        List<MediaType> acceptContentTypes = null;
        try {
            acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes, JAXRSUtils.MEDIA_TYPE_Q_PARAM);
        } catch (IllegalArgumentException ex) {
            throw new NotAcceptableException();
        }
        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);

        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources,
                                          rawPath,
                                          values,
                                          message);
        if (resource == null) {
            org.apache.cxf.common.i18n.Message errorMsg =
                new org.apache.cxf.common.i18n.Message("NO_ROOT_EXC",
                                                   BUNDLE,
                                                   message.get(Message.REQUEST_URI),
                                                   rawPath);
            LOG.warning(errorMsg.toString());
            Response resp = JAXRSUtils.createResponse(null, message, errorMsg.toString(),
                    Response.Status.NOT_FOUND.getStatusCode(), false);
            throw new NotFoundException(resp);
        }

        message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);

        OperationResourceInfo ori = null;    
       
        boolean operChecked = false;
        List<ProviderInfo<RequestHandler>> shs = providerFactory.getRequestHandlers();
        for (ProviderInfo<RequestHandler> sh : shs) {
            if (ori == null && !operChecked) {
                try {               
                    ori = JAXRSUtils.findTargetMethod(resource,
                        message, httpMethod, values,
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.provider.ProviderFactory$MessageBodyWriterComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.