ResourceProducer增加required属性

This commit is contained in:
redkale
2023-10-05 20:22:43 +08:00
parent e280061dff
commit b8d5800434
2 changed files with 7 additions and 2 deletions

View File

@@ -1178,6 +1178,9 @@ public final class Application {
throw new RestException("@" + ResourceProducer.class.getSimpleName() + " must on " + MessageProducer.class.getName() + " type field, but on " + field);
}
MessageAgent agent = findMessageAgent(annotation.mq());
if (!annotation.required() && agent == null) {
return;
}
if (agent == null) {
throw new RedkaleException("Not found " + MessageAgent.class.getSimpleName() + "(name = " + annotation.mq() + ") on " + field);
}

View File

@@ -3,9 +3,9 @@
*/
package org.redkale.mq;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.*;
import org.redkale.convert.ConvertType;
/**
@@ -25,6 +25,8 @@ public @interface ResourceProducer {
String mq();
boolean required() default true;
ConvertType convertType() default ConvertType.JSON;
}