Examples of ClassResourceInfo


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

   
    @SuppressWarnings("unchecked")
    public static void handleSetters(OperationResourceInfo ori,
                                     Object requestObject,
                                     Message message) {
        ClassResourceInfo cri = ori.getClassResourceInfo();
        InjectionUtils.injectContextMethods(requestObject, cri, message);
        // Param methods
        MultivaluedMap<String, String> values =
            (MultivaluedMap<String, String>)message.get(URITemplate.TEMPLATE_PARAMETERS);
        for (Method m : cri.getParameterMethods()) {
            Parameter p = ResourceUtils.getParameter(0, m.getAnnotations());
            Object o = createHttpParameterValue(p,
                                                m.getParameterTypes()[0],
                                                m.getGenericParameterTypes()[0],
                                                message,
                                                values,
                                                ori);
            if (o != null) {
                InjectionUtils.injectThroughMethod(requestObject, m, o);
            }
        }
        // Param fields
        for (Field f : cri.getParameterFields()) {
            Parameter p = ResourceUtils.getParameter(0, f.getAnnotations());
            Object o = createHttpParameterValue(p,
                                                f.getType(),
                                                f.getGenericType(),
                                                message,
View Full Code Here

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

       
        if (!candidateList.isEmpty()) {
            Map.Entry<ClassResourceInfo, MultivaluedMap<String, String>> firstEntry =
                candidateList.entrySet().iterator().next();
            values.putAll(firstEntry.getValue());
            ClassResourceInfo cri = firstEntry.getKey();
            LOG.fine(new org.apache.cxf.common.i18n.Message("CRI_SELECTED",
                                                         BUNDLE,
                                                         cri.getServiceClass().getName(),
                                                         path, cri.getURITemplate().getValue()).toString());
            return cri;
        }
       
        return null;
    }
View Full Code Here

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

            } finally {
                FileUtils.removeDir(classes);
                FileUtils.removeDir(unzippedSrc);
            }
        } finally {
            ClassResourceInfo cri =
                ResourceUtils.createClassResourceInfo(PetStore.class, PetStore.class, true, true);
            new CodeGeneratorProvider().removeCode(cri);
        }
    }
View Full Code Here

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

   
    @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",
View Full Code Here

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

   
    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.ClassResourceInfo

        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.ClassResourceInfo

    protected void checkResources(boolean server) {
        List<ClassResourceInfo> list = serviceFactory.getRealClassResourceInfo();
        if (server) {
            for (Iterator<ClassResourceInfo> it = list.iterator(); it.hasNext();) {
                ClassResourceInfo cri = it.next();
                if (cri.isCreatedFromModel() && cri.getServiceClass() == cri.getResourceClass()
                    && !InjectionUtils.isConcreteClass(cri.getServiceClass())) {
                    it.remove();
                }
            }
        }
        if (list.size() == 0) {
View Full Code Here

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

        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 {
View Full Code Here

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

    protected void checkResources(boolean server) {
        List<ClassResourceInfo> list = serviceFactory.getRealClassResourceInfo();
        if (server) {
            for (Iterator<ClassResourceInfo> it = list.iterator(); it.hasNext();) {
                ClassResourceInfo cri = it.next();
                if (cri.isCreatedFromModel() && cri.getServiceClass() == cri.getResourceClass()
                    && !InjectionUtils.isConcreteClass(cri.getServiceClass())) {
                    it.remove();
                }
            }
        }
        if (list.size() == 0) {
View Full Code Here

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

     * @return the client
     */
    public Client createWithValues(Object... varValues) {
        serviceFactory.setBus(getBus());
        checkResources(false);
        ClassResourceInfo cri = null;
        try {
            Endpoint ep = createEndpoint();
            if (getServiceClass() != null) {
                for (ClassResourceInfo info : serviceFactory.getClassResourceInfo()) {
                    if (info.getServiceClass().isAssignableFrom(getServiceClass())
                        || getServiceClass().isAssignableFrom(info.getServiceClass())) {
                        cri = info;
                        break;
                    }
                }
                if (cri == null) {
                    // can not happen in the reality
                    throw new RuntimeException("Service class " + getServiceClass().getName()
                                               + " is not recognized");
                }
            } else {
                cri = serviceFactory.getClassResourceInfo().get(0);
            }
           
            boolean isRoot = cri.getURITemplate() != null;
            ClientProxyImpl proxyImpl = null;
            ClientState actualState = getActualState();
            if (actualState == null) {
                proxyImpl =
                    new ClientProxyImpl(URI.create(getAddress()), proxyLoader, cri, isRoot,
                                        inheritHeaders, varValues);
            } else {
                proxyImpl =
                    new ClientProxyImpl(actualState, proxyLoader, cri, isRoot,
                                        inheritHeaders, varValues);
            }
            initClient(proxyImpl, ep, actualState == null);   
           
            ClassLoader theLoader = proxyLoader == null ? cri.getServiceClass().getClassLoader() : proxyLoader;
            Class<?>[] ifaces = new Class[]{Client.class, InvocationHandlerAware.class, cri.getServiceClass()};
            Client actualClient = (Client)ProxyHelper.getProxy(theLoader, ifaces, proxyImpl);
            notifyLifecycleManager(actualClient);
            this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, actualClient, ep);
            return actualClient;
        } catch (IllegalArgumentException ex) {
            String message = ex.getLocalizedMessage();
            if (cri != null) {
                String expected = cri.getServiceClass().getSimpleName();
                if ((expected + " is not an interface").equals(message)) {
                    message += "; make sure CGLIB is on the classpath";
                }
            }
            LOG.severe(ex.getClass().getName() + " : " + message);
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.