Package javax.ws.rs

Examples of javax.ws.rs.Produces


      this.httpMethods = httpMethods;
      this.resourceClass = clazz;
      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));
         }
      }
View Full Code Here


            }
        }
        if (produceMediaTypes != null) {
            produceMimes = JAXRSUtils.sortMediaTypes(produceMediaTypes);
        } else {
            Produces pm =
                (Produces)AnnotationUtils.getMethodAnnotation(annotatedMethod, Produces.class);
            if (pm != null) {
                produceMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(pm.value()));
            } else if (classResourceInfo != null) {
                produceMimes = JAXRSUtils.sortMediaTypes(classResourceInfo.getProduceMime());
            }
        }
    }
View Full Code Here

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

            String longDescription = api.description();
            setOptionalAttribute(classElement, "description", longDescription);
            String basePathAttr = api.basePath();
            setOptionalAttribute(classElement, "basePath",basePathAttr);
        }
        Produces produces = classElementIn.getAnnotation(Produces.class);
        if (produces!=null) {
            String[] types = produces.value();
            Element pElement = doc.createElement("produces");
            classElement.appendChild(pElement);
            for (String type : types) {
                Element tElement = doc.createElement("type");
                pElement.appendChild(tElement);
View Full Code Here

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

        }
        return new String[] {};
    }

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

        logger.debug("Found all MessageBodyWriter ObjectFactories limited by class type {}", //$NON-NLS-1$
                     writerFactories);
        Annotation[] ann = new Annotation[0];
        for (ObjectFactory<MessageBodyWriter<?>> factory : writerFactories) {
            MessageBodyWriter<?> writer = factory.getInstance(runtimeContext);
            Produces produces = factory.getInstanceClass().getAnnotation(Produces.class);
            String[] values = null;
            if (produces != null) {
                values = AnnotationUtils.parseConsumesProducesValues(produces.value());
            } else {
                values = new String[] {MediaType.WILDCARD};
            }
            for (String v : values) {
                MediaType mt = MediaType.valueOf(v);
View Full Code Here

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

        public void putProvider(PriorityObjectFactory<T> objectFactory) {
            Produces produces = objectFactory.getInstanceClass().getAnnotation(Produces.class);
            if (produces == null) {
                put(MediaType.WILDCARD_TYPE, objectFactory);
            } else {
                String[] values = AnnotationUtils.parseConsumesProducesValues(produces.value());
                for (String val : values) {
                    put(MediaType.valueOf(val), objectFactory);
                }
            }
        }
View Full Code Here

        return contentType;
    }

    private String[] getAccepts() {
        String accepts[] = {MediaType.APPLICATION_OCTET_STREAM};
        Produces produces = ((JavaOperation)operation).getJavaMethod().getAnnotation(Produces.class);
        if (produces != null) {
            accepts = produces.value();
        }
        WireFormat wf = binding.getResponseWireFormat();
        if (wf != null) {
            if (XMLWireFormat.REST_WIREFORMAT_XML_QNAME.equals(wf.getSchemaName())) {
                accepts = new String[] {MediaType.APPLICATION_XML};
View Full Code Here

            this.consumedMimes = WrapperUtil.convertToMediaTypes(pm.value());
        } else {
            this.consumedMimes = Collections.singletonList(MediaType.ALL);
        }

        final Produces cm = jaxRsProviderClass.getAnnotation(Produces.class);
        if (cm != null) {
            this.producedMimes = WrapperUtil.convertToMediaTypes(cm.value());
        } else {
            this.producedMimes = Collections.singletonList(MediaType.ALL);
        }

        this.genericMbrType = Util.getGenericClass(jaxRsProviderClass,
View Full Code Here

TOP

Related Classes of javax.ws.rs.Produces

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.