mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +00:00
Fix IRS demo by allowing demos to optionally register JAX-RS classes on the node at construction time.
This commit is contained in:
parent
988e00099d
commit
6bdbc7925b
@ -1,7 +1,6 @@
|
|||||||
package core.node
|
package core.node
|
||||||
|
|
||||||
import api.Config
|
import api.Config
|
||||||
//import api.InterestRateSwapAPI
|
|
||||||
import api.ResponseFilter
|
import api.ResponseFilter
|
||||||
import com.codahale.metrics.JmxReporter
|
import com.codahale.metrics.JmxReporter
|
||||||
import com.google.common.net.HostAndPort
|
import com.google.common.net.HostAndPort
|
||||||
@ -45,11 +44,15 @@ class ConfigurationException(message: String) : Exception(message)
|
|||||||
* network map service, while bootstrapping a network.
|
* network map service, while bootstrapping a network.
|
||||||
* @param advertisedServices The services this node advertises. This must be a subset of the services it runs,
|
* @param advertisedServices The services this node advertises. This must be a subset of the services it runs,
|
||||||
* but nodes are not required to advertise services they run (hence subset).
|
* but nodes are not required to advertise services they run (hence subset).
|
||||||
|
* @param clientAPIs A list of JAX-RS annotated classes to register
|
||||||
|
* which will be used to register any extra client web interfaces the node requires for demos to use.
|
||||||
|
* Listed clientAPI classes are assumed to have to take a single APIServer constructor parameter
|
||||||
* @param clock The clock used within the node and by all protocols etc
|
* @param clock The clock used within the node and by all protocols etc
|
||||||
*/
|
*/
|
||||||
class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration,
|
class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration,
|
||||||
networkMapAddress: NodeInfo?, advertisedServices: Set<ServiceType>,
|
networkMapAddress: NodeInfo?,advertisedServices: Set<ServiceType>,
|
||||||
clock: Clock = Clock.systemUTC()) : AbstractNode(dir, configuration, networkMapAddress, advertisedServices, clock) {
|
clock: Clock = Clock.systemUTC(),
|
||||||
|
val clientAPIs: List<Class<*>> = listOf()) : AbstractNode(dir, configuration, networkMapAddress, advertisedServices, clock) {
|
||||||
companion object {
|
companion object {
|
||||||
/** The port that is used by default if none is specified. As you know, 31337 is the most elite number. */
|
/** The port that is used by default if none is specified. As you know, 31337 is the most elite number. */
|
||||||
val DEFAULT_PORT = 31337
|
val DEFAULT_PORT = 31337
|
||||||
@ -103,7 +106,15 @@ class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration
|
|||||||
resourceConfig.register(Config(services))
|
resourceConfig.register(Config(services))
|
||||||
resourceConfig.register(ResponseFilter())
|
resourceConfig.register(ResponseFilter())
|
||||||
resourceConfig.register(api)
|
resourceConfig.register(api)
|
||||||
//resourceConfig.register(InterestRateSwapAPI(api))
|
|
||||||
|
clientAPIs.forEach {
|
||||||
|
customAPI ->
|
||||||
|
val customAPI = customAPI.getConstructor(api.APIServer::class.java)
|
||||||
|
.newInstance(api)
|
||||||
|
resourceConfig.register(customAPI)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Give the app a slightly better name in JMX rather than a randomly generated one and enable JMX
|
// Give the app a slightly better name in JMX rather than a randomly generated one and enable JMX
|
||||||
resourceConfig.addProperties(mapOf(ServerProperties.APPLICATION_NAME to "node.api",
|
resourceConfig.addProperties(mapOf(ServerProperties.APPLICATION_NAME to "node.api",
|
||||||
ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED to "true"))
|
ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED to "true"))
|
||||||
|
@ -75,7 +75,9 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, networkMapId, advertisedServices, DemoClock()).start() }
|
val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, networkMapId,
|
||||||
|
advertisedServices, DemoClock(),
|
||||||
|
listOf(demos.api.InterestRateSwapAPI::class.java)).start() }
|
||||||
|
|
||||||
// TODO: This should all be replaced by the identity service being updated
|
// TODO: This should all be replaced by the identity service being updated
|
||||||
// as the network map changes.
|
// as the network map changes.
|
||||||
|
@ -78,7 +78,9 @@ fun main(args: Array<String>) {
|
|||||||
override val nearestCity: String = "Atlantis"
|
override val nearestCity: String = "Atlantis"
|
||||||
}
|
}
|
||||||
|
|
||||||
val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, networkMapAddress, advertisedServices).start() }
|
val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, networkMapAddress,
|
||||||
|
advertisedServices, DemoClock(),
|
||||||
|
listOf(demos.api.InterestRateSwapAPI::class.java)).start() }
|
||||||
|
|
||||||
val notary = node.services.networkMapCache.notaryNodes[0]
|
val notary = node.services.networkMapCache.notaryNodes[0]
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package demo.api
|
package demos.api
|
||||||
|
|
||||||
import api.*
|
import api.*
|
||||||
import contracts.InterestRateSwap
|
import contracts.InterestRateSwap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user