Package javax.ws.rs

Examples of javax.ws.rs.Consumes


            args.add(String.format(ESCAPED_STRING, dateFormat));
        }
    }

    private void addContentTypeHeaderMethodCall(List<MethodCall> methodCalls) {
        Consumes consumes = actionMethod.getAnnotation(Consumes.class);

        if (consumes != null && consumes.value().length > 0) {
            MethodCall methodCall = new MethodCall(
                    ADD_HEADER_PARAM,
                    String.format(ESCAPED_STRING, HttpHeaders.CONTENT_TYPE),
                    String.format(ESCAPED_STRING, consumes.value()[0]));
            methodCalls.add(methodCall);
        }
    }
View Full Code Here


      this.method = method;
      this.methodInjector = injector.createMethodInjector(clazz, method);

      Produces p = method.getAnnotation(Produces.class);
      if (p == null) p = clazz.getAnnotation(Produces.class);
      Consumes c = method.getAnnotation(Consumes.class);
      if (c == null) c = clazz.getAnnotation(Consumes.class);

      if (p != null)
      {
         produces = new MediaType[p.value().length];
         int i = 0;
         for (String mediaType : p.value())
         {
            produces[i++] = MediaType.valueOf(mediaType);
            preferredProduces.add(WeightedMediaType.valueOf(mediaType));
         }
      }
      if (c != null)
      {
         consumes = new MediaType[c.value().length];
         int i = 0;
         for (String mediaType : c.value())
         {
            consumes[i++] = MediaType.valueOf(mediaType);
            preferredConsumes.add(WeightedMediaType.valueOf(mediaType));
         }
      }
View Full Code Here

*/
public class MediaTypeHelper
{
   public static MediaType getConsumes(Class declaring, AccessibleObject method)
   {
      Consumes consume = method.getAnnotation(Consumes.class);
      if (consume == null)
      {
         consume = (Consumes) declaring.getAnnotation(Consumes.class);
         if (consume == null) return null;
      }
      return MediaType.valueOf(consume.value()[0]);
   }
View Full Code Here

    private void checkMediaTypes(String consumeMediaTypes,
                                 String produceMediaTypes) {
        if (consumeMediaTypes != null) {
            consumeMimes = JAXRSUtils.sortMediaTypes(consumeMediaTypes);
        } else {
            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(classResourceInfo.getConsumeMime());
            }
        }
        if (produceMediaTypes != null) {
View Full Code Here

        return msg;
    }

    private String getContentType() {
        String contentType = MediaType.APPLICATION_OCTET_STREAM;
        Consumes consumes = ((JavaOperation)operation).getJavaMethod().getAnnotation(Consumes.class);
        if (consumes != null && consumes.value().length > 0) {
            contentType = consumes.value()[0];
        }
        WireFormat wf = binding.getRequestWireFormat();
        if (wf != null) {
            if (XMLWireFormat.REST_WIREFORMAT_XML_QNAME.equals(wf.getSchemaName())) {
                contentType = MediaType.APPLICATION_XML;
View Full Code Here

          addContentType(contentType);
        }
      }
    }

    Consumes consumes = declaration.getAnnotation(Consumes.class);
    if (consumes != null) {
      for (String contentType : JAXRSUtils.value(consumes)) {
        try {
          addContentType(MimeType.parse(contentType).toString());
        }
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

   
    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

                  p = resourceClass.getAnnotation(Produces.class); // from resource
               }
               // class
               List<MediaType> produces = MediaTypeHelper.createProducesList(p);

               Consumes c = getMethodAnnotation(method, resourceClass, Consumes.class, false);
               if (c == null)
               {
                  c = resourceClass.getAnnotation(Consumes.class); // from resource
               }
               // class
View Full Code Here

    }
   
    private String[] _getAnnotationValues(Class<?> clazz, Class<?> annotationClass) {
        String values[] = null;
        if (annotationClass.equals(Consumes.class)) {
            Consumes consumes = clazz.getAnnotation(Consumes.class);
            if (consumes != null)
                values = consumes.value();
        } else if (annotationClass.equals(Produces.class)) {
            Produces produces = clazz.getAnnotation(Produces.class);
            if (produces != null)
                values = produces.value();
        }
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.