Examples of Produces


Examples of javax.ws.rs.Produces

    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

Examples of javax.ws.rs.Produces

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

Examples of javax.ws.rs.Produces

         {
            List<MethodParameter> params = createMethodParametersList(resourceClass, method);
            if (httpMethod != null)
            {

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

Examples of javax.ws.rs.Produces

   
    private MediaType checkFinalContentType(MediaType mt, List<WriterInterceptor> writers) {
        if (mt.isWildcardType() || mt.isWildcardSubtype()) {
            int mbwIndex = writers.size() == 1 ? 0 : writers.size() - 1;
            MessageBodyWriter<Object> writer = ((WriterInterceptorMBW)writers.get(mbwIndex)).getMBW();
            Produces pm = writer.getClass().getAnnotation(Produces.class);
            if (pm != null) {
                List<MediaType> sorted =
                    JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(pm.value()), JAXRSUtils.MEDIA_TYPE_QS_PARAM);
                mt = JAXRSUtils.intersectMimeTypes(sorted, mt).get(0);
                if (mt.isWildcardType() || mt.isWildcardSubtype()) {
                    return MediaType.APPLICATION_OCTET_STREAM_TYPE;   
                }
            } else {
View Full Code Here

Examples of javax.ws.rs.Produces

   
    public List<MediaType> getProduceMime() {
        if (producesTypes != null) {
            return JAXRSUtils.parseMediaTypes(producesTypes);
        }
        Produces produces = AnnotationUtils.getClassAnnotation(getServiceClass(), Produces.class);
        if (produces != null || parent == null) {
            return JAXRSUtils.getProduceTypes(produces);
        } else {
            return parent.getProduceMime();
        }
View Full Code Here

Examples of javax.ws.rs.Produces

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

Examples of javax.ws.rs.Produces

    @Test
    public void testEntityAnnotations() throws Exception {
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        Annotation[] annotations = new Annotation[1];
        Annotation produces = new Produces() {
            @Override
            public Class<? extends Annotation> annotationType() {
                return Produces.class;
            }
            @Override
View Full Code Here

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

Examples of javax.ws.rs.Produces

                                                                 "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

Examples of javax.ws.rs.Produces

         {
            List<MethodParameter> params = createMethodParametersList(resourceClass, method);
            if (httpMethod != null)
            {

               Produces p = getMethodAnnotation(method, resourceClass, Produces.class, false);
               if (p == null)
               {
                  p = resourceClass.getAnnotation(Produces.class); // from resource
               }
               // class
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.