Dependency between constraints and validators
by Gunnar Morling
one thing about BV I'm somewhat uncomfortable with is the (cyclic)
dependency between constraint annotation types and their validators.
This is, validators are referenced from constraints within the
@Constraint meta-annotation, while constraint types are referenced by
the type parameter in validator impl's.
In particular this makes it impossible to clearly distinguish between
the public API of a constraint library (the annotation types) and its
implementation (the validators), e.g. by creating two distinct JARs.
Therefore I'd personally prefer if there was only a reference from the
validators to the constraints, but not the other way around. This of
course raises the question how it would be determined which validators
exist for a given constraint. One could think of using XML descriptors
or some scanning-based approach. I guess from a technical POV this
problem is somewhat related to what's to be done in CDI (finding bean
implementations, processing qualifier annotations etc.).
That said, I'd be very interested in your opinion on this topic. Do
you think this is something we should address or do you think this
sort of cycle is acceptable?
11 years, 5 months