mirror of
https://github.com/corda/corda.git
synced 2025-02-21 01:42:24 +00:00
[CORDA-2303]: Fix issue with corda-webserver not looking for plugins in cordapp jars (#4390)
* Create seperate webserver caplet * Revert "Create seperate webserver caplet" This reverts commit 7e1f01d576ca80a27f09597d7e09f115c8db2998. * Make sure cordapps are scanned for web server plugins
This commit is contained in:
parent
e7d1306335
commit
bad7b9b187
@ -5,7 +5,10 @@ import io.netty.channel.unix.Errors
|
||||
import net.corda.client.jackson.JacksonSupport
|
||||
import net.corda.client.rpc.CordaRPCClient
|
||||
import net.corda.client.rpc.RPCException
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.internal.errors.AddressBindingException
|
||||
import net.corda.core.internal.exists
|
||||
import net.corda.core.internal.list
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.utilities.contextLogger
|
||||
import net.corda.webserver.WebServerConfig
|
||||
@ -27,9 +30,13 @@ import java.io.IOException
|
||||
import java.io.Writer
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.net.BindException
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
import java.nio.file.NoSuchFileException
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import kotlin.streams.toList
|
||||
|
||||
class NodeWebServer(val config: WebServerConfig) {
|
||||
private companion object {
|
||||
@ -204,9 +211,22 @@ class NodeWebServer(val config: WebServerConfig) {
|
||||
return connection.proxy
|
||||
}
|
||||
|
||||
/** Fetch WebServerPluginRegistry classes registered in META-INF/services/net.corda.webserver.services.WebServerPluginRegistry files that exist in the classpath */
|
||||
|
||||
private fun jarUrlsInDirectory(directory: Path): List<URL> {
|
||||
return if (!directory.exists()) {
|
||||
emptyList()
|
||||
} else {
|
||||
directory.list { paths ->
|
||||
// `toFile()` can't be used here...
|
||||
paths.filter { it.toString().endsWith(".jar") }.map { it.toUri().toURL() }.toList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Fetch WebServerPluginRegistry classes registered in META-INF/services/net.corda.webserver.services.WebServerPluginRegistry files that exist in the classpath or in cordapps */
|
||||
val pluginRegistries: List<WebServerPluginRegistry> by lazy {
|
||||
ServiceLoader.load(WebServerPluginRegistry::class.java).toList()
|
||||
val urls = jarUrlsInDirectory(config.baseDirectory / "cordapps").toTypedArray()
|
||||
ServiceLoader.load(WebServerPluginRegistry::class.java, URLClassLoader(urls, javaClass.classLoader)).toList()
|
||||
}
|
||||
|
||||
/** Used for useful info that we always want to show, even when not logging to the console */
|
||||
|
Loading…
x
Reference in New Issue
Block a user