[bv-dev] Invoking Configuration#buildValidatorFactory() several times

Sebastian Thomschke sebastian.thomschke at web.de
Mon Mar 19 16:40:18 EDT 2012


Hi,
I have the same opinion. Calling buildValidatorFactory() multiple times 
should be possible. I see no reason why this should be prohibited.

Regards,
Seb

On 19.03.2012 17:21, Matt Benson wrote:
> Hi Gunnar,
>    I agree that nothing is specified, and therefore that my default
> understanding would have been (and in fact was and is) that there is
> no reason a Configuration cannot be reused to build another
> ValidatorFactory.  The fact that Configuration and ConfigurationState
> are separate interfaces seems to imply this as well, albeit subtly.  I
> could believe there might be a use-case for building a number of
> ValidatorFactory instances, each with e.g. one configuration property
> modified from the last.
>
> $0.02,
> Matt
>
> On Sun, Mar 18, 2012 at 5:09 AM, Gunnar Morling
> <gunnar.morling at googlemail.com>  wrote:
>> Hi all,
>>
>> based on a question in the HV user forum [1] I'm wondering whether
>> it's legal to invoke buildValidatorFactory() several times on the same
>> instance of javax.validation.Configuration:
>>
>> Configuration<?>  configuration = Validation.byDefaultProvider().configure();
>>
>> //set up interpolator, traversable resolver etc.
>> configuration. ...();
>>
>> ValidatorFactory vf1 = configuration.buildValidatorFactory();
>>
>> //further customize configuration for another factory
>> configuration. ...();
>>
>> ValidatorFactory vf2 = configuration.buildValidatorFactory();
>>
>> I'm not sure how often one would do something like this in practice,
>> but I think we should make clear whether this is a valid use case or
>> whether a Configuration instance is to be thrown away after invoking
>> buildValidatorFactory().
>>
>> After having a look at the spec and the API documentation I think it's
>> currently unspecified. Any thoughts?
>>
>> Thanks,
>>
>> --Gunnar
>>
>> [1] https://forum.hibernate.org/viewtopic.php?f=9&t=1014788
>> _______________________________________________
>> beanvalidation-dev mailing list
>> beanvalidation-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev



More information about the beanvalidation-dev mailing list