当前位置: 首页>>代码示例>>Java>>正文


Java Configuration类代码示例

本文整理汇总了Java中javax.validation.Configuration的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Configuration类属于javax.validation包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postProcessConfiguration

import javax.validation.Configuration; //导入依赖的package包/类
@Override
protected void postProcessConfiguration(Configuration<?> configuration) {
    super.postProcessConfiguration(configuration);
    HibernateValidatorConfiguration hibernateConfiguration = (HibernateValidatorConfiguration) configuration;

    ConstraintMapping constraintMapping = hibernateConfiguration.createConstraintMapping();
    validators.forEach(validator -> addConstraint(constraintMapping, validator));
    hibernateConfiguration.addMapping(constraintMapping);

    hibernateValidatorConfigurationStrategy.accept(hibernateConfiguration);
}
 
开发者ID:infobip,项目名称:infobip-bean-validation,代码行数:12,代码来源:CustomLocalValidatorFactoryBean.java

示例2: getContext

import javax.validation.Configuration; //导入依赖的package包/类
@Override
public GeneralValidator getContext(final Class<?> type) {
    final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
    final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
    final Configuration<?> config = Validation.byDefaultProvider().configure()
        .messageInterpolator(messageInterpolator);
    final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
    final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
        .getDefaultValidatedExecutableTypes();

    return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
        defaultValidatedExecutableTypes);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:15,代码来源:ValidatorContextResolver.java

示例3: BeanMessageInterpolator

import javax.validation.Configuration; //导入依赖的package包/类
/**
 * Creates a new BeanMessageInterpolator object. The nested delegator is
 * pulled from the bootstrap of the validation provider
 *
 */
