Browse Source

修改Gateway对应配置文件路径及LedgerSettings注册

tags/1.1.0
shaozhuguang 5 years ago
parent
commit
c849affc4f
3 changed files with 32 additions and 5 deletions
  1. +0
    -1
      source/deployment/deployment-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java
  2. +30
    -3
      source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java
  3. +2
    -1
      source/peer/src/main/java/com/jd/blockchain/peer/web/ManagementController.java

+ 0
- 1
source/deployment/deployment-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java View File

@@ -18,7 +18,6 @@ public class GatewayBooter {
writePID();
GatewayServerBooter.main(args);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Error!!! --[" + e.getClass().getName() + "] " + e.getMessage());
}
}


+ 30
- 3
source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java View File

@@ -2,6 +2,7 @@ package com.jd.blockchain.gateway;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -23,10 +24,14 @@ import com.jd.blockchain.utils.ConsoleUtils;
public class GatewayServerBooter {
private static final String DEFAULT_GATEWAY_PROPS = "application-gw.properties";
// 当前参与方在初始化配置中的参与方列表的编号;
private static final String HOST_ARG = "-c";
//sp;针对spring.config.location这个参数进行包装;
private static final String SPRING_CF_LOCATION = BaseConstant.SPRING_CF_LOCATION;
// 是否输出调试信息;
private static final String DEBUG_OPT = "-debug";
@@ -57,11 +62,20 @@ public class GatewayServerBooter {
}else {
//if no the config file, then should tip as follows. but it's not a good feeling, so we create it by inputStream;
ConsoleUtils.info("no param:-sp, format: -sp /x/xx.properties, use the default application-gw.properties ");
ClassPathResource configResource = new ClassPathResource("application-gw.properties");
ClassPathResource configResource = new ClassPathResource(DEFAULT_GATEWAY_PROPS);
InputStream in = configResource.getInputStream();
File targetFile = new File(System.getProperty("user.dir")+File.separator+"conf"+File.separator+"application-gw.properties");
// 将文件写入至config目录下
String configPath = bootPath() + "config" + File.separator + DEFAULT_GATEWAY_PROPS;
File targetFile = new File(configPath);
// 先将原来文件删除再Copy
if (targetFile.exists()) {
FileUtils.forceDelete(targetFile);
}
FileUtils.copyInputStreamToFile(in, targetFile);
springConfigLocation = "file:"+targetFile.getAbsolutePath();
springConfigLocation = "file:" + targetFile.getAbsolutePath();
}
// 启动服务器;
@@ -147,4 +161,17 @@ public class GatewayServerBooter {
return appCtx;
}
private static String bootPath() throws Exception {
URL url = GatewayServerBooter.class.getProtectionDomain().getCodeSource().getLocation();
String currPath = java.net.URLDecoder.decode(url.getPath(), "UTF-8");
// 处理打包至SpringBoot问题
if (currPath.contains("!/")) {
currPath = currPath.substring(5, currPath.indexOf("!/"));
}
if (currPath.endsWith(".jar")) {
currPath = currPath.substring(0, currPath.lastIndexOf("/") + 1);
}
System.out.printf("Current Project Boot Path = %s \r\n", currPath);
return new File(currPath).getParent() + File.separator;
}
}

+ 2
- 1
source/peer/src/main/java/com/jd/blockchain/peer/web/ManagementController.java View File

@@ -111,7 +111,8 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag
DataContractRegistry.register(BftsmartConsensusSettings.class);
DataContractRegistry.register(BftsmartNodeSettings.class);
// DataContractRegistry.register(LedgerAdminDataQuery.class);
DataContractRegistry.register(LedgerAdminInfo.class);
DataContractRegistry.register(LedgerSettings.class);
}


Loading…
Cancel
Save