Search in sources :

Example 1 with BootstrapConfiguration

use of jakarta.validation.BootstrapConfiguration in project resteasy by resteasy.

the class AbstractValidatorContextResolver method getContext.

public GeneralValidatorCDI getContext(Class<?> type) {
    try {
        BootstrapConfiguration bootstrapConfiguration = getConfig();
        boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
        Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration.getDefaultValidatedExecutableTypes();
        return new GeneralValidatorImpl(getValidatorFactory(), isExecutableValidationEnabled, defaultValidatedExecutableTypes);
    } catch (Exception e) {
        throw new ValidationException(Messages.MESSAGES.unableToLoadValidationSupport(), e);
    }
}
Also used : ExecutableType(jakarta.validation.executable.ExecutableType) ValidationException(jakarta.validation.ValidationException) BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) NamingException(javax.naming.NamingException) ValidationException(jakarta.validation.ValidationException)

Example 2 with BootstrapConfiguration

use of jakarta.validation.BootstrapConfiguration in project resteasy by resteasy.

the class AbstractValidatorContextResolver method getConfig.

BootstrapConfiguration getConfig() {
    BootstrapConfiguration tmpConfig = bootstrapConfiguration;
    if (tmpConfig == null) {
        synchronized (RD_LOCK) {
            tmpConfig = bootstrapConfiguration;
            if (tmpConfig == null) {
                config = Validation.byDefaultProvider().configure();
                bootstrapConfiguration = tmpConfig = config.getBootstrapConfiguration();
            }
        }
    }
    return tmpConfig;
}
Also used : BootstrapConfiguration(jakarta.validation.BootstrapConfiguration)

Example 3 with BootstrapConfiguration

use of jakarta.validation.BootstrapConfiguration in project hibernate-validator by hibernate.

the class XmlMappingTest method testScriptEvaluatorFactoryConfiguration.

@Test
@TestForIssue(jiraKey = "HV-1463")
public void testScriptEvaluatorFactoryConfiguration() {
    validationXmlTestHelper.runWithCustomValidationXml("script-evaluator-factory-validation.xml", () -> {
        // given
        BootstrapConfiguration bootstrapConfiguration = ValidatorUtil.getConfiguration().getBootstrapConfiguration();
        // then
        assertEquals(bootstrapConfiguration.getProperties().get(HibernateValidatorConfiguration.SCRIPT_EVALUATOR_FACTORY_CLASSNAME), CustomScriptEvaluatorFactory.class.getName());
    });
}
Also used : BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 4 with BootstrapConfiguration

use of jakarta.validation.BootstrapConfiguration in project hibernate-validator by hibernate.

the class XmlMappingTest method shouldReturnDefaultExecutableTypesIfNoValidationXmlIsGiven.

@Test
@TestForIssue(jiraKey = "HV-707")
public void shouldReturnDefaultExecutableTypesIfNoValidationXmlIsGiven() {
    // given
    BootstrapConfiguration bootstrapConfiguration = ValidatorUtil.getConfiguration().getBootstrapConfiguration();
    // when
    // then
    assertEquals(bootstrapConfiguration.getDefaultValidatedExecutableTypes(), asSet(ExecutableType.CONSTRUCTORS, ExecutableType.NON_GETTER_METHODS));
}
Also used : BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 5 with BootstrapConfiguration

use of jakarta.validation.BootstrapConfiguration in project hibernate-validator by hibernate.

the class ValidatorFactoryBean method createConstraintValidatorFactory.

private ConstraintValidatorFactory createConstraintValidatorFactory(Configuration<?> config) {
    BootstrapConfiguration configSource = config.getBootstrapConfiguration();
    String constraintValidatorFactoryFqcn = configSource.getConstraintValidatorFactoryClassName();
    if (constraintValidatorFactoryFqcn == null) {
        // use default
        return createInstance(InjectingConstraintValidatorFactory.class);
    }
    @SuppressWarnings("unchecked") Class<? extends ConstraintValidatorFactory> constraintValidatorFactoryClass = (Class<? extends ConstraintValidatorFactory>) run(LoadClass.action(constraintValidatorFactoryFqcn, null));
    return createInstance(constraintValidatorFactoryClass);
}
Also used : ConstraintValidatorFactory(jakarta.validation.ConstraintValidatorFactory) BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) LoadClass(org.hibernate.validator.internal.util.privilegedactions.LoadClass)

Aggregations

BootstrapConfiguration (jakarta.validation.BootstrapConfiguration)11 LoadClass (org.hibernate.validator.internal.util.privilegedactions.LoadClass)6 TestForIssue (org.hibernate.validator.testutil.TestForIssue)3 Test (org.testng.annotations.Test)3 ClockProvider (jakarta.validation.ClockProvider)2 ConstraintValidatorFactory (jakarta.validation.ConstraintValidatorFactory)2 MessageInterpolator (jakarta.validation.MessageInterpolator)2 ParameterNameProvider (jakarta.validation.ParameterNameProvider)2 TraversableResolver (jakarta.validation.TraversableResolver)2 ApplicationScoped (jakarta.enterprise.context.ApplicationScoped)1 CreationalContext (jakarta.enterprise.context.spi.CreationalContext)1 Instance (jakarta.enterprise.inject.Instance)1 NamedLiteral (jakarta.enterprise.inject.literal.NamedLiteral)1 Bean (jakarta.enterprise.inject.spi.Bean)1 BeanManager (jakarta.enterprise.inject.spi.BeanManager)1 InjectionPoint (jakarta.enterprise.inject.spi.InjectionPoint)1 PassivationCapable (jakarta.enterprise.inject.spi.PassivationCapable)1 Configuration (jakarta.validation.Configuration)1 Validation (jakarta.validation.Validation)1 ValidationException (jakarta.validation.ValidationException)1