-
1. Re: RF4+Spring+Hibernate validator
jnt30 Jul 12, 2011 11:14 AM (in response to vrelits)I went about this a bit different because I could not come up with the solution you were able to, using the SpringConstraintValidationFactory.
I wrote a custom javax.validation.ConstraintValidatorFactory that also implements org.springframework.context.ApplicationContextAware. In the com.company.validation.CustomConstraintValidationFactory.setApplicationContext(ApplicationContext) method I simply save off the application context. When a call is made to com.company.validation.CustomConstraintValidationFactory.getInstance(Class<T>) looking for a constraint validator, I first check to see if Spring is managing an instance of a bean that fits the class signature. If it does, I return the Spring bean that is autowired up. If it does not, I delegate to teh regular Validation.byDefaultProvider()'s implmenetation for looking up the validator.
You can customize this setting through the validation.xml that is located in the META-INF directory. More information can be found at: http://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html_single/#d0e1867