users@jersey.java.net

Re: [Jersey] Access to a classes _at_Path

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 05 Mar 2010 15:47:05 -0500

On Mar 5, 2010, at 3:12 PM, Moises Lejter wrote:

> Hmm - I thought that
>
>> URI personResource = uriInfo.getBaseUriBuilder()
>> .path(PersonEndpoint.class, "retrieve")
>
> would end put building the combined path from PersonEndpoint
> and the retrieve method within it...
I can see why you might think the above would extract both the class level @Path and the method level @Path, and maybe that would be a good option, but currently they are separate as shown below.

> Are they separate (and your
> example the right way to go) because PersonEndpoint could be
> a (non-root) subresource?
>
The reason is that a root-resource can also be re-used as a subresource and in that case the URI built would be incorrect.

Marc.

>
> On Mar 5, 2010, at 2:05 PM, Marc Hadley wrote:
>
>> If you want to build an absolute URI the best way is to start from UriInfo like this:
>>
>> @Context UriInfo uriInfo;
>>
>> URI personResource = uriInfo.getBaseUriBuilder()
>> .path(PersonEndpoint.class)
>> .path(PersonEndpoint.class, "retrieve")
>> .build(personAddressMapping.getPersonId());
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>