Skip to content

Commit 14c891c

Browse files
committed
MethodValidationPostProcessor provides protected createMethodValidationAdvice template method
Issue: SPR-12863
1 parent e377fc0 commit 14c891c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,12 +101,23 @@ public void setValidatorFactory(ValidatorFactory validatorFactory) {
101101
this.validator = validatorFactory.getValidator();
102102
}
103103

104+
104105
@Override
105106
public void afterPropertiesSet() {
106107
Pointcut pointcut = new AnnotationMatchingPointcut(this.validatedAnnotationType, true);
107-
Advice advice = (this.validator != null ? new MethodValidationInterceptor(this.validator) :
108-
new MethodValidationInterceptor());
109-
this.advisor = new DefaultPointcutAdvisor(pointcut, advice);
108+
this.advisor = new DefaultPointcutAdvisor(pointcut, createMethodValidationAdvice(this.validator));
109+
}
110+
111+
/**
112+
* Create AOP advice for method validation purposes, to be applied
113+
* with a pointcut for the specified 'validated' annotation.
114+
* @param validator the JSR-303 Validator to delegate to
115+
* @return the interceptor to use (typically, but not necessarily,
116+
* a {@link MethodValidationInterceptor} or subclass thereof)
117+
* @since 4.2
118+
*/
119+
protected Advice createMethodValidationAdvice(Validator validator) {
120+
return (validator != null ? new MethodValidationInterceptor(validator) : new MethodValidationInterceptor());
110121
}
111122

112123
}

0 commit comments

Comments
 (0)