Merge pull request #607 from corda/rog-webserver-index-plugin-tweak

Filter out the default node plugins as per request from Chris.
This commit is contained in:
Roger Willis 2017-04-28 14:54:52 +01:00 committed by GitHub
commit 9dde0db407
2 changed files with 36 additions and 28 deletions

View File

@ -24,10 +24,8 @@ import org.slf4j.LoggerFactory
import java.io.IOException import java.io.IOException
import java.io.Writer import java.io.Writer
import java.lang.reflect.InvocationTargetException import java.lang.reflect.InvocationTargetException
import java.util.ServiceLoader import java.util.*
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import javax.ws.rs.core.MediaType import javax.ws.rs.core.MediaType
class NodeWebServer(val config: WebServerConfig) { class NodeWebServer(val config: WebServerConfig) {
@ -160,7 +158,13 @@ class NodeWebServer(val config: WebServerConfig) {
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"))
val infoServlet = ServletHolder(CorDappInfoServlet(pluginRegistries, localRpc)) val filteredPlugins = pluginRegistries.filterNot {
it.javaClass.name.startsWith("net.corda.node.") ||
it.javaClass.name.startsWith("net.corda.core.") ||
it.javaClass.name.startsWith("net.corda.nodeapi.")
}
val infoServlet = ServletHolder(CorDappInfoServlet(filteredPlugins, localRpc))
addServlet(infoServlet, "") addServlet(infoServlet, "")
val container = ServletContainer(resourceConfig) val container = ServletContainer(resourceConfig)

View File

@ -23,6 +23,9 @@ class CorDappInfoServlet(val plugins: List<CordaPluginRegistry>, val rpc: CordaR
} }
body { body {
h2 { +"Installed CorDapps" } h2 { +"Installed CorDapps" }
if (plugins.isEmpty()) {
p { +"No installed custom CorDapps." }
} else {
plugins.forEach { plugin -> plugins.forEach { plugin ->
h3 { +plugin::class.java.name } h3 { +plugin::class.java.name }
if (plugin.requiredFlows.isNotEmpty()) { if (plugin.requiredFlows.isNotEmpty()) {
@ -61,6 +64,7 @@ class CorDappInfoServlet(val plugins: List<CordaPluginRegistry>, val rpc: CordaR
} }
} }
} }
}
data class Endpoint(val method: String, val uri: String, val text: String) data class Endpoint(val method: String, val uri: String, val text: String)