Make the attachments demo IntelliJ run configs work again.

This commit is contained in:
Mike Hearn 2017-01-09 14:44:31 +01:00 committed by Clinton Alexander
parent 7c1ec7aa41
commit 477f109cba
4 changed files with 17 additions and 12 deletions

View File

@ -3,8 +3,8 @@
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="net.corda.attachmentdemo.AttachmentDemoKt" />
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar " />
<option name="PROGRAM_PARAMETERS" value="--role=RECIPIENT" />
<option name="WORKING_DIRECTORY" value="file://samples/attachment-demo" />
<option name="PROGRAM_PARAMETERS" value="--role=RECIPIENT --certificates=&quot;build/attachment-demo-nodes/Bank B/certificates&quot;" />
<option name="WORKING_DIRECTORY" value="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />

View File

@ -3,8 +3,8 @@
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="net.corda.attachmentdemo.AttachmentDemoKt" />
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar " />
<option name="PROGRAM_PARAMETERS" value="--role SENDER" />
<option name="WORKING_DIRECTORY" value="file://samples/attachment-demo" />
<option name="PROGRAM_PARAMETERS" value="--role SENDER --certificates=&quot;build/attachment-demo-nodes/Bank A/certificates&quot;" />
<option name="WORKING_DIRECTORY" value="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />

View File

@ -27,6 +27,7 @@ fun main(args: Array<String>) {
val parser = OptionParser()
val roleArg = parser.accepts("role").withRequiredArg().ofType(Role::class.java).required()
val certsPath = parser.accepts("certificates").withRequiredArg()
val options = try {
parser.parse(*args)
} catch (e: Exception) {
@ -40,14 +41,14 @@ fun main(args: Array<String>) {
Role.SENDER -> {
val host = HostAndPort.fromString("localhost:10004")
println("Connecting to sender node ($host)")
CordaRPCClient(host, sslConfigFor("nodea")).use("demo", "demo") {
CordaRPCClient(host, sslConfigFor("nodea", options.valueOf(certsPath))).use("demo", "demo") {
sender(this)
}
}
Role.RECIPIENT -> {
val host = HostAndPort.fromString("localhost:10006")
println("Connecting to the recipient node ($host)")
CordaRPCClient(host, sslConfigFor("nodeb")).use("demo", "demo") {
CordaRPCClient(host, sslConfigFor("nodeb", options.valueOf(certsPath))).use("demo", "demo") {
recipient(this)
}
}
@ -111,10 +112,10 @@ private fun printHelp(parser: OptionParser) {
// TODO: Take this out once we have a dedicated RPC port and allow SSL on it to be optional.
private fun sslConfigFor(nodename: String): NodeSSLConfiguration {
private fun sslConfigFor(nodename: String, certsPath: String?): NodeSSLConfiguration {
return object : NodeSSLConfiguration {
override val keyStorePassword: String = "cordacadevpass"
override val trustStorePassword: String = "trustpass"
override val certificatesPath: Path = Paths.get("build") / "nodes" / nodename / "certificates"
override val certificatesPath: Path = if (certsPath != null) Paths.get(certsPath) else Paths.get("build") / "nodes" / nodename / "certificates"
}
}

View File

@ -1,18 +1,22 @@
package net.corda.attachmentdemo
import net.corda.core.div
import net.corda.core.node.services.ServiceInfo
import net.corda.node.driver.driver
import net.corda.node.services.User
import net.corda.node.services.transactions.SimpleNotaryService
import java.nio.file.Paths
/**
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)
* Do not use in a production environment.
*/
fun main(args: Array<String>) {
driver(dsl = {
val demoUser = listOf(User("demo", "demo", setOf("StartFlow.net.corda.flows.FinalityFlow")))
driver(isDebug = true, driverDirectory = Paths.get("build") / "attachment-demo-nodes") {
startNode("Controller", setOf(ServiceInfo(SimpleNotaryService.Companion.type)))
startNode("Bank A")
startNode("Bank B")
startNode("Bank A", rpcUsers = demoUser)
startNode("Bank B", rpcUsers = demoUser)
waitForAllNodesToFinish()
}, isDebug = true)
}
}