Package javax.ws.rs

Examples of javax.ws.rs.Consumes


        }
        return true;
    }

    private String[] getConsumes(AnnotatedElement element) {
        Consumes consumes = element.getAnnotation(Consumes.class);
        if (consumes != null) {
            return AnnotationUtils.parseConsumesProducesValues(consumes.value());
        }
        return new String[] {};
    }
View Full Code Here


    private List<ConsumesMethod> getConsumingMethods(Class<?> assetType, MediaType mediaType) {
        // collect all the methods that are annotated with @Consumes
        List<ConsumesMethod> locators = new LinkedList<ConsumesMethod>();
        Method[] methods = assetType.getMethods();
        for (Method method : methods) {
            Consumes annotation = method.getAnnotation(Consumes.class);
            if (annotation != null) {
                String[] producesArray =
                    AnnotationUtils.parseConsumesProducesValues(annotation.value());
                List<MediaType> produces = toSortedMediaTypes(producesArray);
                for (MediaType mt : produces) {
                    if (mt.isCompatible(mediaType)) {
                        ConsumesMethod consumesMethod = new ConsumesMethod(method, mt);
                        if (consumesMethod.getType() != null) {
View Full Code Here

   
    public static List<MediaType> getProviderConsumeTypes(MessageBodyReader provider) {
        String[] values = getUserMediaTypes(provider, "getConsumeMediaTypes");
       
        if (values == null) {
            Consumes c = provider.getClass().getAnnotation(Consumes.class);
            values = c == null ? new String[]{"*/*"} : c.value();
        }
        return JAXRSUtils.getMediaTypes(values);
    }
View Full Code Here

       
        return consumeMimes;
    }
   
    private void checkMediaTypes() {
        Consumes cm =
            (Consumes)AnnotationUtils.getMethodAnnotation(annotatedMethod, Consumes.class);
        if (cm != null) {
            consumeMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(cm.value()));
        } else if (classResourceInfo != null) {
            consumeMimes = JAXRSUtils.sortMediaTypes(
                               JAXRSUtils.getConsumeTypes(classResourceInfo.getConsumeMime()));
        }
       
View Full Code Here

        final String[] accepts = produces == null ? null : produces.value();

        // determine content type
        String contentType = null;
        if (entity != null) {
            Consumes consumes = method.getAnnotation(Consumes.class);
            if (consumes == null) {
                consumes = proxyIfc.getAnnotation(Consumes.class);
            }
            if (consumes != null && consumes.value().length > 0) {
                // TODO: should consider q/qs instead of picking the first one
                contentType = consumes.value()[0];
            }
        }

        Invocation.Builder builder;
        if (accepts != null) {
View Full Code Here

        return HttpMethod.GET;
    }

    private String getConsumes(Method method) {
        Consumes consumes = method.getAnnotation(Consumes.class);
        if (consumes == null || consumes.value() == null) {
            return MediaType.TEXT_PLAIN;
        }
        return consumes.value()[0];
    }
View Full Code Here

    class ProducesClass {
    }

    @Test
    public void testConsumes() {
        final Consumes c = ConsumesClass.class.getAnnotation(Consumes.class);
        final List<MediaType> l = MediaTypes.createFrom(c);
        checkMediaTypes(l);
    }
View Full Code Here

    class ProducesStringClass {
    }

    @Test
    public void testConsumesString() {
        final Consumes c = ConsumesStringClass.class.getAnnotation(Consumes.class);
        final List<MediaType> l = MediaTypes.createFrom(c);
        checkMediaTypes(l);
    }
View Full Code Here

    class ProducesStringsClass {
    }

    @Test
    public void testConsumesStrings() {
        final Consumes c = ConsumesStringsClass.class.getAnnotation(Consumes.class);
        final List<MediaType> l = MediaTypes.createFrom(c);
        checkMediaTypes(l);
    }
View Full Code Here

                    } else {
                        p("__method.header(" + RESOURCE_CLASS + ".HEADER_ACCEPT, " + RESOURCE_CLASS + ".CONTENT_TYPE_JSON);");
                    }
                }

                Consumes consumesAnnotation = findAnnotationOnMethodOrEnclosingType(method, Consumes.class);
                if (consumesAnnotation != null) {
                    p("__method.header(" + RESOURCE_CLASS + ".HEADER_CONTENT_TYPE, "+wrap(consumesAnnotation.value()[0])+");");
                }

                // and set the explicit headers now (could override the accept header)
                for (Map.Entry<String, JParameter> entry : headerParams.entrySet()) {
                    String expr = entry.getValue().getName();
View Full Code Here

TOP

Related Classes of javax.ws.rs.Consumes

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.