Examples of OperationResourceInfo


Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        if (!candidateList.isEmpty()) {
            Map.Entry<OperationResourceInfo, MultivaluedMap<String, String>> firstEntry =
                candidateList.entrySet().iterator().next();
            values.clear();
            values.putAll(firstEntry.getValue());
            OperationResourceInfo ori = firstEntry.getKey();
            if (headMethodPossible(ori.getHttpMethod(), httpMethod)) {
                LOG.info(new org.apache.cxf.common.i18n.Message("GET_INSTEAD_OF_HEAD",
                         BUNDLE, resource.getServiceClass().getName(),
                         ori.getMethodToInvoke().getName()).toString());
            }
            LOG.fine(new org.apache.cxf.common.i18n.Message("OPER_SELECTED",
                           BUNDLE, ori.getMethodToInvoke().getName(),
                           resource.getServiceClass().getName()).toString());
            return ori;
        }
       
        int status;
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

    }
   
    @SuppressWarnings("unchecked")
    public Object invoke(Exchange exchange, Object request, Object resourceObject) {

        OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
        ClassResourceInfo cri = ori.getClassResourceInfo();

        boolean wasSuspended = exchange.remove(REQUEST_WAS_SUSPENDED) != null;
       
        if (!wasSuspended) {
            pushOntoStack(ori, ClassHelper.getRealClass(resourceObject), exchange.getInMessage());
                   
            if (cri.isRoot()) {
                Object realResourceObject = ClassHelper.getRealObject(resourceObject);
                JAXRSUtils.injectParameters(ori, realResourceObject,
                                         exchange.getInMessage());
   
                InjectionUtils.injectContexts(realResourceObject,
                                              ori.getClassResourceInfo(),
                                              exchange.getInMessage());
               
                ProviderInfo<?> appProvider =
                    (ProviderInfo)exchange.getEndpoint().get(Application.class.getName());
                if (appProvider != null) {
                    InjectionUtils.injectContexts(appProvider.getProvider(),
                                                  appProvider,
                                                  exchange.getInMessage());
                }
               
            }
        }
       

        Method methodToInvoke = InjectionUtils.checkProxy(
            cri.getMethodDispatcher().getMethod(ori), resourceObject);
       
        List<Object> params = null;
        if (request instanceof List) {
            params = CastUtils.cast((List<?>)request);
        } else if (request != null) {
            params = new MessageContentsList(request);
        }

        Object result = null;
        ClassLoader contextLoader = null;
        try {
            if (setServiceLoaderAsContextLoader(exchange.getInMessage())) {
                contextLoader = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(resourceObject.getClass().getClassLoader());
            }
            result = invoke(exchange, resourceObject, methodToInvoke, params);
        } catch (Fault ex) {
            Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause(),
                                                                     exchange.getInMessage());
            if (excResponse == null) {
                ProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
                ClassResourceInfo criRoot =
                    (ClassResourceInfo)exchange.get(JAXRSUtils.ROOT_RESOURCE_CLASS);
                if (criRoot != null) {
                    criRoot.clearThreadLocalProxies();
                }
                exchange.put(Message.PROPOGATE_EXCEPTION,
                             JAXRSUtils.propogateException(exchange.getInMessage()));
                throw ex;
            }
            return new MessageContentsList(excResponse);
        } finally {
            exchange.put(LAST_SERVICE_OBJECT, resourceObject);
            if (contextLoader != null) {
                Thread.currentThread().setContextClassLoader(contextLoader);
            }
        }

        if (ori.isSubResourceLocator()) {
            try {
                Message msg = exchange.getInMessage();
                MultivaluedMap<String, String> values = getTemplateValues(msg);
                String subResourcePath = values.getFirst(URITemplate.FINAL_MATCH_GROUP);
                String httpMethod = (String)msg.get(Message.HTTP_REQUEST_METHOD);
                String contentType = (String)msg.get(Message.CONTENT_TYPE);
                if (contentType == null) {
                    contentType = "*/*";
                }
                List<MediaType> acceptContentType =
                    (List<MediaType>)msg.getExchange().get(Message.ACCEPT_CONTENT_TYPE);

                result = checkResultObject(result, subResourcePath);

                ClassResourceInfo subCri = cri.getSubResource(
                     methodToInvoke.getReturnType(),
                     ClassHelper.getRealClass(result));
                if (subCri == null) {
                    org.apache.cxf.common.i18n.Message errorM =
                        new org.apache.cxf.common.i18n.Message("NO_SUBRESOURCE_FOUND",
                                                               BUNDLE,
                                                               subResourcePath);
                    LOG.severe(errorM.toString());
                    throw new WebApplicationException(404);
                }

                OperationResourceInfo subOri = JAXRSUtils.findTargetMethod(subCri,
                                                         exchange.getInMessage(),
                                                         httpMethod,
                                                         values,
                                                         contentType,
                                                         acceptContentType,
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

    }
   
    private ResourceProvider getResourceProvider(Exchange exchange) {
        Object provider = exchange.remove(JAXRSUtils.ROOT_PROVIDER);
        if (provider == null) {
            OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
            ClassResourceInfo cri = ori.getClassResourceInfo();
            return cri.getResourceProvider();
        } else {
            return (ResourceProvider)provider;
        }
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        Object root = exchange.remove(JAXRSUtils.ROOT_INSTANCE);
        if (root != null) {
            return root;
        }
       
        OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
        ClassResourceInfo cri = ori.getClassResourceInfo();

        return cri.getResourceProvider().getInstance(exchange.getInMessage());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        List<OperationResourceInfo> sortedOps = sortOperationsByPath(
            cri.getMethodDispatcher().getOperationResourceInfos());
       
        boolean resourceTagOpened = false;
        for (int i = 0; i < sortedOps.size(); i++) {
            OperationResourceInfo ori = sortedOps.get(i);
           
            if (ori.getHttpMethod() == null) {
                Class<?> cls = getMethod(ori).getReturnType();
                ClassResourceInfo subcri = cri.findResource(cls, cls);
                if (subcri != null && !visitedResources.contains(subcri)) {
                    startResourceTag(sb, subcri.getServiceClass(), ori.getURITemplate().getValue());
                    handleDocs(subcri.getServiceClass().getAnnotations(), sb);
                    handlePathAndMatrixParams(sb, ori);
                    handleResource(sb, jaxbTypes, qnameResolver, clsMap, subcri,
                                   visitedResources);
                    sb.append("</resource>");
                } else {
                    handleDynamicSubresource(sb, jaxbTypes, qnameResolver, clsMap, ori, subcri);
                }
                continue;
            }
            OperationResourceInfo nextOp = i + 1 < sortedOps.size() ? sortedOps.get(i + 1) : null;
            resourceTagOpened = handleOperation(sb, jaxbTypes, qnameResolver, clsMap, ori, nextOp,
                                                resourceTagOpened, i);
        }
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

    }
       
    protected Object performInvocation(Exchange cxfExchange, final Object serviceObject, Method method,
                                       Object[] paramArray) throws Exception {
        paramArray = insertExchange(method, paramArray, cxfExchange);
        OperationResourceInfo ori = cxfExchange.get(OperationResourceInfo.class);       
        if (ori.isSubResourceLocator()) {
            // don't delegate the sub resource locator call to camel processor
            return method.invoke(serviceObject, paramArray);
        }
        Continuation continuation;
        if (!endpoint.isSynchronous() && (continuation = getContinuation(cxfExchange)) != null) {
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

    }
       
    protected Object performInvocation(Exchange cxfExchange, final Object serviceObject, Method method,
                                       Object[] paramArray) throws Exception {
        paramArray = insertExchange(method, paramArray, cxfExchange);
        OperationResourceInfo ori = cxfExchange.get(OperationResourceInfo.class);       
        if (ori.isSubResourceLocator()) {
            // don't delegate the sub resource locator call to camel processor
            return method.invoke(serviceObject, paramArray);
        }
        Continuation continuation;
        if (!endpoint.isSynchronous() && (continuation = getContinuation(cxfExchange)) != null) {
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        if (Client.class == declaringClass || InvocationHandlerAware.class == declaringClass
            || Object.class == declaringClass) {
            return m.invoke(this, params);
        }
        resetResponse();
        OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
        if (ori == null) {
            reportInvalidResourceMethod(m, "INVALID_RESOURCE_METHOD");
        }
       
        MultivaluedMap<ParameterType, Parameter> types = getParametersInfo(m, params, ori);
        List<Parameter> beanParamsList =  getParameters(types, ParameterType.BEAN);
       
       
        List<Object> pathParams = getPathParamValues(m, params, types, beanParamsList, ori);
       
        int bodyIndex = getBodyIndex(types, ori);
       
        UriBuilder builder = getCurrentBuilder().clone();
        if (isRoot) {
            addNonEmptyPath(builder, ori.getClassResourceInfo().getURITemplate().getValue());
        }
        addNonEmptyPath(builder, ori.getURITemplate().getValue());
       
        handleMatrixes(m, params, types, beanParamsList, builder);
        handleQueries(m, params, types, beanParamsList, builder);
       
        URI uri = builder.buildFromEncoded(pathParams.toArray()).normalize();
       
        MultivaluedMap<String, String> headers = getHeaders();
        MultivaluedMap<String, String> paramHeaders = new MetadataMap<String, String>();
        handleHeaders(m, params, paramHeaders, beanParamsList, types);
        handleCookies(m, params, paramHeaders, beanParamsList, types);
               
        if (ori.isSubResourceLocator()) {
            ClassResourceInfo subCri = cri.getSubResource(m.getReturnType(), m.getReturnType());
            if (subCri == null) {
                reportInvalidResourceMethod(m, "INVALID_SUBRESOURCE");
            }
           
            MultivaluedMap<String, String> subHeaders = paramHeaders;
            if (inheritHeaders) {
                subHeaders.putAll(headers);   
            }
           
            ClientState newState = getState().newState(uri, subHeaders,
                 getTemplateParametersMap(ori.getURITemplate(), pathParams));
            ClientProxyImpl proxyImpl =
                new ClientProxyImpl(newState, proxyLoader, subCri, false, inheritHeaders);
            proxyImpl.setConfiguration(getConfiguration());
            return JAXRSClientFactory.createProxy(m.getReturnType(), proxyLoader, proxyImpl);
        }
       
        headers.putAll(paramHeaders);
        setRequestHeaders(headers, ori, types.containsKey(ParameterType.FORM),
            bodyIndex == -1 || params[bodyIndex] == null ? null : params[bodyIndex].getClass(), m.getReturnType());
       
        getState().setTemplates(getTemplateParametersMap(ori.getURITemplate(), pathParams));
       
        Object body = null;
        if (bodyIndex != -1) {
            body = params[bodyIndex];
            if (body == null) {
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

                                 Exchange exchange,
                                 Map<String, Object> invContext) throws Throwable {
       
        Map<String, Object> reqContext = CastUtils.cast((Map<?, ?>)invContext.get(REQUEST_CONTEXT));
        int bodyIndex = body != null ? (Integer)reqContext.get("BODY_INDEX") : -1;
        OperationResourceInfo ori =
            (OperationResourceInfo)reqContext.get(OperationResourceInfo.class.getName());
        return doChainedInvocation(newRequestURI, headers, ori,
                                   body, bodyIndex, exchange, invContext);
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

                                   Type bodyType,
                                   Annotation[] customAnns,
                                   OutputStream os) throws Fault {
           
           
            OperationResourceInfo ori = outMessage.getContent(OperationResourceInfo.class);
            if (ori == null) {
                return;
            }
           
            Method method = ori.getMethodToInvoke();
            int bodyIndex = (Integer)outMessage.get("BODY_INDEX");
           
            Annotation[] anns = customAnns != null ? customAnns
                : getMethodAnnotations(ori.getAnnotatedMethod(), bodyIndex);
            try {
                if (bodyIndex != -1) {
                    Class<?> paramClass = method.getParameterTypes()[bodyIndex];
                    Class<?> bodyClass =
                        paramClass.isAssignableFrom(body.getClass()) ? paramClass : body.getClass();
                    Type genericType = method.getGenericParameterTypes()[bodyIndex];
                    if (bodyType != null) {
                        genericType = bodyType;
                    }
                    genericType = InjectionUtils.processGenericTypeIfNeeded(
                        ori.getClassResourceInfo().getServiceClass(), bodyClass, genericType);
                    bodyClass = InjectionUtils.updateParamClassToTypeIfNeeded(bodyClass, genericType);
                    writeBody(body, outMessage, bodyClass, genericType, anns, os);
                } else {
                    Type paramType = body.getClass();
                    if (bodyType != null) {
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.