users@jax-rs-spec.java.net

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

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Wed, 6 Nov 2013 12:19:03 +0000

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'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