jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Re: UriTemplate API?

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Thu, 21 Feb 2013 18:37:55 +0100

On Feb 21, 2013, at 3:08 PM, Bill Burke <bburke_at_redhat.com> wrote:

>
>
> On 2/20/2013 12:08 PM, Marek Potociar wrote:
>> Hello experts,
>>
>> Please review the issue that has been recently filed:
>> http://java.net/jira/browse/JAX_RS_SPEC-359
>>
>> In summary the user wants to be able take a URI template, e.g.
>> "http://example.com/name/{name}/age/{age}" and then take a URI, e.g.
>> "http://example.com/name/Arnold/age/65" (guess who...) and extract the
>> parameter values information into a Map<String, String> instance.
>>
>> The solution may look like:
>>
>> UriBuilder builder
>> = UriBuilder.fromUri("http://example.com/name/{name}/age/{age}");
>> UriTemplate template = builder.template();
>> Map<String, String> params = new HashMap<String, String>();
>> if (template.match("http://example.com/name/Arnold/age/65", params)) {
>> params.put("name", "Alois");
>> URI uri = builder.buildFromMap(params);
>> ...
>> }
>>
>> The above requires following API changes:
>>
>> * introduce UriTemplate to represent, well, URI templates...
>> * add ability to get UriTemplate instances from UriBuilder and WebTarget
>> * expose the boolean UriTemplate.match(URI, Map<String,
>> String>) method as part of the UriTemplate API.
>>
>> Now, finally, my question is:
>>
>> Q1. Do you think the above API would be useful?
>> Q2. Is it something we should still try to add into JAX-RS 2.0, given
>> where we are?
>>
>
> I'd say extend UriBuilder with a match() method instead of adding yet another class we have to include within RuntimeDelegate. Something like:
>
> Map<String, String> match(String URI);
>
> match() returns null if it can't match the current expression with the passed in URI.

Ok, your other email seems to make sense. Even though I think the user has a point (see issue comments) that the map should not be created by us, but user should be able to pass it as an input parameter. (Or maybe we can have 2 versions of the method.)

>
> Useful. Yes. Include in JAX-RS 2.0? Well... I don't get it...you've deferred some pretty trivial improvements that I've submitted and in some cases important JIRAs like:
>
> JAX_RS_SPEC-339
> JAX_RS_SPEC-317
>
> But you want to include a brand new feature? Plus complain everytime I make a suggestion that we're too close to the PFD? A bit hypocritical don't you think?

Maybe I should have just ignored this rant, but then again, it's rude to not reply to direct questions. :)

Note that in my email I'm merely asking what you (EG) think. I'm not pushing for anything, or suggesting we should (or must) do anything. For that matter, I have not expressed any opinion about whether or not we should include the feature in 2.0. So to answer your last question, no, I do not think I'm being hypocritical here.

Funny thing is that knowing you're somewhat frustrated after our recent conversations I tried to be extra careful to not sound like I would be pushing for anything and formulate the email as a pure summary of the issue at hand plus a couple of questions I'd like to get EG feedback on. Alas, apparently to no avail.

Marek
>
>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com