Package org.apache.cxf.jaxrs.model

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


                docCategory = DocTarget.RETURN;
                allowDefault = false;
            }
            if (isPrimitive) {
                sb.append(">");   
                Parameter p = inbound ? getRequestBodyParam(ori)
                    : new Parameter(ParameterType.REQUEST_BODY, 0, "result");
                doWriteParam(sb, p, type, type, p.getName() == null ? "request" : p.getName(), anns, isJson);
                sb.append("</representation>");
            } else  {
                type = ResourceUtils.getActualJaxbType(type, opMethod, inbound);
                if (isJson) {
                    sb.append(" element=\"").append(type.getSimpleName()).append("\"");
View Full Code Here


        }
        // Param methods
        MultivaluedMap<String, String> values =
            (MultivaluedMap<String, String>)message.get(URITemplate.TEMPLATE_PARAMETERS);
        for (Method m : bri.getParameterMethods()) {
            Parameter p = ResourceUtils.getParameter(0, m.getAnnotations(),
                                                     m.getParameterTypes()[0]);
            Object o;
           
            if (p.getType() == ParameterType.BEAN && bri instanceof ClassResourceInfo) {
                o = createBeanParamValue(message, m.getParameterTypes()[0], ori);   
            } else {
                o = createHttpParameterValue(p,
                                                m.getParameterTypes()[0],
                                                m.getGenericParameterTypes()[0],
                                                m.getParameterAnnotations()[0],
                                                message,
                                                values,
                                                ori);
            }
            InjectionUtils.injectThroughMethod(requestObject, m, o, message);
        }
        // Param fields
        for (Field f : bri.getParameterFields()) {
            Parameter p = ResourceUtils.getParameter(0, f.getAnnotations(),
                                                     f.getType());
            Object o = null;
           
            if (p.getType() == ParameterType.BEAN && bri instanceof ClassResourceInfo) {
                o = createBeanParamValue(message, f.getType(), ori);   
            } else {
                o = createHttpParameterValue(p,
                                                f.getType(),
                                                f.getGenericType(),
View Full Code Here

            return CastUtils.cast(Collections.emptyList(), Parameter.class);
        }
        Class<?>[] types = resourceMethod.getParameterTypes();
        List<Parameter> params = new ArrayList<Parameter>(paramAnns.length);
        for (int i = 0; i < paramAnns.length; i++) {
            Parameter p = getParameter(i, paramAnns[i], types[i]);
            params.add(p);
        }
        return params;
    }
View Full Code Here

    //CHECKSTYLE:OFF
    public static Parameter getParameter(int index, Annotation[] anns, Class<?> type) {
       
        Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
        if (ctx != null) {
            return new Parameter(ParameterType.CONTEXT, index, null);
        }
       
        boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
       
        BeanParam bp = AnnotationUtils.getAnnotation(anns, BeanParam.class);
        if (bp != null) {
            return new Parameter(ParameterType.BEAN, index, null, isEncoded, null);
        }
       
        String dValue = AnnotationUtils.getDefaultParameterValue(anns);
       
        PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
        if (a != null) {
            return new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
        }
        QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
        if (q != null) {
            return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
        }
        MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
        if (m != null) {
            return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
       
   
        FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
        if (f != null) {
            return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
        }
       
        HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
        if (h != null) {
            return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
       
       
        CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
        if (c != null) {
            return new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
        }
       
        return new Parameter(ParameterType.REQUEST_BODY, index, null);
       
    }
View Full Code Here

            DOMUtils.findAllElementsByTagNameNS(e,
                 "http://cxf.apache.org/jaxrs", "param");
        List<Parameter> params = new ArrayList<Parameter>(paramEls.size());
        for (int i = 0; i < paramEls.size(); i++) {
            Element paramEl = paramEls.get(i);
            Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name"));
            p.setEncoded(Boolean.valueOf(paramEl.getAttribute("encoded")));
            p.setDefaultValue(paramEl.getAttribute("defaultValue"));
            params.add(p);
        }
        op.setParameters(params);
        return op;
    }
View Full Code Here

        Object[] values = new Object[params.length];
        for (int i = 0; i < params.length; i++) {
            if (AnnotationUtils.getAnnotation(anns[i], Context.class) != null) {
                values[i] = JAXRSUtils.createContextValue(m, genericTypes[i], params[i]);
            } else {
                Parameter p = ResourceUtils.getParameter(i, anns[i], params[i]);
                values[i] = JAXRSUtils.createHttpParameterValue(
                                p, params[i], genericTypes[i], anns[i], m, templateValues, null);
            }
        }
        return values;
View Full Code Here

                String propertyName = methodName.substring(minLen).toLowerCase();
                if (m.getReturnType() == Class.class
                    || checkIgnorable && canPropertyBeIgnored(m, propertyName)) {
                    continue;
                }
                params.put(new Parameter(type, propertyName), m.getReturnType());
            }
        }
        return params;
    }
View Full Code Here

        ur.setPath("/hashmap");
        UserOperation op = new UserOperation();
        op.setPath("/key/{id}");
        op.setName("get");
        op.setVerb("POST");
        op.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));
        ur.setOperations(Collections.singletonList(op));
       
        Map<String, UserResource> resources = new HashMap<String, UserResource>();
        resources.put(ur.getName(), ur);
        ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(resources, ur, true, true);
        assertNotNull(cri);
        assertEquals("/hashmap", cri.getURITemplate().getValue());
        Method method =
            HashMap.class.getMethod("get", new Class[]{Object.class});
        OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(method);
        assertNotNull(ori);
        assertEquals("/key/{id}", ori.getURITemplate().getValue());
        List<Parameter> params = ori.getParameters();
        assertNotNull(params);
        Parameter p = params.get(0);
        assertEquals("id", p.getName());
    }
View Full Code Here

        assertEquals("/putAll", oper.getPath());
        assertEquals("PUT", oper.getVerb());
        assertEquals("application/json", oper.getProduces());
        assertEquals("application/xml", oper.getConsumes());
       
        Parameter p = oper.getParameters().get(0);
        assertEquals("map", p.getName());
        assertEquals("emptyMap", p.getDefaultValue());
        assertTrue(p.isEncoded());
        assertEquals("REQUEST_BODY", p.getType().toString());
    }
View Full Code Here

        }
        // Param methods
        MultivaluedMap<String, String> values =
            (MultivaluedMap<String, String>)message.get(URITemplate.TEMPLATE_PARAMETERS);
        for (Method m : bri.getParameterMethods()) {
            Parameter p = ResourceUtils.getParameter(0, m.getAnnotations(),
                                                     m.getParameterTypes()[0]);
            Object o;
           
            if (p.getType() == ParameterType.BEAN && bri instanceof ClassResourceInfo) {
                o = createBeanParamValue(message, m.getParameterTypes()[0], ori);   
            } else {
                o = createHttpParameterValue(p,
                                                m.getParameterTypes()[0],
                                                m.getGenericParameterTypes()[0],
                                                m.getParameterAnnotations()[0],
                                                message,
                                                values,
                                                ori);
            }
            InjectionUtils.injectThroughMethod(requestObject, m, o, message);
        }
        // Param fields
        for (Field f : bri.getParameterFields()) {
            Parameter p = ResourceUtils.getParameter(0, f.getAnnotations(),
                                                     f.getType());
            Object o = null;
           
            if (p.getType() == ParameterType.BEAN && bri instanceof ClassResourceInfo) {
                o = createBeanParamValue(message, f.getType(), ori);   
            } else {
                o = createHttpParameterValue(p,
                                                f.getType(),
                                                f.getGenericType(),
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.model.Parameter

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.