Incorporate comments from PR

This commit is contained in:
Matthew Nesbit
2016-07-28 16:30:53 +01:00
parent 601b2faf5f
commit a462bb1d6a
11 changed files with 17 additions and 38 deletions

View File

@ -4,20 +4,20 @@ package com.r3corda.core.node
* Implement this interface on a class advertised in a META-INF/services/com.r3corda.core.node.CordaPluginRegistry file * Implement this interface on a class advertised in a META-INF/services/com.r3corda.core.node.CordaPluginRegistry file
* to extend a Corda node with additional application services. * to extend a Corda node with additional application services.
*/ */
interface CordaPluginRegistry { abstract class CordaPluginRegistry {
/** /**
* List of JAX-RS classes inside the contract jar. They are expected to have a single parameter constructor that takes a ServiceHub as input. * List of JAX-RS classes inside the contract jar. They are expected to have a single parameter constructor that takes a ServiceHub as input.
* These are listed as Class<*>, because they will be instantiated inside an AttachmentClassLoader so that subsequent protocols, contracts, etc * These are listed as Class<*>, because in the future they will be instantiated inside a ClassLoader so that
* will be running in the appropriate isolated context. * Cordapp code can be loaded dynamically.
*/ */
val webApis: List<Class<*>> open val webApis: List<Class<*>> = emptyList()
/** /**
* Map of static serving endpoints to the matching resource directory. All endpoints will be prefixed with "/web" and postfixed with "\*. * Map of static serving endpoints to the matching resource directory. All endpoints will be prefixed with "/web" and postfixed with "\*.
* Resource directories can be either on disk directories (especially when debugging) in the form "a/b/c". Serving from a JAR can * Resource directories can be either on disk directories (especially when debugging) in the form "a/b/c". Serving from a JAR can
* be specified with: javaClass.getResource("<folder-in-jar>").toExternalForm() * be specified with: javaClass.getResource("<folder-in-jar>").toExternalForm()
*/ */
val staticServeDirs: Map<String, String> open val staticServeDirs: Map<String, String> = emptyMap()
/** /**
* A Map with an entry for each consumed protocol used by the webAPIs. * A Map with an entry for each consumed protocol used by the webAPIs.
@ -26,7 +26,7 @@ interface CordaPluginRegistry {
* Standard java.lang.* and kotlin.* types do not need to be included explicitly. * Standard java.lang.* and kotlin.* types do not need to be included explicitly.
* This is used to extend the white listed protocols that can be initiated from the ServiceHub invokeProtocolAsync method. * This is used to extend the white listed protocols that can be initiated from the ServiceHub invokeProtocolAsync method.
*/ */
val requiredProtocols: Map<String, Set<String>> open val requiredProtocols: Map<String, Set<String>> = emptyMap()
/** /**
* List of additional long lived services to be hosted within the node. * List of additional long lived services to be hosted within the node.
@ -34,5 +34,5 @@ interface CordaPluginRegistry {
* The ServiceHubInternal will be fully constructed before the plugin service is created and will * The ServiceHubInternal will be fully constructed before the plugin service is created and will
* allow access to the protocol factory and protocol initiation entry points there. * allow access to the protocol factory and protocol initiation entry points there.
*/ */
val servicePlugins: List<Class<*>> open val servicePlugins: List<Class<*>> = emptyList()
} }

View File

