Package javax.ws.rs.ext

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


                    genericType, annotations, mediaType);
            if (reader == null)
               throw new BadRequestException(
                       "Could not find message body reader for type: "
                               + genericType + " of content type: " + mediaType);
            return reader.readFrom(type, genericType, annotations, mediaType,
                    request.getHttpHeaders().getRequestHeaders(), request
                            .getInputStream());
         }
         else if (isCookie)
         {
View Full Code Here


   
    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Test
    public void testReadFrom() throws Exception {
        MessageBodyReader p = new BinaryDataProvider();
        byte[] bytes = (byte[])p.readFrom(byte[].class, byte[].class, new Annotation[]{},
                                          MediaType.APPLICATION_OCTET_STREAM_TYPE,
                                          new MetadataMap<String, Object>(),
                                          new ByteArrayInputStream("hi".getBytes()));
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
       
View Full Code Here

                                          MediaType.APPLICATION_OCTET_STREAM_TYPE,
                                          new MetadataMap<String, Object>(),
                                          new ByteArrayInputStream("hi".getBytes()));
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
       
        InputStream is = (InputStream)p.readFrom(InputStream.class, InputStream.class, new Annotation[]{},
                                                 MediaType.APPLICATION_OCTET_STREAM_TYPE,
                                                 new MetadataMap<String, Object>(),
            new ByteArrayInputStream("hi".getBytes()));
        bytes = IOUtils.readBytesFromStream(is);
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
View Full Code Here

                                                 new MetadataMap<String, Object>(),
            new ByteArrayInputStream("hi".getBytes()));
        bytes = IOUtils.readBytesFromStream(is);
        assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
       
        Reader r = (Reader)p.readFrom(Reader.class, Reader.class, new Annotation[]{},
                                      MediaType.APPLICATION_OCTET_STREAM_TYPE,
                                      new MetadataMap<String, Object>(),
                                      new ByteArrayInputStream("hi".getBytes()));
        assertEquals(IOUtils.toString(r), "hi");
    }
View Full Code Here

            ProviderFactory.getInstance().createMessageBodyReader(
                cls, type, anns, contentType, outMessage);
        }
        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(ex);
            }
            
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

       
        MessageBodyReader mbr = ProviderFactory.getInstance(inMessage).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) {
                reportMessageHandlerProblem("MSG_READER_PROBLEM", cls, contentType, ex, r);
            }
        } else if (cls == Response.class) {
View Full Code Here

                                                   getAnnotations(),
                                                   mediaType);

                if (mbr != null) {
                    Object read =
                        mbr.readFrom(paramType,
                                     getGenericType(),
                                     getAnnotations(),
                                     mediaType,
                                     runtimeContext.getHttpHeaders().getRequestHeaders(),
                                     runtimeContext.getInputStream());
View Full Code Here

                                                   getAnnotations(),
                                                   mediaType);

                if (mbr != null) {
                    Object read =
                        mbr.readFrom(paramType,
                                     getGenericType(),
                                     getAnnotations(),
                                     mediaType,
                                     runtimeContext.getHttpHeaders().getRequestHeaders(),
                                     runtimeContext.getInputStream());
View Full Code Here

               {
                  try
                  {
                     MultivaluedMap<String, String> headers = context.getContainerRequest().getRequestHeaders();
                     p[i++] =
                        entityReader.readFrom(mp.getParameterClass(), mp.getGenericType(), mp.getAnnotations(),
                           contentType, headers, entityStream);
                  }
                  catch (Exception e)
                  {
                     if (LOG.isDebugEnabled())
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.