users@jersey.java.net

Re: [Jersey] Root resource class question

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 23 Feb 2010 10:31:34 -0500

On Feb 23, 2010, at 9:35 AM, Dário Abdulrehman wrote:

> Is it possible to define a single root resource class that matches both:
>
> GET /proteins?protein=proteinid1&protein=proteinid2&...
> GET/protein/proteinid
>
> @Path(?)
> public Class ...
>
> and define two @GET methods for each case?
>
> Conceptually they are the same resource but one works with lists and the other with single objects.
>
Its possible like this:

@Path("/")
pubic class ProteinResource {

  @GET @Path("proteins")
  public getList(...) {...}

  @GET @Path("protein")
  public getSingle(...) {...}
}

But I think Jan's suggestion is much better.

Marc.