// MultipartBody will use the Content-Type value of the individual
// part to read its data in a type safe way by delegating to a matching
// JAX-RS MessageBodyReader provider
Book jaxbBook = body.getAttachmentObject("book1", Book.class);
Book jsonBook = body.getAttachmentObject("book2", Book.class);
// Accessing individual attachment part, its DataHandler will be
// used to access the underlying input stream, the type-safe access
// is also possible
Attachment imageAtt = body.getAttachment("image");
if ("JAXB".equals(jaxbBook.getName()) && 1L == jaxbBook.getId()
&& "JSON".equals(jsonBook.getName()) && 2L == jsonBook.getId()
&& imageAtt != null) {
return createMultipartBody(jaxbBook, jsonBook, imageAtt.getDataHandler());
}
throw new RuntimeException("Received Book attachment is corrupted");
}