Merge remote-tracking branch 'open/master' into mike-merge-4cfb1606da

This commit is contained in:
Mike Hearn 2018-04-25 10:43:23 +02:00
commit f99d16eebb
3 changed files with 59 additions and 14 deletions

View File

@ -82,6 +82,8 @@ absolute path to the node's base directory.
Currently the defaults in ``/node/src/main/resources/reference.conf`` are as shown in the first example. This is currently Currently the defaults in ``/node/src/main/resources/reference.conf`` are as shown in the first example. This is currently
the only configuration that has been tested, although in the future full support for other storage layers will be validated. the only configuration that has been tested, although in the future full support for other storage layers will be validated.
:h2port: A number that's used to pick the H2 JDBC server port. If not set a randomly chosen port will be used.
:messagingServerAddress: The address of the ArtemisMQ broker instance. If not provided the node will run one locally. :messagingServerAddress: The address of the ArtemisMQ broker instance. If not provided the node will run one locally.
:p2pAddress: The host and port on which the node is available for protocol operations over ArtemisMQ. :p2pAddress: The host and port on which the node is available for protocol operations over ArtemisMQ.

View File

@ -14,8 +14,6 @@
import com.typesafe.config.*; import com.typesafe.config.*;
import sun.misc.Signal; import sun.misc.Signal;
import sun.misc.SignalHandler;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -90,10 +88,12 @@ public class CordaCaplet extends Capsule {
if (ATTR_APP_CLASS_PATH == attr) { if (ATTR_APP_CLASS_PATH == attr) {
T cp = super.attribute(attr); T cp = super.attribute(attr);
(new File(baseDir, "cordapps")).mkdir(); File cordappsDir = new File(baseDir, "cordapps");
// Add additional directories of JARs to the classpath (at the end). e.g. for JDBC drivers // Create cordapps directory if it doesn't exist.
requireCordappsDirExists(cordappsDir);
// Add additional directories of JARs to the classpath (at the end), e.g., for JDBC drivers.
augmentClasspath((List<Path>) cp, new File(baseDir, "drivers")); augmentClasspath((List<Path>) cp, new File(baseDir, "drivers"));
augmentClasspath((List<Path>) cp, new File(baseDir, "cordapps")); augmentClasspath((List<Path>) cp, cordappsDir);
try { try {
List<String> jarDirs = nodeConfig.getStringList("jarDirs"); List<String> jarDirs = nodeConfig.getStringList("jarDirs");
log(LOG_VERBOSE, "Configured JAR directories = " + jarDirs); log(LOG_VERBOSE, "Configured JAR directories = " + jarDirs);
@ -139,24 +139,58 @@ public class CordaCaplet extends Capsule {
} }
private void augmentClasspath(List<Path> classpath, File dir) { private void augmentClasspath(List<Path> classpath, File dir) {
if (dir.exists()) { try {
File[] files = dir.listFiles(); if (dir.exists()) {
for (File file : files) { // The following might return null if the directory is not there (we check this already) or if an I/O error occurs.
for (File file : dir.listFiles()) {
addToClasspath(classpath, file);
}
} else {
log(LOG_VERBOSE, "Directory to add in Classpath was not found " + dir.getAbsolutePath());
}
} catch (SecurityException | NullPointerException e) {
log(LOG_QUIET, e);
}
}
private void requireCordappsDirExists(File dir) {
try {
if (!dir.mkdir() && !dir.exists()) { // It is unlikely to enter this if-branch, but just in case.
logOnFailedCordappDir();
throw new RuntimeException("Cordapps dir could not be created"); // Let Capsule handle the error (log error, clean up, die).
}
}
catch (SecurityException | NullPointerException e) {
logOnFailedCordappDir();
throw e; // Let Capsule handle the error (log error, clean up, die).
}
}
private void logOnFailedCordappDir() {
log(LOG_VERBOSE, "Cordapps dir could not be created");
}
private void addToClasspath(List<Path> classpath, File file) {
try {
if (file.canRead()) {
if (file.isFile() && isJAR(file)) { if (file.isFile() && isJAR(file)) {
classpath.add(file.toPath().toAbsolutePath()); classpath.add(file.toPath().toAbsolutePath());
} else if (file.isDirectory()) { // Search in nested folders as well. TODO: check for circular symlinks.
augmentClasspath(classpath, file);
} }
} else {
log(LOG_VERBOSE, "File or directory to add in Classpath could not be read " + file.getAbsolutePath());
} }
} catch (SecurityException | NullPointerException e) {
log(LOG_QUIET, e);
} }
} }
@Override @Override
protected void liftoff() { protected void liftoff() {
super.liftoff(); super.liftoff();
Signal.handle(new Signal("INT"), new SignalHandler() { Signal.handle(new Signal("INT"), signal -> {
@Override // Disable Ctrl-C for this process, so the child process can handle it in the shell instead.
public void handle(Signal signal) {
// Disable Ctrl-C for this process, so the child process can handle it in the shell instead.
}
}); });
} }

View File

@ -9,7 +9,7 @@
*/ */
buildscript { buildscript {
ext.tornadofx_version = '1.7.10' ext.tornadofx_version = '1.7.15'
ext.jna_version = '4.1.0' ext.jna_version = '4.1.0'
ext.purejavacomm_version = '0.0.18' ext.purejavacomm_version = '0.0.18'
ext.controlsfx_version = '8.40.12' ext.controlsfx_version = '8.40.12'
@ -49,6 +49,15 @@ repositories {
} }
} }
configurations.all {
resolutionStrategy {
// Force TornadoFX to use the same version of Kotlin as Corda.
force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
force "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
}
dependencies { dependencies {
// TornadoFX: A lightweight Kotlin framework for working with JavaFX UI's. // TornadoFX: A lightweight Kotlin framework for working with JavaFX UI's.
compile "no.tornado:tornadofx:$tornadofx_version" compile "no.tornado:tornadofx:$tornadofx_version"