Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public static class MyBeanMessageBodyReader implements MessageBodyReader<MyBean> {
public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return type == Person.class;
public MyBean readFrom(Class<MyBean> type,
Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream)
throws IOException, WebApplicationException {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(MyBean.class);
return (Person) jaxbContext.createUnmarshaller()
return myBean;
} catch (JAXBException jaxbException) {
throw new ProcessingException("Error deserializing a Person.",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.