diff --git a/src/org/redkale/net/http/Rest.java b/src/org/redkale/net/http/Rest.java index 1b5cd2993..28d8b6931 100644 --- a/src/org/redkale/net/http/Rest.java +++ b/src/org/redkale/net/http/Rest.java @@ -239,6 +239,10 @@ public final class Rest { RestOnMessage rom = method.getAnnotation(RestOnMessage.class); if (rom == null) continue; String name = rom.name(); + if (Modifier.isFinal(method.getModifiers())) throw new RuntimeException("@RestOnMessage method can not final but (" + method + ")"); + if (Modifier.isStatic(method.getModifiers())) throw new RuntimeException("@RestOnMessage method can not static but (" + method + ")"); + if (method.getReturnType() != void.class) throw new RuntimeException("@RestOnMessage method must return void but (" + method + ")"); + if (method.getExceptionTypes().length > 0) throw new RuntimeException("@RestOnMessage method can not throw exception but (" + method + ")"); if (name.isEmpty()) throw new RuntimeException(method + " RestOnMessage.name is empty createRestWebSocketServlet"); if (messageNames.contains(name)) throw new RuntimeException(method + " repeat RestOnMessage.name(" + name + ") createRestWebSocketServlet"); messageNames.add(name); diff --git a/src/org/redkale/net/http/RestOnMessage.java b/src/org/redkale/net/http/RestOnMessage.java index de2c07160..b93cd1f01 100644 --- a/src/org/redkale/net/http/RestOnMessage.java +++ b/src/org/redkale/net/http/RestOnMessage.java @@ -10,7 +10,12 @@ import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; /** - * 标记在RestWebSocket的接收消息方法上,方法通常是void返回类型 + * 标记在RestWebSocket的接收消息方法上;
+ * 注意:被标记的方法必须同时符合以下条件:
+ * 1、必须修饰为public + * 2、不能修饰为final和static + * 3、返回值必须是void + * 4、不能throws检查型异常 * *

* 详情见: https://redkale.org