users@jersey.java.net

Post binary, xml, json

From: saturon <netbeans_at_vtxfree.ch>
Date: Fri, 26 Jun 2009 14:08:08 +0200

Hi

I have several POST Resources that must support a custom binary mime
type as well as xml and json.
So I have:
@POST
    @Consumes({"mobileapp/octet-stream"})
    public Response post(byte[] data) {

Now what I did was just declaring 2 methods for the different types and
factor out the common code base. Is there maybe a better way to do this?

    @POST
    @Consumes({"mobileapp/octet-stream"})
    public Response post(byte[] data) {
//transform to common type, then process
..

    @POST
    @Consumes({"application/xml", "application/json"})
    public Response post(MyConverter data) {
//transform to common type, then process
.

Rgds Ben