Dubbo3 驗(yàn)證擴(kuò)展

2022-04-22 11:55 更新

擴(kuò)展說(shuō)明

參數(shù)驗(yàn)證擴(kuò)展點(diǎn)。

擴(kuò)展接口

org.apache.dubbo.validation.Validation

擴(kuò)展配置

<dubbo:service validation="xxx,yyy" />
<!-- 缺省值設(shè)置,當(dāng)<dubbo:service>沒(méi)有配置validation屬性時(shí),使用此配置 -->
<dubbo:provider validation="xxx,yyy" />

已知擴(kuò)展

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

擴(kuò)展示例

Maven 項(xiàng)目結(jié)構(gòu):

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxValidation.java (實(shí)現(xiàn)Validation接口)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.validation.Validation (純文本文件,內(nèi)容為: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


以上內(nèi)容是否對(duì)您有幫助:
在線(xiàn)筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)