mirror of
https://github.com/corda/corda.git
synced 2024-12-26 16:11:12 +00:00
Merge remote-tracking branch 'open/master' into os-merge-1288f63
# Conflicts: # constants.properties # node/src/main/kotlin/net/corda/node/internal/cordapp/CordappConfigProvider.kt # samples/cordapp-configuration/src/main/kotlin/net/corda/configsample/ConfigSampleFlow.kt
This commit is contained in:
commit
b6d43c0204
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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.
|
||||
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.
|
||||
|
@ -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<String>() {
|
||||
override fun call(): String {
|
||||
val config = serviceHub.getAppContext().config
|
||||
return config.getString("someStringValue")
|
||||
}
|
||||
}
|
@ -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<String>() {
|
||||
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)
|
||||
}
|
||||
}
|
@ -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<String, Config> ()
|
||||
|
Loading…
Reference in New Issue
Block a user