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

From: Sergey Beryozkin <>
Date: Wed, 6 Nov 2013 12:15:19 +0000

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.

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