本文整理了Java中javax.validation.Configuration.traversableResolver()
方法的一些代码示例,展示了Configuration.traversableResolver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.traversableResolver()
方法的具体详情如下:
包路径:javax.validation.Configuration
类名称:Configuration
方法名:traversableResolver
[英]Defines the traversable resolver used. Has priority over the configuration based traversable resolver.
If null is passed, the default traversable resolver is used (defined in XML or the specification default).
[中]定义使用的可遍历解析器。优先于基于配置的可遍历解析器。
如果传递null,则使用默认的可遍历解析器(在XML或默认规范中定义)。
代码示例来源:origin: spring-projects/spring-framework
configuration.traversableResolver(this.traversableResolver);
代码示例来源:origin: org.springframework/spring-context
configuration.traversableResolver(this.traversableResolver);
代码示例来源:origin: org.graniteds/granite-client-java-advanced
@SuppressWarnings("unchecked")
@Override
public T traversableResolver(TraversableResolver resolver) {
configuration = configuration.traversableResolver(resolver);
return (T)this;
}
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public T traversableResolver(final TraversableResolver resolver) {
return delegate.traversableResolver(resolver);
}
代码示例来源:origin: hibernate/hibernate-validator
@Override
public ValidatorFactory create(CreationalContext<ValidatorFactory> ctx) {
Configuration<?> config = getConfiguration();
config.constraintValidatorFactory( createConstraintValidatorFactory( config ) );
config.messageInterpolator( createMessageInterpolator( config ) );
config.traversableResolver( createTraversableResolver( config ) );
config.parameterNameProvider( createParameterNameProvider( config ) );
config.clockProvider( createClockProvider( config ) );
addValueExtractorBeans( config );
return config.buildValidatorFactory();
}
代码示例来源:origin: com.atlassian.plugins/oauth2
@Autowired
public OAuth2AccessTokenValidatorImpl(OAuthSettings oAuthSettings) throws MalformedURLException {
this.oAuthSettings = oAuthSettings;
// Need to install a simple traversable thingy cos otherwise it means I obviously want to suck in hibernate jpa (wtf)
validator = Validation.byDefaultProvider().configure()
.traversableResolver(new SimpleTraversableResolver())
.buildValidatorFactory().getValidator();
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test(expectedExceptions = ValidationException.class)
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TRAVERSABLE, id = "j")
public void testResolverExceptionsGetWrappedInValidationException() {
ExceptionThrowingTraversableResolver resolver = new ExceptionThrowingTraversableResolver();
Configuration<?> config = TestUtil.getConfigurationUnderTest().traversableResolver( resolver );
ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
v.validate( new Suit() );
}
代码示例来源:origin: org.hibernate.jsr303.tck/jsr303-tck
@Test(expectedExceptions = ValidationException.class)
@SpecAssertion(section = "3.5.2", id = "e")
public void testResolverExceptionsGetWrappedInValidationException() {
ExceptionThrowingTraversableResolver resolver = new ExceptionThrowingTraversableResolver();
Configuration<?> config = TestUtil.getConfigurationUnderTest().traversableResolver( resolver );
ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
v.validate( new Suit() );
}
代码示例来源:origin: org.jboss.ironjacamar/ironjacamar-core-impl
/**
* Constructor
*/
public BeanValidation()
{
Configuration configuration = Validation.byDefaultProvider().configure();
Configuration<?> conf = configuration.traversableResolver(new JCATraversableResolver());
validatorFactory = conf.buildValidatorFactory();
validator = validatorFactory.getValidator();
}
代码示例来源:origin: org.hibernate.jsr303.tck/jsr303-tck
@Test
@SpecAssertion(section = "3.5.2", id = "d")
public void testCustomTraversableResolverViaConfiguration() {
// get a new factory using a custom configuration
Configuration<?> configuration = TestUtil.getConfigurationUnderTest();
configuration.traversableResolver( new DummyTraversableResolver() );
ValidatorFactory factory = configuration.buildValidatorFactory();
Validator validator = factory.getValidator();
Person person = new Person();
Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
assertCorrectNumberOfViolations( constraintViolations, 0 );
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TRAVERSABLE, id = "i")
public void testCustomTraversableResolverViaConfiguration() {
// get a new factory using a custom configuration
Configuration<?> configuration = TestUtil.getConfigurationUnderTest();
configuration.traversableResolver( new DummyTraversableResolver() );
ValidatorFactory factory = configuration.buildValidatorFactory();
Validator validator = factory.getValidator();
Person person = new Person();
Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
assertNumberOfViolations( constraintViolations, 0 );
}
代码示例来源:origin: org.jboss.ironjacamar/ironjacamar-core-impl
/**
* Create a validator factory
* @return The factory
*/
public static ValidatorFactory createValidatorFactory()
{
Configuration configuration = Validation.byDefaultProvider().configure();
Configuration<?> conf = configuration.traversableResolver(new JCATraversableResolver());
return conf.buildValidatorFactory();
}
代码示例来源:origin: org.apache.cxf/cxf-core
private static void initFactoryConfig(Configuration<?> factoryCfg, ValidationConfiguration cfg) {
if (cfg != null) {
factoryCfg.parameterNameProvider(cfg.getParameterNameProvider());
factoryCfg.messageInterpolator(cfg.getMessageInterpolator());
factoryCfg.traversableResolver(cfg.getTraversableResolver());
factoryCfg.constraintValidatorFactory(cfg.getConstraintValidatorFactory());
for (Map.Entry<String, String> entry : cfg.getProperties().entrySet()) {
factoryCfg.addProperty(entry.getKey(), entry.getValue());
}
}
}
代码示例来源:origin: apache/cxf
private static void initFactoryConfig(Configuration<?> factoryCfg, ValidationConfiguration cfg) {
if (cfg != null) {
factoryCfg.parameterNameProvider(cfg.getParameterNameProvider());
factoryCfg.messageInterpolator(cfg.getMessageInterpolator());
factoryCfg.traversableResolver(cfg.getTraversableResolver());
factoryCfg.constraintValidatorFactory(cfg.getConstraintValidatorFactory());
for (Map.Entry<String, String> entry : cfg.getProperties().entrySet()) {
factoryCfg.addProperty(entry.getKey(), entry.getValue());
}
}
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test
@SpecAssertion(section = Sections.VALIDATIONAPI_BOOTSTRAPPING_VALIDATORFACTORY, id = "c")
public void testTraversableResolverFromValidatorFactory() {
Configuration<?> configuration = TestUtil.getConfigurationUnderTest();
DummyTraversableResolver traversableResolver = new DummyTraversableResolver();
configuration.traversableResolver( traversableResolver );
ValidatorFactory factory = configuration.buildValidatorFactory();
assertSame( factory.getTraversableResolver(), traversableResolver );
}
代码示例来源:origin: com.atlassian.plugins/atlassian-connect-server-core
@Override
public Optional<ConnectSessionAuthToken> parseAndValidate(@Nonnull String authTokenJwt) throws InvalidSessionAuthTokenException, CannotRetrieveKeyException {
final ConnectSessionAuthTokenValidator tokenValidator;
// Need to install a simple traversable thingy cos otherwise it means I obviously want to suck in hibernate jpa (wtf)
final Validator validator = Validation.byDefaultProvider().configure()
.traversableResolver(new SimpleTraversableResolver())
.buildValidatorFactory().getValidator();
try {
tokenValidator = new ConnectSessionAuthTokenValidator(oAuthSettings.getKeyProvider(), oAuthSettings.getAuthorizationServerId(),
validator,
ImmutableSet.of(oAuthSettings.getHostBaseUrl()));
} catch (MalformedURLException e) {
throw new IllegalStateException(e);
}
return tokenValidator.parseAndValidate(authTokenJwt);
}
}
代码示例来源:origin: org.hibernate.jsr303.tck/jsr303-tck
@Test
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "e"),
@SpecAssertion(section = "4.4.6", id = "h")
})
public void testMessageInterpolatorSpecifiedInValidationXmlCanBeOverridden() {
Configuration<?> configuration = Validation
.byDefaultProvider()
.configure();
configuration = configuration.traversableResolver( new ConfigurationDefinedTraversableResolver() );
Validator validator = configuration.buildValidatorFactory().getValidator();
User user = new User();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
assertCorrectNumberOfViolations( constraintViolations, 1 );
assertTrue(
ConfigurationDefinedTraversableResolver.numberOfIsReachableCalls > 0,
"The resolver should have been called at least once if configuration settings were applied."
);
}
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test
@SpecAssertions({
@SpecAssertion(section = Sections.VALIDATIONAPI_BOOTSTRAPPING_XMLCONFIGURATION, id = "d"),
@SpecAssertion(section = Sections.VALIDATIONAPI_BOOTSTRAPPING_XMLCONFIGURATION, id = "g")
})
public void testTraversableResolverSpecifiedInValidationXmlCanBeOverridden() {
Configuration<?> configuration = Validation
.byDefaultProvider()
.configure();
configuration = configuration.traversableResolver( new ConfigurationDefinedTraversableResolver() );
Validator validator = configuration.buildValidatorFactory().getValidator();
User user = new User();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
assertNumberOfViolations( constraintViolations, 1 );
assertTrue(
ConfigurationDefinedTraversableResolver.numberOfIsReachableCalls > 0,
"The resolver should have been called at least once if configuration settings were applied."
);
}
}
代码示例来源:origin: org.hibernate.jsr303.tck/jsr303-tck
@Test
@SpecAssertions({
@SpecAssertion(section = "3.5.2", id = "a"),
@SpecAssertion(section = "3.5.2", id = "b"),
@SpecAssertion(section = "3.5.2", id = "c")
})
public void testCorrectNumberOfCallsToIsReachableAndIsCascadable() {
Suit suit = new Suit();
suit.setTrousers( new Trousers() );
suit.setJacket( new Jacket() );
suit.setSize( 3333 );
suit.getTrousers().setLength( 32321 );
suit.getJacket().setWidth( 432432 );
SnifferTraversableResolver resolver = new SnifferTraversableResolver( suit );
Configuration<?> config = TestUtil.getConfigurationUnderTest().traversableResolver( resolver );
ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
v.validate( suit );
assertEquals( resolver.getReachPaths().size(), 5 );
assertEquals( resolver.getCascadePaths().size(), 2 );
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator-cdi
@Override
public ValidatorFactory create(CreationalContext<ValidatorFactory> ctx) {
Configuration<?> config = getConfiguration();
config.constraintValidatorFactory( createConstraintValidatorFactory( config ) );
config.messageInterpolator( createMessageInterpolator( config ) );
config.traversableResolver( createTraversableResolver( config ) );
config.parameterNameProvider( createParameterNameProvider( config ) );
config.clockProvider( createClockProvider( config ) );
addValueExtractorBeans( config );
return config.buildValidatorFactory();
}
内容来源于网络,如有侵权,请联系作者删除!