Yes, injecting dependency via constructor args into validator instances is not supported. Validator classes need to have a default constructor and are instantiated by the validation framework, not the DI framework.
Spring does not raise an exception since it is not responsible to instantiate the object but only to wire the field dependencies.

Regards,
Seb

On 22.10.2011 10:39, Emmanuel Bernard wrote:
Indeed that's a typo for ConstraintViolationFactory. 

In your approach, the object cannot use constructor injection, correct?
What does Spring Framework do in this case, raise an exception?

On 22 oct. 2011, at 01:33, Sebastian Thomschke <sebastian.thomschke@web.de> wrote:

Hi Emmanuel,

the proposal talks about a ConstraintViolationFactory. I guess you meant ConstraintValidatorFactory?

In OVal dependency injection works like this: OVal instantiates the validator (check) object itself and then passes it to an optional CheckInitializationListener which can wire required dependencies. So the DI system does not create the validator instances but configures the dependencies.

For Spring DI in OVal you do:
  ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("SpringInjectorTest.xml", SpringInjectorTest.class);
  AnnotationsConfigurer myConfigurer = new AnnotationsConfigurer();
  myConfigurer.addCheckInitializationListener(new BeanInjectingCheckInitializationListener());
  Validator v = new Validator(myConfigurer);

Where the BeanInjectingCheckInitializationListener is implemented like:

  public class BeanInjectingCheckInitializationListener implements CheckInitializationListener {
    public void onCheckInitialized(final Check newCheck) {
        // wire the dependencies
        SpringInjector.get().inject(newCheck);
      }
  }

For Bean Validation this could look like:
ValidatorFactory factory = Validation
  .byDefaultProvider()
  .configure()
  .addValidatiorInitializationListener(new SpringBeanInjectingValidatorInitializationListener()) 
  .buildValidatorFactory();

Regards,

Seb

On 21.10.2011 23:55, Emmanuel Bernard wrote:
Hi team,
I've been thinking about BVAL-238 and came up with a first round of ideas and open questions.
It is available here http://beanvalidation.org/proposals/BVAL-238/

Please give me your feedback. I think this issue can be closed quite quickly.

I've also created a proposals section on the website that will contain such work in progress proposals before inclusion in the spec proper. Check out http://beanvalidation.org/proposals

On a side note, for casual website editing, you can use GitHub's `Edit this file` button (see https://github.com/beanvalidation/beanvalidation.org/blob/master/proposals/BVAL-238.md ). It's not quite a wiki but that's pretty close. One thing you cannot do is create a new file unfortunately. Anyone that have asked for write access should see this button.

Emmanuel
_______________________________________________
beanvalidation-dev mailing list
beanvalidation-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev

_______________________________________________
beanvalidation-dev mailing list
beanvalidation-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev


_______________________________________________
beanvalidation-dev mailing list
beanvalidation-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev