diff --git a/src/org/redkale/boot/watch/AppWatchService.java b/src/org/redkale/boot/watch/AppWatchService.java deleted file mode 100644 index 964725088..000000000 --- a/src/org/redkale/boot/watch/AppWatchService.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.boot.watch; - -import javax.annotation.Resource; -import org.redkale.boot.Application; -import org.redkale.net.TransportFactory; -import org.redkale.net.http.RestService; -import org.redkale.watch.WatchService; - -/** - *

- * 详情见: https://redkale.org - * - * @author zhangjx - */ -@RestService(name = "watch", repair = false) -public class AppWatchService implements WatchService { - - @Resource - private Application application; - - @Resource - private TransportFactory transportFactory; - -} diff --git a/src/org/redkale/boot/watch/ServiceWatchService.java b/src/org/redkale/boot/watch/ServiceWatchService.java new file mode 100644 index 000000000..fd4237208 --- /dev/null +++ b/src/org/redkale/boot/watch/ServiceWatchService.java @@ -0,0 +1,41 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.redkale.boot.watch; + +import javax.annotation.Resource; +import org.redkale.boot.Application; +import org.redkale.net.TransportFactory; +import org.redkale.net.http.*; +import org.redkale.service.RetResult; +import org.redkale.watch.WatchService; + +/** + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ +@RestService(name = "service", catalog = "watch", repair = false) +public class ServiceWatchService implements WatchService { + + @Resource + private Application application; + + @Resource + private TransportFactory transportFactory; + + @RestMapping(name = "load", auth = false, comment = "动态增加Service") + public RetResult loadService(String type, @RestUploadFile(maxLength = 10 * 1024 * 1024, fileNameReg = "\\.jar$") byte[] jar) { + //待开发 + return RetResult.success(); + } + + @RestMapping(name = "stop", auth = false, comment = "动态停止Service") + public RetResult stopService(String name, String type) { + //待开发 + return RetResult.success(); + } +} diff --git a/src/org/redkale/boot/watch/ServletWatchService.java b/src/org/redkale/boot/watch/ServletWatchService.java new file mode 100644 index 000000000..5f3eff235 --- /dev/null +++ b/src/org/redkale/boot/watch/ServletWatchService.java @@ -0,0 +1,41 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.redkale.boot.watch; + +import javax.annotation.Resource; +import org.redkale.boot.Application; +import org.redkale.net.TransportFactory; +import org.redkale.net.http.*; +import org.redkale.service.RetResult; +import org.redkale.watch.WatchService; + +/** + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ +@RestService(name = "servlet", catalog = "watch", repair = false) +public class ServletWatchService implements WatchService { + + @Resource + private Application application; + + @Resource + private TransportFactory transportFactory; + + @RestMapping(name = "load", auth = false, comment = "动态增加Servlet") + public RetResult loadServlet(String type, @RestUploadFile(maxLength = 10 * 1024 * 1024, fileNameReg = "\\.jar$") byte[] jar) { + //待开发 + return RetResult.success(); + } + + @RestMapping(name = "stop", auth = false, comment = "动态停止Servlet") + public RetResult stopServlet(String type) { + //待开发 + return RetResult.success(); + } +} diff --git a/src/org/redkale/net/http/Rest.java b/src/org/redkale/net/http/Rest.java index 84050cfae..cccbd2f0c 100644 --- a/src/org/redkale/net/http/Rest.java +++ b/src/org/redkale/net/http/Rest.java @@ -751,6 +751,7 @@ public final class Rest { if (anncookie != null) throw new RuntimeException("@RestAddress and @RestCookie cannot on the same Parameter in " + method); if (annsid != null) throw new RuntimeException("@RestAddress and @RestSessionid cannot on the same Parameter in " + method); if (ptype != String.class) throw new RuntimeException("@RestAddress must on String Parameter in " + method); + comment = annaddr.comment(); } RestBody annbody = param.getAnnotation(RestBody.class); if (annbody != null) { @@ -759,6 +760,7 @@ public final class Rest { if (annsid != null) throw new RuntimeException("@RestBody and @RestSessionid cannot on the same Parameter in " + method); if (annaddr != null) throw new RuntimeException("@RestBody and @RestAddress cannot on the same Parameter in " + method); if (ptype.isPrimitive()) throw new RuntimeException("@RestBody cannot on primitive type Parameter in " + method); + comment = annbody.comment(); } RestUploadFile annfile = param.getAnnotation(RestUploadFile.class); if (annfile != null) { @@ -771,6 +773,7 @@ public final class Rest { if (annaddr != null) throw new RuntimeException("@RestUploadFile and @RestAddress cannot on the same Parameter in " + method); if (annbody != null) throw new RuntimeException("@RestUploadFile and @RestBody cannot on the same Parameter in " + method); if (ptype != byte[].class && ptype != File.class && ptype != File[].class) throw new RuntimeException("@RestUploadFile must on byte[] or File or File[] Parameter in " + method); + comment = annfile.comment(); } RestURI annuri = param.getAnnotation(RestURI.class); @@ -782,6 +785,7 @@ public final class Rest { if (annbody != null) throw new RuntimeException("@RestURI and @RestBody cannot on the same Parameter in " + method); if (annfile != null) throw new RuntimeException("@RestURI and @RestUploadFile cannot on the same Parameter in " + method); if (ptype != String.class) throw new RuntimeException("@RestURI must on String Parameter in " + method); + comment = annuri.comment(); } RestParam annpara = param.getAnnotation(RestParam.class); diff --git a/src/org/redkale/net/http/RestAddress.java b/src/org/redkale/net/http/RestAddress.java index 5137a818a..4530d4570 100644 --- a/src/org/redkale/net/http/RestAddress.java +++ b/src/org/redkale/net/http/RestAddress.java @@ -25,4 +25,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Retention(RUNTIME) public @interface RestAddress { + /** + * 备注描述, 对应@HttpParam.comment + * + * @return String + */ + String comment() default ""; } diff --git a/src/org/redkale/net/http/RestBody.java b/src/org/redkale/net/http/RestBody.java index cbfaa5ef2..fe7f96f44 100644 --- a/src/org/redkale/net/http/RestBody.java +++ b/src/org/redkale/net/http/RestBody.java @@ -25,4 +25,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Retention(RUNTIME) public @interface RestBody { + /** + * 备注描述, 对应@HttpParam.comment + * + * @return String + */ + String comment() default ""; } diff --git a/src/org/redkale/net/http/RestURI.java b/src/org/redkale/net/http/RestURI.java index 44e9ad009..fb7fb6a01 100644 --- a/src/org/redkale/net/http/RestURI.java +++ b/src/org/redkale/net/http/RestURI.java @@ -23,4 +23,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Target({PARAMETER, FIELD}) @Retention(RUNTIME) public @interface RestURI { + + /** + * 备注描述, 对应@HttpParam.comment + * + * @return String + */ + String comment() default ""; } diff --git a/src/org/redkale/net/http/RestUploadFile.java b/src/org/redkale/net/http/RestUploadFile.java index 388bc33ee..6d1b11566 100644 --- a/src/org/redkale/net/http/RestUploadFile.java +++ b/src/org/redkale/net/http/RestUploadFile.java @@ -45,4 +45,11 @@ public @interface RestUploadFile { * @return String */ String contentTypeReg() default ""; + + /** + * 备注描述, 对应@HttpParam.comment + * + * @return String + */ + String comment() default ""; }