Package javax.ws.rs.ext

Examples of javax.ws.rs.ext.MessageBodyReader.readFrom()


                }


                try {
                    //noinspection unchecked
                    return reader.readFrom(
                            parameter.getRawType(),
                            parameter.getType(),
                            parameter.getAnnotations(),
                            mediaType,
                            request.getHeaders(),
View Full Code Here


                                    String.class,
                                    String.class,
                                    parameter.getAnnotations(),
                                    mediaType);

                            @SuppressWarnings("unchecked") final String value = (String) reader.readFrom(
                                    String.class,
                                    String.class,
                                    parameter.getAnnotations(),
                                    mediaType,
                                    request.getHeaders(),
View Full Code Here

                                         type,
                                         m);
            if (provider != null) {
                try {
                    HttpHeaders headers = new HttpHeadersImpl(m);
                    return provider.readFrom(
                              targetTypeClass, parameterType, parameterAnnotations, contentType,
                              headers.getRequestHeaders(), is);
                } catch (IOException e) {
                    String errorMessage = "Error deserializing input stream into target class "
                                          + targetTypeClass.getSimpleName()
View Full Code Here

            ProviderFactory.getInstance().createMessageBodyReader(
                cls, type, anns, contentType, inMessage);
        }
        if (mbr != null) {
            try {
                return mbr.readFrom(cls, type, anns, contentType,
                       new MetadataMap<String, Object>(r.getMetadata(), true, true), inputStream);
            } catch (Exception ex) {
                throw new WebApplicationException();
            }
            
View Full Code Here

                                         type,
                                         m);
            if (provider != null) {
                try {
                    HttpHeaders headers = new HttpHeadersImpl(m);
                    return provider.readFrom(
                              targetTypeClass, parameterType, parameterAnnotations, contentType,
                              headers.getRequestHeaders(), is);
                } catch (IOException e) {
                    String errorMessage = "Error deserializing input stream into target class "
                                          + targetTypeClass.getSimpleName()
View Full Code Here

               }

               try
               {
                  p[i++] =
                     entityReader.readFrom(mp.getParameterClass(), mp.getGenericType(), mp.getAnnotations(),
                        contentType, headers, entityStream);
               }
               catch (IOException e)
               {
View Full Code Here

   
    @SuppressWarnings("unchecked")
    @Test
    public void testReadFrom() throws Exception {
        MessageBodyReader p = new BinaryDataProvider();
        byte[] bytes = (byte[])p.readFrom(byte[].class, null, null,
                                          new ByteArrayInputStream("hi".getBytes()));
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
       
        InputStream is = (InputStream)p.readFrom(InputStream.class, null, null,
                                          new ByteArrayInputStream("hi".getBytes()));
View Full Code Here

        MessageBodyReader p = new BinaryDataProvider();
        byte[] bytes = (byte[])p.readFrom(byte[].class, null, null,
                                          new ByteArrayInputStream("hi".getBytes()));
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
       
        InputStream is = (InputStream)p.readFrom(InputStream.class, null, null,
                                          new ByteArrayInputStream("hi".getBytes()));
        bytes = IOUtils.readBytesFromStream(is);
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
    }
   
View Full Code Here

            provider = ProviderFactory.getInstance()
                .createMessageBodyReader(targetTypeClass, type);
            // TODO : make the exceptions
            if (provider != null) {
                try {
                    return provider.readFrom(targetTypeClass, contentType, null, is);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Error deserializing input stream into target class "
                                               + targetTypeClass.getSimpleName()
                                               + ", content type : " + contentType);
View Full Code Here

        MultivaluedMap<String, String> form = new MultivaluedMapImpl();
        try {
            MessageBodyReader reader = context.getProviders().getMessageBodyReader(MultivaluedMap.class, formType, null,
                    contentType);
            if (reader != null) {
                form = (MultivaluedMap<String, String>) reader.readFrom(MultivaluedMap.class, formType, null, contentType,
                        context.getHttpHeaders().getRequestHeaders(), context.getContainerRequest().getEntityStream());
            }
        } catch (IllegalStateException e) {
            if (log.isTraceEnabled()) {
                log.trace(e.getMessage(), e);
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.