users@jersey.java.net

How do I get a given path to call the right method

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Thu, 26 Jun 2008 11:30:24 -0700 (PDT)

Hello all,

So I thought this would work automatically, but I am finding out that by calling my path with extra path info, it gives me an error telling me there is no file found.

So I want basically

DELETE /myresource/resource-name

If I call just /myresource it works fine. But DELETE wont allow any body info to be passed in (makes sense). Basically my "object" has an ID associated with it. I want to say DELETE /myresource/object-id but am not sure how to code this in the class.

I have

    @DELETE
    @ConsumeMime("application/xml")
    public void deleteXml(String content) {
        System.out.println("INSIDE DELETE XML IN RESOURCE");
    }

So first off, I am guessing @ConsumeMime is of no good since DELETE wont accept any body anyway. So do I need to specify a specific path such as @Path("/myresource/{id}") something like that? I can't find anything describing how to make this work.

Furthermore, we are going to have a situation very soon where we have a something like /myresource/res-id/instances/instance-id, and we'll want to drill down to the instance-id and send in calls. I have yet to find how to do this with Jersey. Do I specify a second class, say InstancesResource, and put an @Path("/myresources/{res-id}/instances") or is there some way that the /myresource class handles/parses the remaining path info and calls appropriate methods?

Thanks.