public BeanMessageInterpolator() {
    @SuppressWarnings("rawtypes")
    Configuration configuration = Validation.byDefaultProvider().configure();

    delegate = configuration.getDefaultMessageInterpolator();
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:12,代码来源:BeanMessageInterpolator.java

示例4: buildValidator

import javax.validation.Configuration; //导入依赖的package包/类
private static Validator buildValidator ()
{
    final GenericBootstrap bootstrap = Validation.byDefaultProvider ();
    bootstrap.providerResolver ( tracker );

    final Configuration<?> cfg = bootstrap.configure ();
    final OsgiMessageInterpolator mi = getMessageInterpolator ();
    mi.setFallback ( cfg.getDefaultMessageInterpolator () );
    cfg.messageInterpolator ( mi );

    final ValidatorFactory factory = cfg.buildValidatorFactory ();
    return factory.getValidator ();
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:14,代码来源:ValidationBundle.java

示例5: postProcessConfiguration

import javax.validation.Configuration; //导入依赖的package包/类
@Override
protected void postProcessConfiguration(Configuration<?> config) {
    this.config = config;

    if (this.paramNameProv == null) {
        this.paramNameProv = this.config.getDefaultParameterNameProvider();
    }
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:9,代码来源:SdcctValidatorFactoryBean.java

示例6: createValidatorFactory

import javax.validation.Configuration; //导入依赖的package包/类
/**
 * Create a validator factory
 * @return The factory
 */
static ValidatorFactory createValidatorFactory()
{
   Configuration configuration = Validation.byDefaultProvider().configure();
   Configuration<?> conf = configuration.traversableResolver(new IronJacamarTraversableResolver());

   return conf.buildValidatorFactory();
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:12,代码来源:BeanValidationImpl.java

示例7: getContext

import javax.validation.Configuration; //导入依赖的package包/类
/**
 * Get a context of type {@code GeneralValidator} that is applicable to the supplied type.
 *
 * @param type the class of object for which a context is desired
 * @return a context for the supplied type or {@code null} if a context for the supplied type is not available from
 *         this provider.
 */
@Override
public GeneralValidator getContext(Class<?> type) {
    Configuration<?> config = Validation.byDefaultProvider().configure();
    BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();

    config.messageInterpolator(new LocaleSpecificMessageInterpolator(Validation.byDefaultProvider().configure()
            .getDefaultMessageInterpolator()));
    config.parameterNameProvider(new CustomParameterNameProvider());

    return new GeneralValidatorImpl(config.buildValidatorFactory(),
            bootstrapConfiguration.isExecutableValidationEnabled(),
            bootstrapConfiguration.getDefaultValidatedExecutableTypes());
}
 
开发者ID:samaxes,项目名称:jaxrs-beanvalidation-javaee7,代码行数:21,代码来源:ValidationConfigurationContextResolver.java

示例8: buildFactory

import javax.validation.Configuration; //导入依赖的package包/类
public static ValidatorFactory buildFactory(final ValidationInfo config, final ClassLoader classLoader) {
    ValidatorFactory factory = null;
    final Thread thread = Thread.currentThread();
    final ClassLoader oldContextLoader = thread.getContextClassLoader();
    try {
        thread.setContextClassLoader(classLoader);
        if (config == null) {
            factory = Validation.buildDefaultValidatorFactory();
        } else {
            final Configuration<?> configuration = getConfig(config);
            try {
                factory = configuration.buildValidatorFactory();
            } catch (final ValidationException ve) {
                thread.setContextClassLoader(ValidatorBuilder.class.getClassLoader());
                factory = Validation.buildDefaultValidatorFactory();
                thread.setContextClassLoader(classLoader);

                logger.warning("Unable create validator factory with config " + config
                    + " (" + ve.getMessage() + ")."
                    + " Default factory will be used.");
            }
        }
    } finally {
        thread.setContextClassLoader(oldContextLoader);
    }
    return factory;
}
 
开发者ID:apache,项目名称:tomee,代码行数:28,代码来源:ValidatorBuilder.java

示例9: DefaultValidationContext

import javax.validation.Configuration; //导入依赖的package包/类
private DefaultValidationContext() {
    Configuration<?> validationConfig = Validation.byDefaultProvider().configure();
    if (new DefaultSejdaContext().isIgnoreXmlConfiguration()) {
        validationConfig.ignoreXmlConfiguration();
    }
    ValidatorFactory factory = validationConfig.buildValidatorFactory();
    validator = factory.getValidator();
}
 
开发者ID:torakiki,项目名称:sejda,代码行数:9,代码来源:DefaultValidationContext.java

示例10: ValidationExtension

import javax.validation.Configuration; //导入依赖的package包/类
/**
 * Creates a ValidationExtension
 *
 * @param m the Morphia instance to use
 */
public ValidationExtension(final Morphia m) {
    final Configuration<?> configuration = Validation.byDefaultProvider().configure();
    validationFactory = configuration.buildValidatorFactory();

    m.getMapper().addInterceptor(this);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:12,代码来源:ValidationExtension.java

示例11: setUp

import javax.validation.Configuration; //导入依赖的package包/类
@Before
public void setUp() {
	Configuration config = Validation.byDefaultProvider().configure();
	ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
	validator = factory.getValidator();
}
 
开发者ID:dvbern,项目名称:beanvalidation,代码行数:7,代码来源:SameTest.java

示例12: afterPropertiesSet

import javax.validation.Configuration; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {
	@SuppressWarnings({"rawtypes", "unchecked"})
	Configuration<?> configuration = (this.providerClass != null ?
			Validation.byProvider(this.providerClass).configure() :
			Validation.byDefaultProvider().configure());

	MessageInterpolator targetInterpolator = this.messageInterpolator;
	if (targetInterpolator == null) {
		targetInterpolator = configuration.getDefaultMessageInterpolator();
	}
	configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));

	if (this.traversableResolver != null) {
		configuration.traversableResolver(this.traversableResolver);
	}

	ConstraintValidatorFactory targetConstraintValidatorFactory = this.constraintValidatorFactory;
	if (targetConstraintValidatorFactory == null && this.applicationContext != null) {
		targetConstraintValidatorFactory =
				new SpringConstraintValidatorFactory(this.applicationContext.getAutowireCapableBeanFactory());
	}
	if (targetConstraintValidatorFactory != null) {
		configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
	}

	if (this.parameterNameDiscoverer != null) {
		configureParameterNameProviderIfPossible(configuration);
	}

	if (this.mappingLocations != null) {
		for (Resource location : this.mappingLocations) {
			try {
				configuration.addMapping(location.getInputStream());
			}
			catch (IOException ex) {
				throw new IllegalStateException("Cannot read mapping resource: " + location);
			}
		}
	}

	for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
		configuration.addProperty(entry.getKey(), entry.getValue());
	}

	// Allow for custom post-processing before we actually build the ValidatorFactory.
	postProcessConfiguration(configuration);

	this.validatorFactory = configuration.buildValidatorFactory();
	setTargetValidator(this.validatorFactory.getValidator());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:LocalValidatorFactoryBean.java

示例13: buildValidatorFactory

import javax.validation.Configuration; //导入依赖的package包/类
public static ValidatorFactory buildValidatorFactory(boolean osgi,
                                                     ValidationProviderResolver validationProviderResolver,
                                                     MessageInterpolator messageInterpolator,
                                                     TraversableResolver traversableResolver,
                                                     ConstraintValidatorFactory constraintValidatorFactory) {

    ValidationProviderResolver resolvedValidationProviderResolver =
            resolveValidationProviderResolver(osgi, validationProviderResolver);

    GenericBootstrap bootstrap = Validation.byDefaultProvider();
    if (resolvedValidationProviderResolver != null) {
        bootstrap.providerResolver(resolvedValidationProviderResolver);
    }
    Configuration<?> configuration = bootstrap.configure();

    if (messageInterpolator != null) {
        configuration.messageInterpolator(messageInterpolator);
    }

    if (traversableResolver != null) {
        configuration.traversableResolver(traversableResolver);
    }

    if (constraintValidatorFactory != null) {
        configuration.constraintValidatorFactory(constraintValidatorFactory);
    }

    return configuration.buildValidatorFactory();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:ValidatorFactories.java

示例14: buildValidatorFactory

import javax.validation.Configuration; //导入依赖的package包/类
protected ValidatorFactory buildValidatorFactory(VaConfigSetupper hibernateConfigSetupper) {
    final Configuration<?> configuration = createConfiguration();
    setupFrameworkConfiguration(configuration);
    setupYourConfiguration(configuration, hibernateConfigSetupper);
    return configuration.buildValidatorFactory();
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:7,代码来源:ActionValidator.java

示例15: setupFrameworkConfiguration

import javax.validation.Configuration; //导入依赖的package包/类
protected void setupFrameworkConfiguration(Configuration<?> configuration) {
    configuration.messageInterpolator(newResourceBundleMessageInterpolator());
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:4,代码来源:ActionValidator.java


注:本文中的javax.validation.Configuration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。