Hello Hetal,
you'd rather use two different resource classes here, because usually,
in RESTful design, a "collection of X" is a different resource than
"X" itself.
So in your example, you can have the following resources/URI
templates/server resource classes:
A car: /cars/{car}, CarServerResource
A list (collection) of car: /cars, CarsServerResource
then, both CarsServerResource and CarServerResource can have as many
@Get and @Put you want/need, for example:
public class CarsServerResource extends ServerResource {
private List<Car> cars;
@Get("json")
public Representation toJSON() {
}
@Get("xml")
public Representation toXML() {
}
}
and so on.
Hope this helps.
On Thu, Feb 17, 2011 at 6:11 PM, Hetal Gaglani <[email protected]> wrote:
> Can we have multiple @Get and @Put for different URL's pointing to them??
> For eg:
> For URI: /car/nissan, I have a @Get("json") method pointing to return nissan
> car attributes as json
> For URI: /car, I need just a list of car attributes to be returned as json
> But both these URI's are pointing to the CarResource which means I need some
> distinction on the @Get("json") method based on the URL.
>
> In short, do we or can we have the @Path annotation in JAX-RS for Restlet
> resources??
>
> Thanks,
> Hetal Gaglani
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2705165
>
--
Fabián Mandelbaum
IS Engineer
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2705216