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


Java HibernateValidatorConfiguration类代码示例

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


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

示例1: start

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
    HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class)
            .configure();
    configuration.parameterNameProvider(new ReflectionParameterNameProvider());
    configuration.messageInterpolator(new LocaleSpecificMessageInterpolator(configuration
            .getDefaultMessageInterpolator()));
    validatorFactory = configuration.buildValidatorFactory();
    Dictionary<String, Object> props = new Hashtable<>();
    props.put(Constants.SERVICE_VENDOR, "AdeptJ");
    props.put(Constants.SERVICE_DESCRIPTION, "AdeptJ ValidatorService");
    servRegValidatorService = context.registerService(ValidatorService.class,
            new OSGiBeanValidatorService(this.validatorFactory.getValidator(),
                    configuration.getBootstrapConfiguration()),
            props);
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:17,代码来源:BeanValidationActivator.java

示例2: getPropertyConfiguredValidatedValueHandlers

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
/**
 * Returns a list with {@link ValidatedValueUnwrapper}s configured via the
 * {@link HibernateValidatorConfiguration#VALIDATED_VALUE_HANDLERS}
 * property.
 *
 * @param properties
 *            the properties used to bootstrap the factory
 *
 * @return a list with property-configured {@link ValidatedValueUnwrapper}s;
 *         May be empty but never {@code null}
 */
private List<ValidatedValueUnwrapper<?>> getPropertyConfiguredValidatedValueHandlers(Map<String, String> properties) {
	String propertyValue = properties.get(HibernateValidatorConfiguration.VALIDATED_VALUE_HANDLERS);

	if (propertyValue == null || propertyValue.isEmpty()) {
		return Collections.emptyList();
	}

	String[] handlerNames = propertyValue.split(",");
	List<ValidatedValueUnwrapper<?>> handlers = newArrayList(handlerNames.length);

	for (String handlerName : handlerNames) {
		@SuppressWarnings("unchecked")
		Class<? extends ValidatedValueUnwrapper<?>> handlerType = (Class<? extends ValidatedValueUnwrapper<?>>) run(LoadClass
				.action(handlerName, ValidatorFactoryImpl513.class));
		handlers.add(run(NewInstance.action(handlerType, "validated value handler class")));
	}

	return handlers;
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:31,代码来源:ValidatorFactoryImpl513.java

示例3: createConfiguration

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
/**
 * create hibernate validation configuration
 * 
 * @return
 */
protected HibernateValidatorConfiguration createConfiguration() {
	HibernateValidatorConfiguration configuration = null;
	if (this.isIgnoreClassHierarchy()) {
		ValidationProviderResolver resolver = new ValidationProviderResolver() {
			/**
			 * (non-Javadoc)
			 * 
			 * @see javax.validation.ValidationProviderResolver#getValidationProviders()
			 */
			@Override
			public List<ValidationProvider<?>> getValidationProviders() {
				List<ValidationProvider<?>> providers = new ArrayList<ValidationProvider<?>>(1);
				providers.add(new HibernateValidator513());
				return providers;
			}
		};
		configuration = Validation.byProvider(HibernateValidator513.class).providerResolver(resolver).configure();
	} else {
		configuration = Validation.byProvider(HibernateValidator.class).configure();
	}
	configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(
			MESSAGES)));
	return configuration;
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:30,代码来源:HibernateValidationConfigurationInitializer.java

示例4: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysRole.class)
            .property("roleName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .constraint(new PatternDef().regexp("^(?!root$).+$").message(
                    "may not be root"))
            .property("roleCode", ElementType.FIELD)
            .constraint(new NotNullDef()).constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:SysRoleValidator.java

示例5: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysRoute.class)
            .property("routeId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("name", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("url", ElementType.FIELD)
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysRouteUpdateValidator.java

示例6: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysMenu.class)
            .property("menuName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .property("menuPath", ElementType.FIELD)
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"))
            .property("parentId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("icon", ElementType.FIELD)
            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysMenuValidator.java

示例7: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysUser.class)
            .property("userId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("username", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(3))
            .constraint(new PatternDef().regexp("[a-zA-Z][0-9a-zA-Z_]*")
                    .message("{msg.error.validation.username.pattern}"))
            .property("password", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .property("fullName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("email", ElementType.FIELD).constraint(new EmailDef())
            .constraint(new SizeDef().max(64));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysUserUpdateValidator.java

示例8: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping.type(SysRole.class).property("roleId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("roleName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new PatternDef().regexp("^(?!root$).+$").message("may not be root"))
            .property("roleCode", ElementType.FIELD)

            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:19,代码来源:SysRoleUpdateValidator.java

示例9: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysUser.class)
            .property("username", ElementType.FIELD)
            .constraint(new NotNullDef())
            .constraint(new SizeDef().max(16).min(3))
            .constraint(new PatternDef().regexp("[a-zA-Z][0-9a-zA-Z_]*")
                    .message("{msg.error.validation.username.pattern}"))
            .property("password", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef())
            .property("fullName", ElementType.FIELD)
            .constraint(new NotNullDef()).constraint(new SizeDef().max(32))
            .property("email", ElementType.FIELD)
            .constraint(new SizeDef().max(64)).constraint(new EmailDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysUserValidator.java

示例10: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping.type(ChangePasswordVo.class)
            .property("oldpassword", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef())
            .property("newpassword", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef())
            .property("retypepassword", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:21,代码来源:PasswordValidator.java

示例11: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysMenu.class)
            .property("menuId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("menuName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("menuPath", ElementType.FIELD)
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"))
            .property("icon", ElementType.FIELD)
            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:24,代码来源:SysMenuUpdateValidator.java

示例12: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysRoute.class)
            .property("name", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .property("url", ElementType.FIELD)
            .constraint(new NotNullDef())
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysRouteValidator.java

示例13: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping.type(SysJob.class).property("jobId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("clazzName", ElementType.FIELD).constraint(new NullDef())
            .property("jobName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("cron", ElementType.FIELD)
            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:18,代码来源:SysJobUpdateValidator.java

示例14: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysJob.class)
            .property("clazzName", ElementType.FIELD)
            .constraint(new NotNullDef())
            .constraint(new SizeDef().max(64))
            .constraint(new PatternDef().regexp("[a-zA-Z.]+")
                    .message("{msg.error.validation.className.pattern}"))
            .property("jobName", ElementType.FIELD)
            .constraint(new SizeDef().max(32)).constraint(new NotNullDef())
            .property("cron", ElementType.FIELD)
            .constraint(new SizeDef().max(32)).constraint(new NotNullDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysJobValidator.java

示例15: createValidator

import org.hibernate.validator.HibernateValidatorConfiguration; //导入依赖的package包/类
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysDict.class)
            .property("dictCode", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .constraint(new PatternDef().regexp("[0-9a-zA-Z_]+").message(
                    "{msg.error.validation.dictCode.pattern}"))
            .property("dictName", ElementType.FIELD)
            .constraint(new SizeDef().max(32)).constraint(new NotNullDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:SysDictValidator.java


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