diff --git a/constants.properties b/constants.properties index 4afc7061e4..bffdc995cc 100644 --- a/constants.properties +++ b/constants.properties @@ -8,7 +8,7 @@ # Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. # -gradlePluginsVersion=4.0.11 +gradlePluginsVersion=4.0.12 kotlinVersion=1.2.20 platformVersion=4 guavaVersion=21.0 diff --git a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProvider.kt b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProvider.kt index edb631ac4a..9cf30dec43 100644 --- a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProvider.kt +++ b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigFileProvider.kt @@ -12,7 +12,6 @@ package net.corda.node.internal.cordapp import com.typesafe.config.Config import com.typesafe.config.ConfigFactory -import net.corda.core.internal.cordapp.CordappConfigProvider import net.corda.core.utilities.loggerFor import java.io.File diff --git a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigProvider.kt b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigProvider.kt index c66616c80a..cf4e16242d 100644 --- a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigProvider.kt +++ b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigProvider.kt @@ -8,7 +8,7 @@ * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. */ -package net.corda.core.internal.cordapp +package net.corda.node.internal.cordapp import com.typesafe.config.Config diff --git a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappProviderImpl.kt b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappProviderImpl.kt index 66a50a439a..e015e57255 100644 --- a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappProviderImpl.kt +++ b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappProviderImpl.kt @@ -17,7 +17,6 @@ import net.corda.core.cordapp.Cordapp import net.corda.core.cordapp.CordappContext import net.corda.core.crypto.SecureHash import net.corda.core.internal.DEPLOYED_CORDAPP_UPLOADER -import net.corda.core.internal.cordapp.CordappConfigProvider import net.corda.core.internal.createCordappContext import net.corda.core.node.services.AttachmentId import net.corda.core.node.services.AttachmentStorage diff --git a/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt b/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt index 55aa56d509..7c160593f3 100644 --- a/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt +++ b/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt @@ -12,15 +12,12 @@ package net.corda.node.internal.cordapp import com.typesafe.config.Config import com.typesafe.config.ConfigFactory -import junit.framework.Assert.assertNull -import net.corda.core.internal.cordapp.CordappConfigProvider import net.corda.core.node.services.AttachmentStorage import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.internal.MockCordappConfigProvider import net.corda.testing.services.MockAttachmentStorage import org.assertj.core.api.Assertions.assertThat -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull +import org.junit.Assert.* import org.junit.Before import org.junit.Test import java.net.URL @@ -29,9 +26,9 @@ class CordappProviderImplTests { private companion object { val isolatedJAR = this::class.java.getResource("isolated.jar")!! // TODO: Cordapp name should differ from the JAR name - val isolatedCordappName = "isolated" + const val isolatedCordappName = "isolated" val emptyJAR = this::class.java.getResource("empty.jar")!! - val validConfig = ConfigFactory.parseString("key=value") + val validConfig: Config = ConfigFactory.parseString("key=value") val stubConfigProvider = object : CordappConfigProvider { override fun getConfigByName(name: String): Config = ConfigFactory.empty() @@ -87,7 +84,7 @@ class CordappProviderImplTests { @Test fun `test cordapp configuration`() { val configProvider = MockCordappConfigProvider() - configProvider.cordappConfigs.put(isolatedCordappName, validConfig) + configProvider.cordappConfigs[isolatedCordappName] = validConfig val loader = CordappLoader.createDevMode(listOf(isolatedJAR)) val provider = CordappProviderImpl(loader, configProvider, attachmentStore, whitelistedContractImplementations) diff --git a/samples/cordapp-configuration/README.md b/samples/cordapp-configuration/README.md index 651e8debc9..e8e35b8291 100644 --- a/samples/cordapp-configuration/README.md +++ b/samples/cordapp-configuration/README.md @@ -6,18 +6,18 @@ This sample shows a simple example of how to use per-cordapp configuration. It i * Gradle build file to show how to install your Cordapp configuration * A flow that consumes the Cordapp configuration -## Usage +To run from the command line in Unix: -To run the sample you must first build it from the project root with; +1. Run ``./gradlew samples:cordapp-configuration:deployNodes`` to create a set of configs and installs under + ``samples/cordapp-configuration/build/nodes`` +2. Run ``./samples/cordapp-configuration/build/nodes/runnodes`` to open up three new terminals with the three nodes +3. At the shell prompt for Bank A or Bank B run ``start net.corda.configsample.GetStringConfigFlow configKey: someStringValue``. + This will start the flow and read the `someStringValue` CorDapp config. - ./gradlew deployNodes - -This will deploy the node with the configuration installed. -The relevant section is the ``deployNodes`` task. +To run from the command line in Windows: -## Running - -* Windows: `build\nodes\runnodes` -* Mac/Linux: `./build/nodes/runnodes` - -Once the nodes have started up and show a prompt you can now run your flow. \ No newline at end of file +1. Run ``gradlew samples:cordapp-configuration:deployNodes`` to create a set of configs and installs under + ``samples\cordapp-configuration\build\nodes`` +2. Run ``samples\cordapp-configuration\build\nodes\runnodes`` to open up three new terminals with the three nodes +3. At the shell prompt for Bank A or Bank B run ``start net.corda.configsample.GetStringConfigFlow configKey: someStringValue``. + This will start the flow and read the `someStringValue` CorDapp config. diff --git a/samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/ConfigSampleFlow.kt b/samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/ConfigSampleFlow.kt deleted file mode 100644 index 88cbfc441e..0000000000 --- a/samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/ConfigSampleFlow.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * R3 Proprietary and Confidential - * - * Copyright (c) 2018 R3 Limited. All rights reserved. - * - * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. - * - * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. - */ - -package net.corda.configsample - -import net.corda.core.flows.FlowLogic - -class ConfigSampleFlow : FlowLogic() { - override fun call(): String { - val config = serviceHub.getAppContext().config - return config.getString("someStringValue") - } -} \ No newline at end of file diff --git a/samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/GetStringConfigFlow.kt b/samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/GetStringConfigFlow.kt new file mode 100644 index 0000000000..7fbbaeff77 --- /dev/null +++ b/samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/GetStringConfigFlow.kt @@ -0,0 +1,19 @@ +package net.corda.configsample + +import co.paralleluniverse.fibers.Suspendable +import net.corda.core.flows.FlowLogic +import net.corda.core.flows.StartableByRPC +import net.corda.core.utilities.ProgressTracker + +@StartableByRPC +class GetStringConfigFlow(private val configKey: String) : FlowLogic() { + object READING : ProgressTracker.Step("Reading config") + override val progressTracker = ProgressTracker(READING) + + @Suspendable + override fun call(): String { + progressTracker.currentStep = READING + val config = serviceHub.getAppContext().config + return config.getString(configKey) + } +} diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/internal/MockCordappConfigProvider.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/MockCordappConfigProvider.kt index a0ec3a4773..651ba4ee43 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/internal/MockCordappConfigProvider.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/internal/MockCordappConfigProvider.kt @@ -12,7 +12,7 @@ package net.corda.testing.internal import com.typesafe.config.Config import com.typesafe.config.ConfigFactory -import net.corda.core.internal.cordapp.CordappConfigProvider +import net.corda.node.internal.cordapp.CordappConfigProvider class MockCordappConfigProvider : CordappConfigProvider { val cordappConfigs = mutableMapOf ()