users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Default Servlet Mapping?

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 22 Mar 2012 16:11:42 +0000

On 22/03/12 14:41, Bill Burke wrote:
>
>
> On 3/21/12 6:18 PM, Sergey Beryozkin wrote:
>> Hi Bill,
>>
>> On 21/03/12 19:08, Bill Burke wrote:
>>>
>>>
>>> On 3/21/12 3:01 PM, Marek Potociar wrote:
>>>>
>>>> On Mar 19, 2012, at 3:01 PM, Bill Burke wrote:
>>>>
>>>>>
>>>>>
>>>>> On 3/15/12 4:15 PM, Santiago Pericas-Geertsen wrote:
>>>>>>
>>>>>> On Mar 15, 2012, at 4:00 PM, Bill Burke wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 3/15/12 3:54 PM, Santiago Pericas-Geertsen wrote:
>>>>>>>>
>>>>>>>> On Mar 15, 2012, at 3:31 PM, Bill Burke wrote:
>>>>>>>>
>>>>>>>>> I would say do nothing because it would break existing 1.1
>>>>>>>>> applications when deployed.
>>>>>>>>
>>>>>>>> How so? Before you had to always specify the mapping, and that
>>>>>>>> will continue to take precedence. Can you elaborate?
>>>>>>>>
>>>>>>> We assumed everything could be scanned, you could have an empty
>>>>>>> web.xml file, and no Application class. This was an incorrect
>>>>>>> assumption? I know a lot of people use us in this manner. Maybe I
>>>>>>> just interpreted the 1.1 spec wrong?
>>>>>>
>>>>>> Class scanning and servlet mapping are orthogonal. The only way you
>>>>>> can get the servlet mapping in 1.1 is from (i) a web.xml or (ii) the
>>>>>> @ApplicationPath annotation on an Application subclass AFAICT, with
>>>>>> (i) overriding (ii) if both are present. For the other cases, 1.1
>>>>>> states that "the application MUST be packaged with a web.xml that
>>>>>> specifies a servlet mapping for the added servlet".
>>>>>>
>>>>>> Perhaps you're already using a default in Resteasy?
>>>>>>
>>>>>
>>>>> Well, then the spec should allow the case for *no* Application class
>>>>> and no web.xml listing. The default mapping should be "/*" and should
>>>>> work with static content too. This way its very simple for users and
>>>>> no thought has to be put into anything.
>>>>>
>>>>
>>>> I think so far we can all agree, that a default mapping is good. I
>>>> want to however point out that suggested "/*" as a default mapping is
>>>> too aggressive in connection with any other technology that uses some
>>>> default mapping as well (e.g. JSF). For that reason, I suggest to
>>>> choose a named default mapping directly under the root path e.g. the
>>>> "/webapi/*" as proposed earlier.
>>>>
>>>
>>> Please tell me why "/*" is too aggressive? its easily handled if your
>>> implementation is Filter based.
>>>
>>> But, this is orthogonal to the issue of requiring a web.xml or
>>> Application class. I do not think either of these artifacts should be
>>> required to deploy a JAX-RS service.
>>
>> Without Application, what would be the most portable way to deploy a
>> simple JAX-RS service across multiple JAX-RS stacks ? Sorry may be this
>> question is also orthogonal :-),
>>
>
> Not sure I understand you. just put a resource class in /WEB-INF/classes
> and have the scanner discover it. Seems pretty straightforward to me.
> YOu want a full Java EE container to have value-add. One of the value
> adds is scanning.
>
OK...That works. IMHO, relying on the scanning is not something any of
the interesting applications would do, however it does in some simple
cases. Application is a richer construct because it can get the JAX-RS
contexts injected or indeed itself injected as a context, but I
understand what you say too



Cheers, Sergey