Search in sources :

Example 6 with BootstrapConfiguration

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

the class ValidatorFactoryBean method createValidationXmlValueExtractors.

private Set<ValueExtractorDescriptor> createValidationXmlValueExtractors(Configuration<?> config) {
    BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    Set<String> valueExtractorFqcns = bootstrapConfiguration.getValueExtractorClassNames();
    @SuppressWarnings("unchecked") Set<ValueExtractorDescriptor> valueExtractorDescriptors = valueExtractorFqcns.stream().map(fqcn -> createInstance((Class<? extends ValueExtractor<?>>) run(LoadClass.action(fqcn, null)))).map(ve -> new ValueExtractorDescriptor(ve)).collect(Collectors.toSet());
    return valueExtractorDescriptors;
}
Also used : GetClassLoader(org.hibernate.validator.internal.util.privilegedactions.GetClassLoader) ConstraintValidatorFactory(jakarta.validation.ConstraintValidatorFactory) ValueExtractorDescriptor(org.hibernate.validator.internal.engine.valueextraction.ValueExtractorDescriptor) BeanNames(org.hibernate.validator.cdi.spi.BeanNames) ClassHierarchyHelper(org.hibernate.validator.internal.util.classhierarchy.ClassHierarchyHelper) ApplicationScoped(jakarta.enterprise.context.ApplicationScoped) TraversableResolver(jakarta.validation.TraversableResolver) Function(java.util.function.Function) Instance(jakarta.enterprise.inject.Instance) ValidatorFactory(jakarta.validation.ValidatorFactory) Bean(jakarta.enterprise.inject.spi.Bean) HashSet(java.util.HashSet) ValueExtractor(jakarta.validation.valueextraction.ValueExtractor) CollectionHelper.newHashSet(org.hibernate.validator.internal.util.CollectionHelper.newHashSet) GetInstancesFromServiceLoader(org.hibernate.validator.internal.util.privilegedactions.GetInstancesFromServiceLoader) Map(java.util.Map) PassivationCapable(jakarta.enterprise.inject.spi.PassivationCapable) CollectionHelper(org.hibernate.validator.internal.util.CollectionHelper) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Validation(jakarta.validation.Validation) BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) BeanMetaDataClassNormalizer(org.hibernate.validator.metadata.BeanMetaDataClassNormalizer) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) NamedLiteral(jakarta.enterprise.inject.literal.NamedLiteral) LoadClass(org.hibernate.validator.internal.util.privilegedactions.LoadClass) Set(java.util.Set) CreationalContext(jakarta.enterprise.context.spi.CreationalContext) PrivilegedAction(java.security.PrivilegedAction) Collectors(java.util.stream.Collectors) ParameterNameProvider(jakarta.validation.ParameterNameProvider) List(java.util.List) ClockProvider(jakarta.validation.ClockProvider) MessageInterpolator(jakarta.validation.MessageInterpolator) Type(java.lang.reflect.Type) Annotation(java.lang.annotation.Annotation) HibernateValidatorConfiguration(org.hibernate.validator.HibernateValidatorConfiguration) AccessController(java.security.AccessController) Collections(java.util.Collections) IgnoreForbiddenApisErrors(org.hibernate.validator.internal.IgnoreForbiddenApisErrors) Configuration(jakarta.validation.Configuration) ValueExtractorDescriptor(org.hibernate.validator.internal.engine.valueextraction.ValueExtractorDescriptor) BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) LoadClass(org.hibernate.validator.internal.util.privilegedactions.LoadClass) ValueExtractor(jakarta.validation.valueextraction.ValueExtractor)

Example 7 with BootstrapConfiguration

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

the class ValidatorFactoryBean method createClockProvider.

private ClockProvider createClockProvider(Configuration<?> config) {
    BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    String clockProviderFqcn = bootstrapConfiguration.getClockProviderClassName();
    if (clockProviderFqcn == null) {
        return config.getDefaultClockProvider();
    }
    @SuppressWarnings("unchecked") Class<? extends ClockProvider> clockProviderClass = (Class<? extends ClockProvider>) run(LoadClass.action(clockProviderFqcn, null));
    return createInstance(clockProviderClass);
}
Also used : BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) LoadClass(org.hibernate.validator.internal.util.privilegedactions.LoadClass) ClockProvider(jakarta.validation.ClockProvider)

Example 8 with BootstrapConfiguration

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

the class ValidatorFactoryBean method createTraversableResolver.

private TraversableResolver createTraversableResolver(Configuration<?> config) {
    BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    String traversableResolverFqcn = bootstrapConfiguration.getTraversableResolverClassName();
    if (traversableResolverFqcn == null) {
        return config.getDefaultTraversableResolver();
    }
    @SuppressWarnings("unchecked") Class<? extends TraversableResolver> traversableResolverClass = (Class<? extends TraversableResolver>) run(LoadClass.action(traversableResolverFqcn, null));
    return createInstance(traversableResolverClass);
}
Also used : TraversableResolver(jakarta.validation.TraversableResolver) BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) LoadClass(org.hibernate.validator.internal.util.privilegedactions.LoadClass)

Example 9 with BootstrapConfiguration

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

the class ValidatorFactoryBean method createMessageInterpolator.

private MessageInterpolator createMessageInterpolator(Configuration<?> config) {
    BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    String messageInterpolatorFqcn = bootstrapConfiguration.getMessageInterpolatorClassName();
    if (messageInterpolatorFqcn == null) {
        return config.getDefaultMessageInterpolator();
    }
    @SuppressWarnings("unchecked") Class<? extends MessageInterpolator> messageInterpolatorClass = (Class<? extends MessageInterpolator>) run(LoadClass.action(messageInterpolatorFqcn, null));
    return createInstance(messageInterpolatorClass);
}
Also used : BootstrapConfiguration(jakarta.validation.BootstrapConfiguration) LoadClass(org.hibernate.validator.internal.util.privilegedactions.LoadClass) MessageInterpolator(jakarta.validation.MessageInterpolator)

Example 10 with BootstrapConfiguration

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

the class ValidatorFactoryBean method createParameterNameProvider.

private ParameterNameProvider createParameterNameProvider(Configuration<?> config) {
    BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    String parameterNameProviderFqcn = bootstrapConfiguration.getParameterNameProviderClassName();
    if (parameterNameProviderFqcn == null) {
        return config.getDefaultParameterNameProvider();
    }
    @SuppressWarnings("unchecked") Class<? extends ParameterNameProvider> parameterNameProviderClass = (Class<? extends ParameterNameProvider>) run(LoadClass.action(parameterNameProviderFqcn, null));
    return createInstance(parameterNameProviderClass);
}
Also used : ParameterNameProvider(jakarta.validation.ParameterNameProvider) 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