users@jersey.java.net

Re: One Resource class for two URLs

From: Martin Probst <mail_at_martin-probst.com>
Date: Tue, 22 Apr 2008 08:20:05 +0200

Hi,

> @Path on a method is relative to the @Path of the class so you can't
> do what you want with a single class. Instead you can write:
>
> @Path("books")
> class BooksResource {
> List<Book> getBooks() {...}
> }
>
> @Path("book/{id}")
> class BookResource {
> Book getBook{_at_PathParam("id") String bookId) {...}
> }

The problem is that I want "BookResource" to directly map to a
persistent class, so I can't have it being created by Jersey - it
needs to be loaded by Hibernate. Maybe I can hook into the creation of
the resource (by having my own ComponentProvider) and access the path
parameter to load the instance from persistence?

Regards,
Martin