Package javax.ws.rs

Examples of javax.ws.rs.Produces


   
    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


        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

                                                                 "application/xml,application/json");
        Assert.assertTrue(cls.isAnnotationPresent(Path.class));
        Path path = cls.getAnnotation(Path.class);
        Assert.assertEquals("myURI", path.value());

        Produces produces = cls.getAnnotation(Produces.class);
        Assert.assertEquals("application/xml", produces.value()[0]);

        Consumes consumes = cls.getAnnotation(Consumes.class);
        Assert.assertEquals("application/json", consumes.value()[1]);

        Field field = cls.getField("delegate");
View Full Code Here

        logger.trace("Found all MessageBodyWriter ObjectFactories limited by class type {}", //$NON-NLS-1$
                     writerFactories);
        Annotation[] ann = new Annotation[0];
        for (MediaTypeMap<MessageBodyWriter<?>>.OFHolder<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

    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

   
    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

         headers.replaceValues(ACCEPT, accept);
   }

   private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) {
      if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) {
         Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class);
         headers.replaceValues(CONTENT_TYPE, asList(header.value()));
      }
      if (invocation.getInvokable().isAnnotationPresent(Produces.class)) {
         Produces header = invocation.getInvokable().getAnnotation(Produces.class);
         headers.replaceValues(CONTENT_TYPE, asList(header.value()));
      }
   }
View Full Code Here

         headers.replaceValues(ACCEPT, accept);
   }

   private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) {
      if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) {
         Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class);
         headers.replaceValues(CONTENT_TYPE, asList(header.value()));
      }
      if (invocation.getInvokable().isAnnotationPresent(Produces.class)) {
         Produces header = invocation.getInvokable().getAnnotation(Produces.class);
         headers.replaceValues(CONTENT_TYPE, asList(header.value()));
      }
   }
View Full Code Here

            if (m.getName().equals(method)) {
                final Path path = m.getAnnotation(Path.class);
                if (path != null) {
                    lb.path(m);
                }
                Produces ps = m.getAnnotation(Produces.class);
                if (ps == null) {
                    ps = resource.getAnnotation(Produces.class);
                }
                if (ps != null) {
                    final String[] values = ps.value();
                    if (values.length > 0) {
                        lb.type(values[0]);     // use first type
                    }
                }
                return lb;
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.