@ -117,7 +117,7 @@ abstract class Simulation(val networkSendManuallyPumped: Boolean,
return object : SimulatedNode(dir, cfg, network, networkMapAddr, advertisedServices, id, keyPair) { return object : SimulatedNode(dir, cfg, network, networkMapAddr, advertisedServices, id, keyPair) {
override fun start(): MockNetwork.MockNode { override fun start(): MockNetwork.MockNode {
super.start() super.start()
getCustomService<NodeInterestRates.Service>().upload(javaClass.getResourceAsStream("example.rates.txt")) findService<NodeInterestRates.Service>().upload(javaClass.getResourceAsStream("example.rates.txt"))
return this return this
} }
} }

View File

@ -9,10 +9,7 @@ import com.r3corda.protocols.NotaryChangeProtocol
object NotaryChange { object NotaryChange {
class Plugin : CordaPluginRegistry { class Plugin : CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val requiredProtocols: Map<String, Set<String>> = emptyMap()
override val staticServeDirs: Map<String, String> = emptyMap()
override val servicePlugins: List<Class<*>> = listOf(Service::class.java) override val servicePlugins: List<Class<*>> = listOf(Service::class.java)
} }

View File

@ -13,10 +13,7 @@ import com.r3corda.protocols.TwoPartyDealProtocol
* TODO: This will be replaced with the automatic sessionID / session setup work. * TODO: This will be replaced with the automatic sessionID / session setup work.
*/ */
object FixingSessionInitiation { object FixingSessionInitiation {
class Plugin: CordaPluginRegistry { class Plugin: CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val staticServeDirs: Map<String, String> = emptyMap()
override val requiredProtocols: Map<String, Set<String>> = emptyMap()
override val servicePlugins: List<Class<*>> = listOf(Service::class.java) override val servicePlugins: List<Class<*>> = listOf(Service::class.java)
} }

View File

@ -46,9 +46,7 @@ object NodeInterestRates {
/** /**
* Register the protocol that is used with the Fixing integration tests. * Register the protocol that is used with the Fixing integration tests.
*/ */
class Plugin : CordaPluginRegistry { class Plugin : CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val staticServeDirs: Map<String, String> = emptyMap()
override val requiredProtocols: Map<String, Set<String>> = mapOf(Pair(TwoPartyDealProtocol.FixingRoleDecider::class.java.name, setOf(Duration::class.java.name, StateRef::class.java.name))) override val requiredProtocols: Map<String, Set<String>> = mapOf(Pair(TwoPartyDealProtocol.FixingRoleDecider::class.java.name, setOf(Duration::class.java.name, StateRef::class.java.name)))
override val servicePlugins: List<Class<*>> = listOf(NodeInterestRates.Service::class.java) override val servicePlugins: List<Class<*>> = listOf(NodeInterestRates.Service::class.java)
} }

View File

@ -16,10 +16,7 @@ import javax.annotation.concurrent.ThreadSafe
object DataVending { object DataVending {
class Plugin : CordaPluginRegistry { class Plugin : CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val staticServeDirs: Map<String, String> = emptyMap()
override val requiredProtocols: Map<String, Set<String>> = emptyMap()
override val servicePlugins: List<Class<*>> = listOf(Service::class.java) override val servicePlugins: List<Class<*>> = listOf(Service::class.java)
} }

View File

@ -105,7 +105,7 @@ class NodeInterestRatesTest {
fun network() { fun network() {
val net = MockNetwork() val net = MockNetwork()
val (n1, n2) = net.createTwoNodes() val (n1, n2) = net.createTwoNodes()
n2.getCustomService<NodeInterestRates.Service>().oracle.knownFixes = TEST_DATA n2.findService<NodeInterestRates.Service>().oracle.knownFixes = TEST_DATA
val tx = TransactionType.General.Builder() val tx = TransactionType.General.Builder()
val fixOf = NodeInterestRates.parseFixOf("LIBOR 2016-03-16 1M") val fixOf = NodeInterestRates.parseFixOf("LIBOR 2016-03-16 1M")

View File

@ -257,14 +257,13 @@ object CliParamsSpec {
val help = parser.accepts("help", "Prints this help").forHelp() val help = parser.accepts("help", "Prints this help").forHelp()
} }
class IRSDemoPluginRegistry : CordaPluginRegistry { class IRSDemoPluginRegistry : CordaPluginRegistry() {
override val webApis: List<Class<*>> = listOf(InterestRateSwapAPI::class.java) override val webApis: List<Class<*>> = listOf(InterestRateSwapAPI::class.java)
override val staticServeDirs: Map<String, String> = mapOf("irsdemo" to javaClass.getResource("irswebdemo").toExternalForm()) override val staticServeDirs: Map<String, String> = mapOf("irsdemo" to javaClass.getResource("irswebdemo").toExternalForm())
override val requiredProtocols: Map<String, Set<String>> = mapOf( override val requiredProtocols: Map<String, Set<String>> = mapOf(
Pair(AutoOfferProtocol.Requester::class.java.name, setOf(InterestRateSwap.State::class.java.name)), Pair(AutoOfferProtocol.Requester::class.java.name, setOf(InterestRateSwap.State::class.java.name)),
Pair(UpdateBusinessDayProtocol.Broadcast::class.java.name, setOf(java.time.LocalDate::class.java.name)), Pair(UpdateBusinessDayProtocol.Broadcast::class.java.name, setOf(java.time.LocalDate::class.java.name)),
Pair(ExitServerProtocol.Broadcast::class.java.name, setOf(kotlin.Int::class.java.name))) Pair(ExitServerProtocol.Broadcast::class.java.name, setOf(kotlin.Int::class.java.name)))
override val servicePlugins: List<Class<*>> = emptyList()
} }
private class NotSetupException: Throwable { private class NotSetupException: Throwable {

View File

@ -28,10 +28,7 @@ object AutoOfferProtocol {
val notary: Party, val notary: Party,
val otherSessionID: Long, val dealBeingOffered: DealState) val otherSessionID: Long, val dealBeingOffered: DealState)
class Plugin: CordaPluginRegistry { class Plugin: CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val staticServeDirs: Map<String, String> = emptyMap()
override val requiredProtocols: Map<String, Set<String>> = emptyMap()
override val servicePlugins: List<Class<*>> = listOf(Service::class.java) override val servicePlugins: List<Class<*>> = listOf(Service::class.java)
} }

View File

@ -20,10 +20,7 @@ object ExitServerProtocol {
data class ExitMessage(val exitCode: Int) data class ExitMessage(val exitCode: Int)
class Plugin: CordaPluginRegistry { class Plugin: CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val staticServeDirs: Map<String, String> = emptyMap()
override val requiredProtocols: Map<String, Set<String>> = emptyMap()
override val servicePlugins: List<Class<*>> = listOf(Service::class.java) override val servicePlugins: List<Class<*>> = listOf(Service::class.java)
} }

View File

@ -21,10 +21,7 @@ object UpdateBusinessDayProtocol {
data class UpdateBusinessDayMessage(val date: LocalDate) data class UpdateBusinessDayMessage(val date: LocalDate)
class Plugin: CordaPluginRegistry { class Plugin: CordaPluginRegistry() {
override val webApis: List<Class<*>> = emptyList()
override val staticServeDirs: Map<String, String> = emptyMap()
override val requiredProtocols: Map<String, Set<String>> = emptyMap()
override val servicePlugins: List<Class<*>> = listOf(Service::class.java) override val servicePlugins: List<Class<*>> = listOf(Service::class.java)
} }