JAXBObjectEntityProvider implements EntityProvider<Object> { @Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { try { JAXBContext jaxbContext = getJAXBContext(type, mediaType); return jaxbContext.createUnmarshaller().unmarshal(entityStream); } catch (UnmarshalException e) { LOG.debug(e.getMessage(), e); return null; } catch (JAXBException e) { throw new IOException(String.format("Can't read from input stream, %s", e)); } } JAXBObjectEntityProvider(@Context Providers providers); @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override Object readFrom(Class<Object> type,
                           Type genericType,
                           Annotation[] annotations,
                           MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders,
                           InputStream entityStream); @Override long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(Object t,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }
@Test public void readsObjectFromEntityStream() throws Exception { Book book = (Book)reader.readFrom(Book.class, null, null, APPLICATION_XML_TYPE, new MultivaluedMapImpl(), new ByteArrayInputStream(TEST_XML_CONTENT_BYTES)); assertEquals("Java and XML Data Binding", book.getTitle()); assertTrue(book.isSendByPost()); assertEquals("Brett McLaughlin", book.getAuthor()); assertEquals("USD", book.getPrice().getCurrency()); assertEquals(new BigDecimal("34.95"), book.getPrice().getValue()); assertEquals("USD", book.getMemberPrice().getCurrency()); assertEquals(new BigDecimal("26.56"), book.getMemberPrice().getValue()); }