users@jersey.java.net

Re: [Jersey] Issue with Routes and Collections using JAXB

From: Jason Winnebeck <gillius-ml_at_gillius.org>
Date: Fri, 09 Jul 2010 11:46:33 -0400

I am sort of new to Jersey, but from what I saw in the Bookstore example:

If you rename your CustomerResource to CustomersResource (representing
multiple customers) and its getCustomer(int cid) returns a new class
CustomerResource (representing a SINGLE customer) with a @path("incidents")
and a @path("incident/{incidentId}") then that is one possibly technique.

I think it would also work to have a method in your original CustomerResource
with @path("customer/{cid}/incident/{incidentId}"). It's up to your design --
are you putting too much in one class if you did that?

So you can have just one class CustomerResource with everything, or you can
have as any levels as you want. If you went all the way you would have:

Customers -> Customer -> Incidents -> Incident (each having @Path-annotated
methods returning the lower level).

Jason

On 7/9/2010 11:37 AM, Basmajian, Raffi wrote:
> We created a CustomerResource class that handles the following routes:
> @produces("application/xml)
> @path("/")
> class CustomerResource
> @Path("customers/")
> getCustomers()
> @Path("customer/{cid}")
> getCustomer(int cid)
> We also want to implement a route to support getting a specific incident
> for a customer, for example *"/customer/100/incident/5"*, and we are not
> sure how to do this. We are not sure if we have to create another
> resource class for Incident, or, if we should create another method in
> customerResource, such as getCustomerIncident(cid, iid), to handle it.