Examples of ProviderFactory


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

            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
    }
   
    protected ProviderFactory setupFactory(Endpoint ep) {
        ProviderFactory factory = ProviderFactory.getInstance();
        if (entityProviders != null) {
            factory.setUserProviders(entityProviders);
        }
        if (getDataBinding() != null) {
            setDataBindingProvider(factory, ep.getService());
        }
        factory.setBus(getBus());
        if (schemaLocations != null) {
            factory.setSchemaLocations(schemaLocations);
        }
        ep.put(ProviderFactory.class.getName(), factory);
        return factory;
    }
View Full Code Here

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

   
    protected String convertParamValue(Object pValue, Annotation[] anns) {
        if (pValue == null) {
            return null;
        }
        ProviderFactory pf = ClientProviderFactory.getInstance(cfg.getBus());
        if (pf != null) {
            Class<?> pClass = pValue.getClass();
           
            @SuppressWarnings("unchecked")
            ParamConverter<Object> prov = (ParamConverter<Object>)pf.createParameterHandler(pClass, anns);
            if (prov != null) {
                return prov.toString(pValue);
            }
        }
        return pValue.toString();
View Full Code Here

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

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

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

       
        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

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

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

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

   
    protected String convertParamValue(Object pValue, Annotation[] anns) {
        if (pValue == null) {
            return null;
        }
        ProviderFactory pf = ProviderFactory.getInstance(cfg.getBus());
        if (pf != null) {
            Class<?> pClass = pValue.getClass();
            @SuppressWarnings("unchecked")
            ParamConverter<Object> prov = (ParamConverter<Object>)pf.createParameterHandler(pClass, anns);
            if (prov != null) {
                return prov.toString(pValue);
            }
        }
        return pValue.toString();
View Full Code Here

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

    public JAXRSOutInterceptor() {
        super(Phase.MARSHAL);
    }
   
    public void handleMessage(Message message) {
        ProviderFactory providerFactory = ProviderFactory.getInstance(message);
        try {
            processResponse(providerFactory, message);
        } catch (Exception ex) {
            message.put("jaxrs.out.fault", Boolean.TRUE);   
        } finally {
            Object rootInstance = message.getExchange().remove(JAXRSUtils.ROOT_INSTANCE);
            Object rootProvider = message.getExchange().remove(JAXRSUtils.ROOT_PROVIDER);
            if (rootInstance != null && rootProvider != null) {
                try {
                    ((ResourceProvider)rootProvider).releaseInstance(message, rootInstance);
                } catch (Throwable tex) {
                    LOG.warning("Exception occurred during releasing the service instance, "
                                + tex.getMessage());
                }
            }
            providerFactory.clearThreadLocalProxies();
            ClassResourceInfo cri =
                (ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
            if (cri != null) {
                cri.clearThreadLocalProxies();
            }
View Full Code Here

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

        }
    }
   
    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;
        }
        // HTTP method
        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
                                                        HttpMethod.POST, true);
       
        // Path to match
        String rawPath = HttpUtils.getPathToMatch(message, true);
       
        Map<String, List<String>> protocolHeaders = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
       
        // Content-Type
        String requestContentType = null;
        List<String> ctHeaderValues = protocolHeaders.get(Message.CONTENT_TYPE);
        if (ctHeaderValues != null) {
            requestContentType = ctHeaderValues.get(0);
            message.put(Message.CONTENT_TYPE, requestContentType);
        }
        if (requestContentType == null) {
            requestContentType = (String)message.get(Message.CONTENT_TYPE);
       
            if (requestContentType == null) {
                requestContentType = MediaType.WILDCARD;
            }
        }
       
        // Accept
        String acceptTypes = null;
        List<String> acceptHeaderValues = protocolHeaders.get(Message.ACCEPT_CONTENT_TYPE);
        if (acceptHeaderValues != null) {
            acceptTypes = acceptHeaderValues.get(0);
            message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes);
        }
       
        if (acceptTypes == null) {
            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 ExceptionUtils.toNotAcceptableException(null, null);
        }
        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);

        //1. Matching target resource class
        Service service = message.getExchange().get(Service.class);
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();

        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 ExceptionUtils.toNotFoundException(null, 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

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

    public ClientResponseFilterInterceptor() {
        super(Phase.PRE_PROTOCOL_FRONTEND);
    }
   
    public void handleMessage(Message inMessage) throws Fault {
        ProviderFactory pf = ProviderFactory.getInstance(inMessage);
        if (pf == null) {
            return;
        }
       
        List<ProviderInfo<ClientResponseFilter>> filters = pf.getClientResponseFilters();
        if (!filters.isEmpty()) {
            ClientRequestContext reqContext = new ClientRequestContextImpl(inMessage.getExchange().getInMessage(),
                                                                        true);
           
            ClientResponseContext respContext = new ClientResponseContextImpl(getResponse(inMessage),
View Full Code Here

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

    public ClientRequestFilterInterceptor() {
        super(Phase.PRE_LOGICAL);
    }
   
    public void handleMessage(Message outMessage) throws Fault {
        ProviderFactory pf = ProviderFactory.getInstance(outMessage);
        if (pf == null) {
            return;
        }
       
        List<ProviderInfo<ClientRequestFilter>> filters = pf.getClientRequestFilters();
        if (!filters.isEmpty()) {
           
            final Exchange exchange = outMessage.getExchange();
            final ClientRequestContext context = new ClientRequestContextImpl(outMessage, false);
            for (ProviderInfo<ClientRequestFilter> filter : filters) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.