This commit is contained in:
Redkale
2018-04-03 16:14:42 +08:00
parent 60225e3f5f
commit 2d31b8521d
2 changed files with 10 additions and 4 deletions

View File

@@ -782,15 +782,21 @@ public final class Rest {
for (final Method method : serviceType.getMethods()) {
if (Modifier.isStatic(method.getModifiers())) continue;
if (method.isSynthetic()) continue;
Class[] extypes = method.getExceptionTypes();
if (extypes.length > 1) continue;
if (extypes.length == 1 && extypes[0] != IOException.class) continue;
if (EXCLUDERMETHODS.contains(method.getName())) continue;
if ("init".equals(method.getName())) continue;
if ("destroy".equals(method.getName())) continue;
if ("version".equals(method.getName())) continue;
RestMapping[] mappings = method.getAnnotationsByType(RestMapping.class);
Class[] extypes = method.getExceptionTypes();
if (extypes.length > 1) {
if (mappings != null && mappings.length > 0) throw new RuntimeException("@" + RestMapping.class.getSimpleName() + " only for method with throws IOException");
continue;
}
if (extypes.length == 1 && extypes[0] != IOException.class) {
if (mappings != null && mappings.length > 0) throw new RuntimeException("@" + RestMapping.class.getSimpleName() + " only for method with throws IOException");
continue;
}
if (controller == null) continue;
if (!controller.automapping() && mappings.length < 1) continue;
boolean ignore = false;

View File

@@ -10,7 +10,7 @@ import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/**
* 只能依附在Service实现类的public方法上 <br>
* 只能依附在Service实现类的public方法上且方法如果throws只能是IOException <br>
* value默认为"/" + Service的类名去掉Service字样的小写字符串 (如HelloService的默认路径为/hello)。 <br>
* <p>
* 详情见: https://redkale.org