Validation Extension

Validation Extension

Extension Description

Parameter validation extension point.

Extension Interface

org.apache.dubbo.validation.Validation

Extension Configuration

  1. <dubbo:service validation="xxx,yyy" />
  2. <!-- Default value setting, when <dubbo:service> does not configure the validation attribute, use this configuration -->
  3. <dubbo:provider validation="xxx,yyy" />

Known Extensions

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

Extension Examples

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxValidation.java (implements Validation interface)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.validation.Validation (plain text file, content: xxx=com.xxx.XxxValidation)

XxxValidation.java:

  1. package com.xxx;
  2. import org.apache.dubbo.validation.Validation;
  3. public class XxxValidation implements Validation {
  4. public Object getValidator(URL url) {
  5. // ...
  6. }
  7. }

XxxValidator.java:

  1. package com.xxx;
  2. import org.apache.dubbo.validation.Validator;
  3. public class XxxValidator implements Validator {
  4. public XxxValidator(URL url) {
  5. // ...
  6. }
  7. public void validate(Invocation invocation) throws Exception {
  8. // ...
  9. }
  10. }

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

  1. xxx=com.xxx.XxxValidation

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)