com.github.ldeitos.validation.impl.interpolator.BaseInterpolator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of extendedValidation Show documentation
Show all versions of extendedValidation Show documentation
Extension for BeanValidation API to provide CDI compatible ConstraintValidatorFactory, easy way to set parameters on message constraint and easy API to add non properties file message sources, like DB, external modules, mainframe routines, etc.
This version is Java 17 and JakartaEE 10 compatible.
package com.github.ldeitos.validation.impl.interpolator;
import com.github.ldeitos.util.ManualContext;
import com.github.ldeitos.validation.MessagesSource;
import com.github.ldeitos.validation.impl.configuration.ConfigInfoProvider;
import com.github.ldeitos.validation.impl.configuration.Configuration;
class BaseInterpolator {
/**
* Messages source.
*/
private MessagesSource messageSource;
public MessagesSource getMessageSource() {
ConfigInfoProvider configProvider = ManualContext.lookupCDI(ConfigInfoProvider.class);
Configuration configuration = Configuration.getConfiguration(configProvider);
if (messageSource == null) {
messageSource = configuration.getConfiguredMessagesSource();
}
return messageSource;
}
}