Hi
On Mon, Apr 11, 2011 at 9:27 PM, Simon Chen <[email protected]> wrote:
> Hi all,
>
> I'm wondering if there is a way for an object in the web service to
> somehow self-report where it is, in term of uri path?
>
> For example, we have:
>
> @path("/webstore/")
> class WebStore {
> @path("/customers/")
> List<Customer> customers;
> }
>
> Given a link "cl" to a Customer object, can we somehow figure out that
> it is under "/webstore/customers"? I understand that we can probably
> easily hard-code this, but I want to do it more automatically...
>
> Have JAX-RS UriInfo injected:
@path("/webstore/")
class WebStore {
@Context
private UriInfo uriInfo;
}
then you can do:
uriInfo.getBaseUri()
or
UriBuilder builder = uriInfo.getBaseUriBuilder();
Cheers, Sergey
Thanks.
> -SImon
>
--
Sergey Beryozkin
Application Integration Division of Talend <http://www.talend.com>
http://sberyozkin.blogspot.com