-
Notifications
You must be signed in to change notification settings - Fork 26.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Validator supports automatic switch #13923
Conversation
*/ | ||
@Override | ||
protected Validator createValidator(URL url) { | ||
return new JValidator(url); | ||
List<Class<? extends Validator>> validatorList = Arrays.asList(JValidator.class, JValidatorNew.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Class.forName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you meaning loading JValidator.class
and JValidatorNew.class
classes with Class.forName(String)
like this? Or could you please provided more detail info
try {
Class<? extends Validator> validCls = (Class<? extends Validator>) Class.forName("org.apache.dubbo.validation.support.jvalidation.JValidator");
Class<? extends Validator> newValidCls = (Class<? extends Validator>) Class.forName("org.apache.dubbo.validation.support.jvalidation.JValidatorNew");
} catch (Throwable ignore) {
}
By the way, the JValidator.java#316
and JValidatorNew.java#316
need to be modified together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
A more conscise way is to use org.apache.dubbo.common.extension.Activate#onClass
and create two filter for javax
and jakarta
|
@AlbumenJ I try to use The Validation extensions was mark the dubbo/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/Validation.java Line 28 in 6b3f543
If use dubbo/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java Line 773 in 6b3f543
If remove the default extension declared in As long as fill in any characters into |
@aofall How about make |
OK. I will try it |
I found the I think this follow class can extracted into a separate module like
And make the real implement like dubbo-spi-extension. Such as Maybe there are some big changes, if the above plan is passed, will it be better to develop on the 3.3 branch? |
Yes
Can we merge these classes into one module? |
Move to #14194 |
What is the purpose of the change
In the newer versions of Hibernate-validator, the package names of the relevant validation implementation classes have been migrated from
javax
tojakarta
.Dubbo has been support new validator with
jakarta
in #9552 , but the setting of default validator is implement withjavax
, if the user is not configured to use a new validator under the SpringBoot3, anNoClassDefFoundError
will be throw.If the validator supports automatic switch, this will reduce a lot of configuration processes for users.
related with #12401 #12465
Brief changelog
Verifying this change
Checklist