From 3f3e0e99730004695b5b428042306a768852832f Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Mon, 12 Feb 2018 14:00:25 +0000 Subject: [PATCH] Allows the webserver JAR used by each node in deployNodes to be configured. --- docs/source/changelog.rst | 3 +++ docs/source/generating-a-node.rst | 19 +++++++++++++++ .../src/main/kotlin/net/corda/plugins/Node.kt | 24 +++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index d5fbbcc6cc..d24525247e 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -183,6 +183,9 @@ UNRELEASED * Marked ``stateMachine`` on ``FlowLogic`` as ``CordaInternal`` to make clear that is it not part of the public api and is only for internal use +* Provided experimental support for specifying your own webserver to be used instead of the default development + webserver in ``Cordform`` using the ``webserverJar`` argument + * Created new ``StartedMockNode`` and ``UnstartedMockNode`` classes which are wrappers around our MockNode implementation that expose relevant methods for testing without exposing internals, create these using a ``MockNetwork``. diff --git a/docs/source/generating-a-node.rst b/docs/source/generating-a-node.rst index 99c5022344..68d000f68d 100644 --- a/docs/source/generating-a-node.rst +++ b/docs/source/generating-a-node.rst @@ -137,6 +137,25 @@ a single node to run the network map service, by putting its name in the ``netwo .. warning:: When adding nodes, make sure that there are no port clashes! +Specifying a custom webserver +----------------------------- +By default, any node listing a webport will use the default development webserver, which is not production-ready. You +can use your own webserver JAR instead by using the ``webserverJar`` argument in a ``Cordform`` ``node`` configuration +block: + +.. sourcecode:: groovy + + node { + name "O=PartyA,L=New York,C=US" + webPort 10005 + webserverJar "lib/my_webserver.jar" + } + +The webserver JAR will be copied into the node's ``build`` folder with the name ``corda-webserver.jar``. + +.. warning:: This is an experimental feature. There is currently no support for reading the webserver's port from the + node's ``node.conf`` file. + Running deployNodes ------------------- To create the nodes defined in our ``deployNodes`` task, run the following command in a terminal window from the root diff --git a/gradle-plugins/cordformation/src/main/kotlin/net/corda/plugins/Node.kt b/gradle-plugins/cordformation/src/main/kotlin/net/corda/plugins/Node.kt index 59f9a7f6f5..10c408cc71 100644 --- a/gradle-plugins/cordformation/src/main/kotlin/net/corda/plugins/Node.kt +++ b/gradle-plugins/cordformation/src/main/kotlin/net/corda/plugins/Node.kt @@ -38,9 +38,10 @@ class Node(private val project: Project) : CordformNode() { private set internal lateinit var containerName: String private set - internal var rpcSettings: RpcSettings = RpcSettings() private set + internal var webserverJar: String? = null + private set /** * Sets whether this node will use HTTPS communication. @@ -79,6 +80,17 @@ class Node(private val project: Project) : CordformNode() { config = config.withValue("sshd.port", ConfigValueFactory.fromAnyRef(sshdPort)) } + /** + * The webserver JAR to be used by this node. + * + * If not provided, the default development webserver is used. + * + * @param webserverJar The file path of the webserver JAR to use. + */ + fun webserverJar(webserverJar: String) { + this.webserverJar = webserverJar + } + internal fun build() { if (config.hasPath("webAddress")) { installWebserverJar() @@ -130,7 +142,15 @@ class Node(private val project: Project) : CordformNode() { * Installs the corda webserver JAR to the node directory */ private fun installWebserverJar() { - val webJar = Cordformation.verifyAndGetRuntimeJar(project, "corda-webserver") + // If no webserver JAR is provided, the default development webserver is used. + val webJar = if (webserverJar == null) { + project.logger.info("Using default development webserver.") + Cordformation.verifyAndGetRuntimeJar(project, "corda-webserver") + } else { + project.logger.info("Using custom webserver: $webserverJar.") + File(webserverJar) + } + project.copy { it.apply { from(webJar)