This commit is contained in:
Redkale
2017-05-30 16:42:10 +08:00
parent 6895b31ad0
commit b2e73d378c
8 changed files with 112 additions and 29 deletions

View File

@@ -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;
/**
* <p>
* 详情见: https://redkale.org
*
* @author zhangjx
*/
@RestService(name = "watch", repair = false)
public class AppWatchService implements WatchService {
@Resource
private Application application;
@Resource
private TransportFactory transportFactory;
}

View File

@@ -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;
/**
* <p>
* 详情见: 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();
}
}

View File

@@ -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;
/**
* <p>
* 详情见: 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();
}
}

View File

@@ -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);

View File

@@ -25,4 +25,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface RestAddress {
/**
* 备注描述, 对应&#64;HttpParam.comment
*
* @return String
*/
String comment() default "";
}

View File

@@ -25,4 +25,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface RestBody {
/**
* 备注描述, 对应&#64;HttpParam.comment
*
* @return String
*/
String comment() default "";
}

View File

@@ -23,4 +23,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({PARAMETER, FIELD})
@Retention(RUNTIME)
public @interface RestURI {
/**
* 备注描述, 对应&#64;HttpParam.comment
*
* @return String
*/
String comment() default "";
}

View File

@@ -45,4 +45,11 @@ public @interface RestUploadFile {
* @return String
*/
String contentTypeReg() default "";
/**
* 备注描述, 对应&#64;HttpParam.comment
*
* @return String
*/
String comment() default "";
}