Package javax.ws.rs

Examples of javax.ws.rs.Produces


            throw new IllegalArgumentException("All parameters must be non-null");
        }

        Builder lb = Link.fromUri(UriBuilder.fromResource(resource).build());
        lb.rel(rel);
        final Produces 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


                    return new ContextResolverAdapter(crl);
                }       
            }
           
            List<MediaType> getMediaTypes(ComponentContext ic) {
                Produces p = null;
                for (Annotation a : ic.getAnnotations()) {
                    if (a instanceof Produces) {
                        p = (Produces)a;
                        break;
                    }
View Full Code Here

        workOutSetterMethodsList(resource, methodList, isEncodedAnotOnClass);
       
        final Consumes classScopeConsumesAnnotation =
                annotatedResourceClass.getAnnotation(Consumes.class);
        final Produces classScopeProducesAnnotation =
                annotatedResourceClass.getAnnotation(Produces.class);
        workOutResourceMethodsList(resource, methodList, isEncodedAnotOnClass,
                classScopeConsumesAnnotation, classScopeProducesAnnotation);
        workOutSubResourceMethodsList(resource, methodList, isEncodedAnotOnClass,
                classScopeConsumesAnnotation, classScopeProducesAnnotation);
View Full Code Here

        responses.add(response);
        return responses;
    }

    private boolean hasEmptyProducibleMediaTypeSet(final AbstractResourceMethod method) {
        final Produces produces = method.getMethod().getAnnotation(Produces.class);
        return produces != null && getProducibleMediaTypes(method).isEmpty();
    }
View Full Code Here

        return produces != null && getProducibleMediaTypes(method).isEmpty();
    }

    private List<String> getProducibleMediaTypes(final AbstractResourceMethod method) {
        List<String> mediaTypes = Collections.emptyList();
        final Produces produces = method.getMethod().getAnnotation(Produces.class);

        if (produces != null && produces.value() != null) {
            mediaTypes = Arrays.asList(produces.value());
        }

        return mediaTypes;
    }
View Full Code Here

   
    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

        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

    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

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.