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

[jsr339-experts] Re: UriBuilder.fromMethod

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Thu, 5 Sep 2013 11:31:07 +0200

Hi Jan,

On Aug 8, 2013, at 10:09 PM, Jan Algermissen <jan.algermissen_at_nordsc.com> wrote:

> Bill,
> thanks for clarifying.
>
> On 08.08.2013, at 14:37, Bill Burke <bburke_at_redhat.com> wrote:
>
>> This is correct behavior. the TCK tests this. Supposedly there are cases where you just want the @Path annotation from the method and not the path and the method.
>
> Ah - and what would they be? Any idea?

Lets first clarify the purpose of UriBuilder: UriBuilder is not a fancy high-level utility that would introspect resources or inspect resource graphs or change behavior based on the context in which it is used. As such, UriBuilder is pretty much just doing what it says - it builds URIs based on the provided information. Knowing about the path annotation, it provides convenience methods to retrieve the information from the path annotation applied to a particular annotated element passed as an input to the URI builder, but nothing else.

As for the use cases for current behavior, some root resources can be accessed also as sub resources. Some resources can implement a common resource interface and expose it via different root paths. In these scenarios, automatically applying the class-level Path value would not be desirable.

FWIW, I am not against coming up with a new convenience method that would cover your use case as such - IIRC, EG was however against introducing another method in the already large UriBuilder API. I am also not against coming up with a method that would not fail with an exception in case there is no Path annotation on the input annotated element, as Bill would want - I'm just saying that we cannot change the behavior of the API method that is already there.

Marek

>
> Jan
>
>
>
>
>
>
>>
>> What also sucks is, if your method doesn't have a @Path annotation, this method throws an exception :( I've pinged expert group about this, but they can't seem to grok why this behavior is bad.
>>
>> On 8/8/2013 8:25 AM, Jan Algermissen wrote:
>>> Hi,
>>>
>>> before I consider it a bug, a clarification question:
>>>
>>> If I have a resource annotated with @Path("a/b") that contains a method annotated with @Path("c") then UriBuilder.fromMethod(..) should resolve to "a/b/c" , houldn't it?
>>>
>>> For me, with Jersey of latest GF4 it resolves to "c" - which seems unexpected. The docs are not explicit on this, hence the question.
>>>
>>> Jan
>>>
>>
>> --
>> Bill Burke
>> JBoss, a division of Red Hat
>> http://bill.burkecentral.com
>