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

[jsr339-experts] Re: [jax-rs-spec users] Re: Resource Class Validation

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Wed, 6 Nov 2013 09:10:09 -0500

On Nov 6, 2013, at 7:19 AM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:

> On 06/11/13 12:15, Sergey Beryozkin wrote:
>> Hi Santiago, All
>>
>> I'd like to ask few more questions about Chapter 7.
>>
>> First, how to validate resource classes themselves.
>>
>> 7.6 says:
>>
>> "Constraint annotations are allowed in the same locations as the
>> following annotations: @MatrixParam, ..., *except in class construc-
>> tors and property setters*.
>>
>> ...
>>
>> The same caveats related to the use of other JAX-RS annotations in
>> resource classes apply to
>> constraint annotations. For example, *a constraint validation annotating
>> a constructor parameter* in a resource
>> class whose lifecycle is singleton will only be executed once.
>> "
> Actually, I also meant to ask if it was possible after all to have a constructor parameter annotated, the 1st highlight suggests it is not, the last one - yes.

 I recall we went back and forth on the constructors, and this "for example" was obviously not updated. Please file a JIRA on the chapter for all this (e.g., validation of wrapped entities). Thanks.

-- Santiago

>>
>> I'm assuming that what it says that we do not validate the resource
>> class during the initialization (via the constructor or when injecting
>> the properties via setters) and we move to Phase 2:
>>
>> "Phase 2 Validate annotations on resource classes, fields and property
>> getters (if enabled)."
>>
>> The question here is what happens when a singleton root resource fails
>> the validation ? I recall we had a callback handler in API but it has
>> gone, so am I right to assume that the runtime would need to synchronize
>> during the request processing and ensure that a singleton resource is
>> validated only once ?
>>
>> Thanks, Sergey
>>
>>
>>
>>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com