Package javax.ws.rs

Examples of javax.ws.rs.Consumes


   public void addMessageBodyReader(MessageBodyReader provider, boolean isBuiltin)
   {
      SortedKey<MessageBodyReader> key = new SortedKey<MessageBodyReader>(MessageBodyReader.class, provider, isBuiltin);
      injectProperties(provider);
      providers.put(provider.getClass(), provider);
      Consumes consumeMime = provider.getClass().getAnnotation(Consumes.class);
      if (consumeMime != null)
      {
         for (String consume : consumeMime.value())
         {
            MediaType mime = MediaType.valueOf(consume);
            messageBodyReaders.add(mime, key);
         }
      }
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

      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 = methodConsumes = 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

    Path klassPath = klass.getAnnotation(Path.class);
    Produces produces = method.getAnnotation(Produces.class);
    if (produces == null)
      produces = klass.getAnnotation(Produces.class);
    this.wants = getWants(produces);
    Consumes consumes = method.getAnnotation(Consumes.class);
    if (consumes == null)
      consumes = klass.getAnnotation(Consumes.class);
    this.uri = appendURIFragments(registry, klassPath, methodPath);
    if(serviceRegistry.isRoot())
      this.functionPrefix = klass.getSimpleName();
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 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

        }
        return true;
    }

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

        public ConsumesMediaTypeMap(Class<?> rawType) {
            super(rawType);
        }

        public void putProvider(ObjectFactory<T> objectFactory) {
            Consumes consumes = objectFactory.getInstanceClass().getAnnotation(Consumes.class);
            if (consumes == null) {
                put(MediaType.WILDCARD_TYPE, objectFactory);
            } else {
                String[] values = consumes.value();
                for (String val : values) {
                    put(MediaType.valueOf(val), objectFactory);
                }
            }
        }
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

    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 = 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

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.