[bv-dev] Method interception configuration and interception technology

Emmanuel Bernard emmanuel at hibernate.org
Wed Jan 23 11:30:20 EST 2013


Hi Pete,
(I've added you as accepted sender to the mailing list so you can reply
to beanvalidation-dev wo being rejected).

We have a problem and we need your wisdom.

## Context

- Bean Validation offers method / constructor validation.
- the feature is defined at a generic level to be implemented on all
  interception technologies
- we have a CDI specific section to make it clear how things work /
  integrate with CDI
- we need to be able to enable / disable validation for constructors,
  non-getter and getter method both per element and via a global default setting

## The problem

BV integrates with CDI via portable extensions (or some proprietary
means similar to this) that bind an interceptor to the constructors and
methods that require validation.

We offer @ValidateExecutable to customize whether or not a method /
constructor is validated. And we also would like to offer a global
setting.

We tried to make the validation configuration a core part of Bean
Validation so that the logic would be similar across all interception
technologies but we have hit a snag.

We wanted to make the global setting part of both:

- META-INF/validation.xml
- the BV bootstrap API (programmatic approach)

But it turns out that the portable extension is enabled at a different
tie than a ValidatorFactory. So using the programmatic API to change the
setting would not be reflected. Likewise, the portable extension would
need to read the validation.xml to find the setting.

that made some members of this group to push for having the method
interception setting in a CDI configuration rather than Bean Validation
one. Most likely beans.xml.

Is it a natural fit for CDI to augment beans.xml it with Portable Extension
specific options and what is the way of doing it?
We can try and keep things in validation.xml but that would be a
placeholder that would need to be read one way or another by the
interception technology.

What are your thoughts Pete?

Emmanuel


More information about the beanvalidation-dev mailing list