This commit is contained in:
Redkale
2018-11-29 13:54:14 +08:00
parent e4ea20cc5f
commit 33f89264a6
2 changed files with 24 additions and 7 deletions

View File

@@ -170,25 +170,29 @@ public class ServiceWatchService extends AbstractWatchService {
}
@RestMapping(name = "load", auth = false, comment = "动态增加Service")
public RetResult loadService(String type, @RestUploadFile(maxLength = 10 * 1024 * 1024, fileNameReg = "\\.jar$") byte[] jar) {
public RetResult loadService(@RestParam(name = "type", comment = "Service的类名") String type,
@RestUploadFile(maxLength = 10 * 1024 * 1024, fileNameReg = "\\.jar$") byte[] jar) {
//待开发
return RetResult.success();
}
@RestMapping(name = "reload", auth = false, comment = "重新加载Service")
public RetResult reloadService(String name, String type) {
public RetResult reloadService(@RestParam(name = "name", comment = "Service的资源名") String name,
@RestParam(name = "type", comment = "Service的类名") String type) {
//待开发
return RetResult.success();
}
@RestMapping(name = "stop", auth = false, comment = "动态停止Service")
public RetResult stopService(String name, String type) {
public RetResult stopService(@RestParam(name = "name", comment = "Service的资源名") String name,
@RestParam(name = "type", comment = "Service的类名") String type) {
//待开发
return RetResult.success();
}
@RestMapping(name = "find", auth = false, comment = "查找Service")
public RetResult find(String name, String type) {
public RetResult find(@RestParam(name = "name", comment = "Service的资源名") String name,
@RestParam(name = "type", comment = "Service的类名") String type) {
//待开发
return RetResult.success();
}

View File

@@ -5,9 +5,9 @@
*/
package org.redkale.boot.watch;
import java.io.IOException;
import java.io.*;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.*;
import javax.annotation.Resource;
import org.redkale.boot.Application;
import org.redkale.net.http.*;
@@ -16,6 +16,7 @@ import org.redkale.source.*;
import org.redkale.util.*;
/**
* WATCH服务, 操作DataSource源
*
* @author zhangjx
*/
@@ -31,13 +32,25 @@ public class SourceWatchService extends AbstractWatchService {
@Comment("PoolSource调用change方法失败")
public static final int RET_SOURCE_METHOD_INVOKE_NOT_EXISTS = 1605_0003;
@Resource(name = "APP_HOME")
protected File home;
@Resource
protected Application application;
@RestMapping(name = "change", auth = false, comment = "动态更改DataSource的配置")
public RetResult addNode(@RestParam(name = "name", comment = "DataSource的标识") final String name,
@RestParam(name = "properties", comment = "配置") final Properties properties) throws IOException {
@RestParam(name = "properties", comment = "配置") Properties properties,
@RestParam(name = "xmlpath", comment = "配置文件路径") String xmlpath) throws IOException {
if (name == null) return new RetResult(RET_WATCH_PARAMS_ILLEGAL, "not found param (name)");
if (properties == null && xmlpath != null) {
File f = new File(xmlpath);
if (!f.isFile()) f = new File(home, xmlpath);
if (!f.isFile()) return new RetResult(RET_WATCH_PARAMS_ILLEGAL, "not found file (" + xmlpath + ")");
FileInputStream in = new FileInputStream(f);
Map<String, Properties> map = DataSources.loadPersistenceXml(in);
properties = map.get(name);
}
if (properties == null) return new RetResult(RET_WATCH_PARAMS_ILLEGAL, "not found param (properties)");
DataSource source = null;
for (DataSource s : application.getDataSources()) {