use of com.jd.blockchain.tools.initializer.web.LedgerBindingConfigException in project jdchain-core by blockchain-jd-com.
the class PeerServerBooter method handle.
public static void handle(String[] args) {
LedgerBindingConfig ledgerBindingConfig = null;
ArgumentSet arguments = ArgumentSet.resolve(args, ArgumentSet.setting().prefix(LEDGERBIND_ARG, HOST_ARG, PORT_ARG, SPRING_CF_LOCATION));
try {
ArgumentSet.ArgEntry argLedgerBindConf = arguments.getArg(LEDGERBIND_ARG);
ledgerBindConfigFile = argLedgerBindConf == null ? null : argLedgerBindConf.getValue();
if (ledgerBindConfigFile == null) {
LOGGER.info("Load build-in default configuration ...");
ClassPathResource configResource = new ClassPathResource(LEDGER_BIND_CONFIG_NAME);
if (configResource.exists()) {
try (InputStream in = configResource.getInputStream()) {
ledgerBindingConfig = LedgerBindingConfig.resolve(in);
}
}
} else {
LOGGER.info("Load configuration,ledgerBindConfigFile position=" + ledgerBindConfigFile);
File file = new File(ledgerBindConfigFile);
if (file.exists()) {
try {
ledgerBindingConfig = LedgerBindingConfig.resolve(file);
} catch (LedgerBindingConfigException e) {
LOGGER.info("Load ledgerBindConfigFile content is empty !!!");
}
}
}
String host = null;
ArgumentSet.ArgEntry hostArg = arguments.getArg(HOST_ARG);
if (hostArg != null) {
host = hostArg.getValue();
}
int port = 0;
ArgumentSet.ArgEntry portArg = arguments.getArg(PORT_ARG);
if (portArg != null) {
try {
port = Integer.parseInt(portArg.getValue());
} catch (NumberFormatException e) {
// ignore NumberFormatException of port argument;
}
}
// spring config location;
String springConfigLocation = null;
ArgumentSet.ArgEntry spConfigLocation = arguments.getArg(SPRING_CF_LOCATION);
if (spConfigLocation != null) {
springConfigLocation = spConfigLocation.getValue();
}
PeerServerBooter booter = new PeerServerBooter(ledgerBindingConfig, host, port, springConfigLocation);
LOGGER.debug("PeerServerBooter's urls=" + Arrays.toString(((URLClassLoader) booter.getClass().getClassLoader()).getURLs()));
booter.start();
} catch (Exception e) {
LOGGER.error("Peer start error", e);
}
}
use of com.jd.blockchain.tools.initializer.web.LedgerBindingConfigException in project jdchain-core by blockchain-jd-com.
the class LedgerLoadTimer method loadLedgerBindingConfig.
private LedgerBindingConfig loadLedgerBindingConfig() throws Exception {
LedgerBindingConfig ledgerBindingConfig = null;
String ledgerBindConfigFile = PeerServerBooter.ledgerBindConfigFile;
LOGGER.debug("--- Load " + LEDGER_BIND_CONFIG_NAME + " path = {}", ledgerBindConfigFile == null ? "Default" : ledgerBindConfigFile);
if (ledgerBindConfigFile == null) {
ClassPathResource configResource = new ClassPathResource(LEDGER_BIND_CONFIG_NAME);
if (configResource.exists()) {
try (InputStream in = configResource.getInputStream()) {
ledgerBindingConfig = LedgerBindingConfig.resolve(in);
} catch (LedgerBindingConfigException e) {
LOGGER.debug("Load ledgerBindConfigFile content is empty !!!");
}
}
} else {
File file = new File(ledgerBindConfigFile);
if (file.exists()) {
try {
ledgerBindingConfig = LedgerBindingConfig.resolve(file);
} catch (LedgerBindingConfigException e) {
LOGGER.debug("Load ledgerBindConfigFile content is empty !!!");
}
}
}
return ledgerBindingConfig;
}
Aggregations