From 21af487aab8aea4c1af6bb6d76c527e122e4cdc0 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Thu, 11 Jan 2018 19:13:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E6=A0=87=E8=AE=B0@RestOnMess?= =?UTF-8?q?age=E6=96=B9=E6=B3=95=E7=9A=84=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/net/http/Rest.java | 4 ++++ src/org/redkale/net/http/RestOnMessage.java | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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