This commit is contained in:
Redkale
2018-04-03 16:16:10 +08:00
parent 2d31b8521d
commit e64a75cfab

View File

@@ -786,18 +786,9 @@ public final class Rest {
if ("init".equals(method.getName())) continue; if ("init".equals(method.getName())) continue;
if ("destroy".equals(method.getName())) continue; if ("destroy".equals(method.getName())) continue;
if ("version".equals(method.getName())) continue; if ("version".equals(method.getName())) continue;
if (controller == null) continue;
RestMapping[] mappings = method.getAnnotationsByType(RestMapping.class); 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; if (!controller.automapping() && mappings.length < 1) continue;
boolean ignore = false; boolean ignore = false;
for (RestMapping mapping : mappings) { for (RestMapping mapping : mappings) {
@@ -807,6 +798,16 @@ public final class Rest {
} }
} }
if (ignore) continue; if (ignore) continue;
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;
}
paramtypes.add(TypeToken.getGenericType(method.getGenericParameterTypes(), serviceType)); paramtypes.add(TypeToken.getGenericType(method.getGenericParameterTypes(), serviceType));
if (mappings.length == 0) { //没有Mapping设置一个默认值 if (mappings.length == 0) { //没有Mapping设置一个默认值
MappingEntry entry = new MappingEntry(methodidex, null, bigmodulename, method); MappingEntry entry = new MappingEntry(methodidex, null, bigmodulename, method);