From 393323e082d66e50c0ed56dc6905a3aab70b0447 Mon Sep 17 00:00:00 2001 From: Clinton Date: Fri, 29 Sep 2017 13:25:49 +0100 Subject: [PATCH] Cordapps now have a name field. (#1664) Corrected cordapp name generation. Added changelog entry. --- core/src/main/kotlin/net/corda/core/cordapp/Cordapp.kt | 2 ++ .../main/kotlin/net/corda/core/internal/cordapp/CordappImpl.kt | 3 +++ docs/source/changelog.rst | 2 ++ node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt | 1 + 4 files changed, 8 insertions(+) diff --git a/core/src/main/kotlin/net/corda/core/cordapp/Cordapp.kt b/core/src/main/kotlin/net/corda/core/cordapp/Cordapp.kt index fcd9cea9cd..ea9557d7c9 100644 --- a/core/src/main/kotlin/net/corda/core/cordapp/Cordapp.kt +++ b/core/src/main/kotlin/net/corda/core/cordapp/Cordapp.kt @@ -13,6 +13,7 @@ import java.net.URL * * This will only need to be constructed manually for certain kinds of tests. * + * @property name Cordapp name - derived from the base name of the Cordapp JAR (therefore may not be unique) * @property contractClassNames List of contracts * @property initiatedFlows List of initiatable flow classes * @property rpcFlows List of RPC initiable flows classes @@ -23,6 +24,7 @@ import java.net.URL * @property jarPath The path to the JAR for this CorDapp */ interface Cordapp { + val name: String val contractClassNames: List val initiatedFlows: List>> val rpcFlows: List>> diff --git a/core/src/main/kotlin/net/corda/core/internal/cordapp/CordappImpl.kt b/core/src/main/kotlin/net/corda/core/internal/cordapp/CordappImpl.kt index f34f845091..8cfda77d42 100644 --- a/core/src/main/kotlin/net/corda/core/internal/cordapp/CordappImpl.kt +++ b/core/src/main/kotlin/net/corda/core/internal/cordapp/CordappImpl.kt @@ -5,6 +5,7 @@ import net.corda.core.flows.FlowLogic import net.corda.core.node.CordaPluginRegistry import net.corda.core.schemas.MappedSchema import net.corda.core.serialization.SerializeAsToken +import java.io.File import java.net.URL data class CordappImpl( @@ -16,6 +17,8 @@ data class CordappImpl( override val plugins: List, override val customSchemas: Set, override val jarPath: URL) : Cordapp { + override val name: String = File(jarPath.toURI()).name.removeSuffix(".jar") + /** * An exhaustive list of all classes relevant to the node within this CorDapp * diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 41c8195849..2355142bea 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -7,6 +7,8 @@ from the previous milestone release. UNRELEASED ---------- +* ``Cordapp`` now has a name field for identifying CorDapps and all CorDapp names are printed to console at startup. + Release 1.0 ----------- diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index 6fb990d27e..0b645a2c48 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -263,6 +263,7 @@ open class NodeStartup(val args: Array) { node.configuration.extraAdvertisedServiceIds.let { if (it.isNotEmpty()) Node.printBasicNodeInfo("Providing network services", it.joinToString()) } + Node.printBasicNodeInfo("Loaded CorDapps", node.cordappProvider.cordapps.map { it.name }.joinToString()) val plugins = node.pluginRegistries .map { it.javaClass.name } .filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") || it.startsWith("net.corda.nodeapi.") }