Make ServiceLoader results for CordaPlugins a protected property on the AbstractNode

This commit is contained in:
Matthew Nesbit 2016-07-07 13:55:15 +01:00
parent 51ba0cc8dd
commit 1557a82992
2 changed files with 5 additions and 4 deletions

View File

@ -137,6 +137,10 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
val networkMapRegistrationFuture: ListenableFuture<Unit>
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. */
@Volatile var started = false
private set
@ -188,8 +192,6 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
}
private fun initialiseProtocolLogicFactory(): ProtocolLogicRefFactory {
val serviceLoader = ServiceLoader.load(CordaPluginRegistry::class.java)
val pluginRegistries = serviceLoader.toList()
val protocolWhitelist = HashMap<String, Set<String>>()
for (plugin in pluginRegistries) {
for (protocol in plugin.requiredProtocols) {
@ -200,6 +202,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
return ProtocolLogicRefFactory(protocolWhitelist)
}
/**
* Run any tasks that are needed to ensure the node is in a correct state before running start()
*/

View File

@ -109,8 +109,6 @@ class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
resourceConfig.register(ResponseFilter())
resourceConfig.register(api)
val serviceLoader = ServiceLoader.load(CordaPluginRegistry::class.java)
val pluginRegistries = serviceLoader.toList()
val webAPIsOnClasspath = pluginRegistries.flatMap { x -> x.webApis }
for (webapi in webAPIsOnClasspath) {
log.info("Add Plugin web API from attachment ${webapi.name}")