[bv-dev] BVAL-238 Dependency injection in ConstraintViolation
Emmanuel Bernard
emmanuel at hibernate.org
Tue Oct 25 09:34:20 EDT 2011
On 24 oct. 2011, at 22:26, Gunnar Morling wrote:
>>
>> Note that CDI strategy is to let other specs describe their integration, we are responsible for describing how that will work.
>
> I see. Validator and ValidatorFactory are built-in beans in CDI 1.0
> already, so I think one could extend on that and require that the
> runtime must use a CDI-enabled ConstraintValidatorFactory. Maybe this
> is something which we could contribute to CDI 1.1.
yep
>
> It would be interesting to know how CDI integration is solved for JPA
> entity listeners. Do you have any information on that?
Here is a summary though the point is still if flux at the moment:
1. EntityListeners are annotated with @BeanListener (we are trying to get rid of this requirement though
2. JPA providers use the CDI implementation to inject data as described in http://seamframework.org/Documentation/HowDoIDoNoncontextualInjectionForAThirdpartyFramework
3. CDI's BeanManager is injected by the container during the EMF creation at a pre defined key javax.persistence.validation.factory (there is a free form Map upon EMF creation)
This model (esp the last point) is how BV integrates in JPA btw and it has served JPA well.
About point 2., Bean Validation lacks a close() hook to properly call the `dispose()` operations. We will need to add it.
More information about the beanvalidation-dev
mailing list