验证扩展

验证扩展

此文档已经不再维护。您当前查看的是快照版本。如果想要查看最新版本的文档,请参阅最新版本

扩展说明

参数验证扩展点。

扩展接口

org.apache.dubbo.validation.Validation

扩展配置

<dubbo:service validation="xxx,yyy" />
<!-- 缺省值设置,当<dubbo:service>没有配置validation属性时,使用此配置 -->
<dubbo:provider validation="xxx,yyy" />

已知扩展

org.apache.dubbo.validation.support.jvalidation.JValidation

扩展示例

Maven 项目结构:

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxValidation.java (实现Validation接口)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.validation.Validation (纯文本文件,内容为:xxx=com.xxx.XxxValidation)

XxxValidation.java:

package com.xxx;
 
import org.apache.dubbo.validation.Validation;
 
public class XxxValidation implements Validation {
    public Object getValidator(URL url) {
        // ...
    }
}

XxxValidator.java:

package com.xxx;
 
import org.apache.dubbo.validation.Validator;
 
public class XxxValidator implements Validator {
    public XxxValidator(URL url) {
        // ...
    }
    public void validate(Invocation invocation) throws Exception {
        // ...
    }
}

META-INF/dubbo/org.apache.dubbo.validation.Validation:

xxx=com.xxx.XxxValidation

最后修改 March 1, 2023: Move sdk docs (#2337) (ceab0ea115a)