mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
Install the finance module as a CorDapp into every DemoBench node. (#1290)
This commit is contained in:
parent
a2ede0fc73
commit
f364f3aaee
@ -93,28 +93,40 @@ distributions {
|
||||
contents {
|
||||
into('lib/linux') {
|
||||
from 'libs/linux'
|
||||
fileMode = 0555
|
||||
}
|
||||
into('lib/macosx') {
|
||||
from 'libs/macosx'
|
||||
fileMode = 0555
|
||||
}
|
||||
into('lib/win') {
|
||||
from 'libs/win'
|
||||
fileMode = 0555
|
||||
}
|
||||
from(project(':tools:explorer:capsule').tasks.buildExplorerJAR) {
|
||||
rename 'node-explorer-(.*)', 'node-explorer.jar'
|
||||
into 'explorer'
|
||||
fileMode = 0444
|
||||
}
|
||||
from(project(':node:capsule').tasks.buildCordaJAR) {
|
||||
rename 'corda-(.*)', 'corda.jar'
|
||||
into 'corda'
|
||||
fileMode = 0444
|
||||
}
|
||||
from(project(':webserver:webcapsule').tasks.buildWebserverJar) {
|
||||
rename 'corda-webserver-(.*)', 'corda-webserver.jar'
|
||||
into 'corda'
|
||||
fileMode = 0444
|
||||
}
|
||||
from(project(':finance').tasks.jar) {
|
||||
rename 'corda-finance-(.*)', 'corda-finance.jar'
|
||||
into 'plugins'
|
||||
fileMode = 0444
|
||||
}
|
||||
from(project(':samples:bank-of-corda-demo').jar) {
|
||||
rename 'bank-of-corda-demo-(.*)', 'bank-of-corda.jar'
|
||||
into 'plugins'
|
||||
fileMode = 0444
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package net.corda.demobench.plugin
|
||||
|
||||
import net.corda.core.internal.copyToDirectory
|
||||
import net.corda.core.internal.createDirectories
|
||||
import net.corda.core.internal.exists
|
||||
import net.corda.demobench.model.HasPlugins
|
||||
import net.corda.demobench.model.JVMConfig
|
||||
import net.corda.demobench.model.NodeConfig
|
||||
@ -7,32 +10,42 @@ import tornadofx.*
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.stream.Stream
|
||||
|
||||
class PluginController : Controller() {
|
||||
|
||||
private val jvm by inject<JVMConfig>()
|
||||
private val pluginDir: Path = jvm.applicationDir.resolve("plugins")
|
||||
private val bankOfCorda = pluginDir.resolve("bank-of-corda.jar").toFile()
|
||||
private val bankOfCorda: Path = pluginDir.resolve("bank-of-corda.jar")
|
||||
private val finance: Path = pluginDir.resolve("corda-finance.jar")
|
||||
|
||||
/**
|
||||
* Install any built-in plugins that this node requires.
|
||||
*/
|
||||
@Throws(IOException::class)
|
||||
fun populate(config: NodeConfig) {
|
||||
if (!config.pluginDir.exists()) {
|
||||
config.pluginDir.createDirectories()
|
||||
}
|
||||
if (finance.exists()) {
|
||||
finance.copyToDirectory(config.pluginDir, StandardCopyOption.REPLACE_EXISTING)
|
||||
log.info("Installed 'Finance' plugin")
|
||||
}
|
||||
// Nodes cannot issue cash unless they contain the "Bank of Corda" plugin.
|
||||
if (config.isCashIssuer && bankOfCorda.isFile) {
|
||||
bankOfCorda.copyTo(config.pluginDir.resolve(bankOfCorda.name).toFile(), overwrite = true)
|
||||
if (config.isCashIssuer && bankOfCorda.exists()) {
|
||||
bankOfCorda.copyToDirectory(config.pluginDir, StandardCopyOption.REPLACE_EXISTING)
|
||||
log.info("Installed 'Bank of Corda' plugin")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a stream of a node's non-built-it plugins.
|
||||
* Generates a stream of a node's non-built-in plugins.
|
||||
*/
|
||||
@Throws(IOException::class)
|
||||
fun userPluginsFor(config: HasPlugins): Stream<Path> = walkPlugins(config.pluginDir)
|
||||
.filter { bankOfCorda.name != it.fileName.toString() }
|
||||
.filter { !bankOfCorda.endsWith(it.fileName) }
|
||||
.filter { !finance.endsWith(it.fileName) }
|
||||
|
||||
private fun walkPlugins(pluginDir: Path): Stream<Path> {
|
||||
return if (Files.isDirectory(pluginDir))
|
||||
|
Loading…
x
Reference in New Issue
Block a user