Annotation Type XopWithMultipartRelated


@Target({PARAMETER,METHOD,FIELD}) @Retention(RUNTIME) public @interface XopWithMultipartRelated
This annotation can be used to process/produce incoming/outgoing XOP messages (packaged as multipart/related) to/from JAXB annotated objects.

XOP packaging can be suitable if you have to work with binary content and you don't want to encode it (for example in base64 or hex inside an xml). XOP makes it possible to pass binary through the network without any encoding on it (binary contents will travel in separate parts of the multipart/related message).

Example. A bean annotated with JAXB. XmlMimeType tells JAXB the mime type of the binary content (its not required to do XOP packaging but it is recommended to be set if you know the exact type):

 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
 public static class Xop {
     private Customer bill;

     private Customer monica;

     @XmlMimeType(MediaType.APPLICATION_OCTET_STREAM)
     private byte[] myBinary;

     @XmlMimeType(MediaType.APPLICATION_OCTET_STREAM)
     private DataHandler myDataHandler;

     // methods, other fields ...
 }
 
A REST Service method parameters/return value annotated with XopWithMultipartRelated and consuming/producing MultipartConstants.MULTIPART_RELATED:
 @PUT
 @Path("xop")
 @Consumes(org.jboss.resteasy.plugins.providers.multipart.MultipartConstants.MULTIPART_RELATED)
 public void putXopWithMultipartRelated(@XopWithMultipartRelated Xop xop) {
 }
 

More about XOP can be read here: http://www.w3.org/TR/xop10

Version:
$Revision: 1 $
Author:
Attila Kiraly