users@jersey.java.net

RE: Injection of message body readers/writers now supported in latest builds

From: Ross Judson <rossj_at_soletta.com>
Date: Fri, 25 Jan 2008 13:34:13 -0500

I've got my simple form-based example working now, where my POST method
receives the multipart MIME message. Looking over the problem, I think what
would be _really_ cool would be another Param annotation, FieldParam.

What I expected initially was that I could do something like this:

@POST
@Path("upload")
@FormData
public void uploadGraphML(
   @FieldParam(name="graphml",type="application/xml") GraphML graphML,
   @FieldParam(name="owner") String ownerName
) {
}


Sure, I'd like Jersey to just do everything for me ;) Marking @FormData
tells Jersey that that form data from a post is inbound, so it knows to
break those into named fields. The @FieldParam tells Jersey the name and
mime type of the field within the multipart MIME data. It can then perform
its normal data conversion steps to get from there to the type of the field
(in this case I have a JAXB context defined for GraphML). For each parameter
the process is repeated, locating the appropriate field on the inbound
message and converting it.

I've got what I need working, but there's a certain elegance (not to mention
great ease of use) to the scheme outlined above...

RJ