mirror of
https://github.com/corda/corda.git
synced 2024-12-21 22:07:55 +00:00
Create a subclass of CordaCaplet for the web server to put the cordapp JARs on its class path.
This commit is contained in:
parent
3c13c07c09
commit
12f14275c0
@ -12,8 +12,8 @@ import java.util.*;
|
|||||||
|
|
||||||
public class CordaCaplet extends Capsule {
|
public class CordaCaplet extends Capsule {
|
||||||
|
|
||||||
private Config nodeConfig = null;
|
protected Config nodeConfig = null;
|
||||||
private String baseDir = null;
|
protected String baseDir = null;
|
||||||
|
|
||||||
protected CordaCaplet(Capsule pred) {
|
protected CordaCaplet(Capsule pred) {
|
||||||
super(pred);
|
super(pred);
|
||||||
@ -156,7 +156,7 @@ public class CordaCaplet extends Capsule {
|
|||||||
} else return super.attribute(attr);
|
} else return super.attribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void augmentClasspath(List<Path> classpath, File dir) {
|
protected void augmentClasspath(List<Path> classpath, File dir) {
|
||||||
try {
|
try {
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
// The following might return null if the directory is not there (we check this already) or if an I/O error occurs.
|
// The following might return null if the directory is not there (we check this already) or if an I/O error occurs.
|
||||||
@ -179,7 +179,7 @@ public class CordaCaplet extends Capsule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean checkIfCordappDirExists(File dir) {
|
protected Boolean checkIfCordappDirExists(File dir) {
|
||||||
try {
|
try {
|
||||||
if (!dir.mkdir() && !dir.exists()) { // It is unlikely to enter this if-branch, but just in case.
|
if (!dir.mkdir() && !dir.exists()) { // It is unlikely to enter this if-branch, but just in case.
|
||||||
logOnFailedCordappDir();
|
logOnFailedCordappDir();
|
||||||
|
25
node/src/main/java/CordaWebServerCaplet.java
Normal file
25
node/src/main/java/CordaWebServerCaplet.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CordaWebServerCaplet extends CordaCaplet {
|
||||||
|
protected CordaWebServerCaplet(Capsule pred) {
|
||||||
|
super(pred);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected <T> T attribute(Map.Entry<String, T> attr) {
|
||||||
|
T cp = super.attribute(attr);
|
||||||
|
if (ATTR_APP_CLASS_PATH == attr) {
|
||||||
|
File cordappsDir = new File(baseDir, "cordapps");
|
||||||
|
// Create cordapps directory if it doesn't exist.
|
||||||
|
if (checkIfCordappDirExists(cordappsDir)) {
|
||||||
|
// Add additional directories of JARs to the classpath (at the end), e.g., for JDBC drivers.
|
||||||
|
augmentClasspath((List<Path>) cp, cordappsDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
}
|
@ -38,7 +38,9 @@ task buildWebserverJar(type: FatCapsule, dependsOn: project(':node').tasks.jar)
|
|||||||
applicationSource = files(
|
applicationSource = files(
|
||||||
project(':webserver').configurations.runtimeClasspath,
|
project(':webserver').configurations.runtimeClasspath,
|
||||||
project(':webserver').tasks.jar,
|
project(':webserver').tasks.jar,
|
||||||
|
project(':node').sourceSets.main.java.outputDir.toString() + '/CordaWebServerCaplet.class',
|
||||||
project(':node').sourceSets.main.java.outputDir.toString() + '/CordaCaplet.class',
|
project(':node').sourceSets.main.java.outputDir.toString() + '/CordaCaplet.class',
|
||||||
|
project(':node').sourceSets.main.java.outputDir.toString() + '/CordaWebServerCaplet$1.class',
|
||||||
project(':node').sourceSets.main.java.outputDir.toString() + '/CordaCaplet$1.class',
|
project(':node').sourceSets.main.java.outputDir.toString() + '/CordaCaplet$1.class',
|
||||||
project(':node').buildDir.toString() + '/resources/main/reference.conf',
|
project(':node').buildDir.toString() + '/resources/main/reference.conf',
|
||||||
"$rootDir/config/dev/log4j2.xml",
|
"$rootDir/config/dev/log4j2.xml",
|
||||||
@ -52,7 +54,7 @@ task buildWebserverJar(type: FatCapsule, dependsOn: project(':node').tasks.jar)
|
|||||||
systemProperties['visualvm.display.name'] = 'Corda Webserver'
|
systemProperties['visualvm.display.name'] = 'Corda Webserver'
|
||||||
minJavaVersion = '1.8.0'
|
minJavaVersion = '1.8.0'
|
||||||
minUpdateVersion['1.8'] = java8_minUpdateVersion
|
minUpdateVersion['1.8'] = java8_minUpdateVersion
|
||||||
caplets = ['CordaCaplet']
|
caplets = ['CordaWebServerCaplet']
|
||||||
|
|
||||||
// JVM configuration:
|
// JVM configuration:
|
||||||
// - Constrain to small heap sizes to ease development on low end devices.
|
// - Constrain to small heap sizes to ease development on low end devices.
|
||||||
|
Loading…
Reference in New Issue
Block a user