mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
Make ServiceLoader results for CordaPlugins a protected property on the AbstractNode
This commit is contained in:
parent
51ba0cc8dd
commit
1557a82992
@ -137,6 +137,10 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
|||||||
val networkMapRegistrationFuture: ListenableFuture<Unit>
|
val networkMapRegistrationFuture: ListenableFuture<Unit>
|
||||||
get() = _networkMapRegistrationFuture
|
get() = _networkMapRegistrationFuture
|
||||||
|
|
||||||
|
/** fetch CordaPluginRegistry classes registered in META-INF/services/com.r3corda.core.node.CordaPluginRegistry files that exist in the classpath */
|
||||||
|
protected val pluginRegistries: List<CordaPluginRegistry>
|
||||||
|
get() = ServiceLoader.load(CordaPluginRegistry::class.java).toList()
|
||||||
|
|
||||||
/** Set to true once [start] has been successfully called. */
|
/** Set to true once [start] has been successfully called. */
|
||||||
@Volatile var started = false
|
@Volatile var started = false
|
||||||
private set
|
private set
|
||||||
@ -188,8 +192,6 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initialiseProtocolLogicFactory(): ProtocolLogicRefFactory {
|
private fun initialiseProtocolLogicFactory(): ProtocolLogicRefFactory {
|
||||||
val serviceLoader = ServiceLoader.load(CordaPluginRegistry::class.java)
|
|
||||||
val pluginRegistries = serviceLoader.toList()
|
|
||||||
val protocolWhitelist = HashMap<String, Set<String>>()
|
val protocolWhitelist = HashMap<String, Set<String>>()
|
||||||
for (plugin in pluginRegistries) {
|
for (plugin in pluginRegistries) {
|
||||||
for (protocol in plugin.requiredProtocols) {
|
for (protocol in plugin.requiredProtocols) {
|
||||||
@ -200,6 +202,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
|||||||
return ProtocolLogicRefFactory(protocolWhitelist)
|
return ProtocolLogicRefFactory(protocolWhitelist)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run any tasks that are needed to ensure the node is in a correct state before running start()
|
* Run any tasks that are needed to ensure the node is in a correct state before running start()
|
||||||
*/
|
*/
|
||||||
|
@ -109,8 +109,6 @@ class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
|
|||||||
resourceConfig.register(ResponseFilter())
|
resourceConfig.register(ResponseFilter())
|
||||||
resourceConfig.register(api)
|
resourceConfig.register(api)
|
||||||
|
|
||||||
val serviceLoader = ServiceLoader.load(CordaPluginRegistry::class.java)
|
|
||||||
val pluginRegistries = serviceLoader.toList()
|
|
||||||
val webAPIsOnClasspath = pluginRegistries.flatMap { x -> x.webApis }
|
val webAPIsOnClasspath = pluginRegistries.flatMap { x -> x.webApis }
|
||||||
for (webapi in webAPIsOnClasspath) {
|
for (webapi in webAPIsOnClasspath) {
|
||||||
log.info("Add Plugin web API from attachment ${webapi.name}")
|
log.info("Add Plugin web API from attachment ${webapi.name}")
|
||||||
|
Loading…
Reference in New Issue
Block a user