Skip to main content

[jsr339-experts] Re: Desired behavior of UriBuilder.fromResource

  • From: Jan Algermissen <jan.algermissen@...>
  • To: jsr339-experts@...
  • Subject: [jsr339-experts] Re: Desired behavior of UriBuilder.fromResource
  • Date: Thu, 8 Nov 2012 20:08:14 +0100


On Nov 8, 2012, at 7:48 PM, "Markus KARG" <markus@...> wrote:

>> Suppose I have:
>
>> @Path("customer/{id}")
>> public class CustomerResource {
>
>
>> When I use UriBuilder.fromResource(CustomerResource.class)
>
>> The builder creates a URI, %-encoding the { and } in the path.
>
>> This sort feels both, wrong and correct :-)
>
>> Question: what is the desired behavior?
> 
> The above code is not creating an URI, it is creating an URIBuilder.
> 
> To create an URI you must invoke build("MyID") on this URIBuilder, which
> creates an URI that looks like "customer/MyID".

Thanks - missed the toTemplate() method.

WebTarget customerTarget = 
baseTarget.path(UriBuilder.fromResource(CustomerResource.class).build().toASCIIString());

should have been

WebTarget customerTarget = 
baseTarget.path(UriBuilder.fromResource(CustomerResource.class).toTemplate());

but the fluent API was just carrying me along without thinking :-)


Kinda tricky .... the combinations between these APIs :-)

Jan 








> 
> If that is not produced by your software, then it is definitively wrong and
> you should file a ticket.
> 
> Regards
> Markus
> 



[jsr339-experts] Desired behavior of UriBuilder.fromResource

Jan Algermissen 11/08/2012

[jsr339-experts] Re: Desired behavior of UriBuilder.fromResource

Markus KARG 11/08/2012

[jsr339-experts] Re: Desired behavior of UriBuilder.fromResource

Jan Algermissen 11/08/2012
 
 
Close
loading
Please Confirm
Close