[
http://opensource.atlassian.com/projects/hibernate/browse/BVAL-224?page=c...
]
Gunnar Morling commented on BVAL-224:
-------------------------------------
In Seam Validation there is a custom {{ConstraintValidatorFactory}},
[
InjectingConstraintValidatorFactory|https://github.com/seam/validation/bl...].
This factory creates itself constraint validators which are CDI beans but delegates to the
default factory for validators which are no CDI beans.
As the factory is set via XML there is no good way to get hold of the default factory to
delegate to. Currently it's done like this:
{code}
public InjectingConstraintValidatorFactory() {
delegate =
Validation.byDefaultProvider().configure().getDefaultConstraintValidatorFactory();
}
{code}
This works but seems not perfect to me, in particular if the BV provider setting up this
factory is not the default provider. Another example would be a custom message
interpolator which wishes to delegate to the default interpolator.
Provide a way for accessing default implementations for XML
configured bootstrap artifacts
------------------------------------------------------------------------------------------
Key: BVAL-224
URL:
http://opensource.atlassian.com/projects/hibernate/browse/BVAL-224
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Reporter: Gunnar Morling
Using {{validation.xml}} one can specify custom implementations for constraint validator
factory, message interpolator etc. Right now there is no way to delegate from within these
custom implementations to the default ones. This would be possible when using the
configuration API:
{code}
HibernateValidatorConfiguration configuration =
Validation.byProvider(HibernateValidator.class).configure();
ConstraintValidatorFactory defaultFactory =
configuration.getDefaultConstraintValidatorFactory();
ConstraintValidatorFactory customFactory = new
CustomConstraintValidatorFactory(defaultFactory);
configuration.constraintValidatorFactory(customFactory);
{code}
One idea to allow for such a delegation is to support constructors taking the default
implementation as parameter:
{code}
CustomConstraintValidatorFactory implements ConstraintValidatorFactory {
ConstraintValidatorFactory delegate;
CustomConstraintValidatorFactory(ConstraintValidatorFactory defaultFactory) {
this.delegate = defaultFactory;
}
}
{code}
For XML-configured artifacts the runtime could invoke this delegate constructor if
existent, otherwise the default constructor could be invoked.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira