Skip to content

Commit be93640

Browse files
authored
Merge pull request #91 from Fraunhofer-AISEC/fix-routes-overview
Show routes from dynamically loaded XMLs in UI
2 parents c92f29f + 10db7ac commit be93640

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/RouteManagerService.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,9 @@ class RouteManagerService : RouteManager {
170170
private val camelContexts: List<CamelContext>
171171
get() {
172172
return try {
173-
val contexts = ctx.getBeansOfType(CamelContext::class.java).values.toMutableList()
174-
175-
contexts.sortWith(Comparator.comparing { it.name })
176-
177-
return contexts
173+
val appContexts = ctx.getBeansOfType(CamelContext::class.java).values.toList()
174+
val watcherContexts = XmlDeployWatcher.getBeansOfType(CamelContext::class.java)
175+
return listOf(appContexts, watcherContexts).flatten().sortedBy { it.name }
178176
} catch (e: Exception) {
179177
LOG.warn("Cannot retrieve the list of Camel contexts.", e)
180178
emptyList()

ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/XmlDeployWatcher.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package de.fhg.aisec.ids.rm
2121

2222
import org.slf4j.Logger
2323
import org.slf4j.LoggerFactory
24+
import org.springframework.beans.BeansException
2425
import org.springframework.boot.context.event.ApplicationReadyEvent
2526
import org.springframework.context.ApplicationContext
2627
import org.springframework.context.ApplicationContextAware
@@ -44,8 +45,6 @@ class XmlDeployWatcher : ApplicationContextAware {
4445
this.applicationContext = applicationContext
4546
}
4647

47-
private val xmlContexts = mutableMapOf<String, CompletableFuture<AbstractXmlApplicationContext>>()
48-
4948
private fun startXmlApplicationContext(xmlPath: String) {
5049
LOG.info("XML file {} detected, creating XmlApplicationContext...", xmlPath)
5150
val xmlContextFuture: CompletableFuture<AbstractXmlApplicationContext> = CompletableFuture.supplyAsync {
@@ -150,6 +149,20 @@ class XmlDeployWatcher : ApplicationContextAware {
150149
}
151150

152151
companion object {
153-
val LOG: Logger = LoggerFactory.getLogger(XmlDeployWatcher::class.java)
152+
private val LOG: Logger = LoggerFactory.getLogger(XmlDeployWatcher::class.java)
153+
private val xmlContexts = mutableMapOf<String, CompletableFuture<AbstractXmlApplicationContext>>()
154+
155+
@Throws(BeansException::class)
156+
fun <T> getBeansOfType(type: Class<T>?): List<T> {
157+
return xmlContexts.values
158+
.mapNotNull {
159+
if (it.isDone) {
160+
it.get()
161+
} else {
162+
null
163+
}
164+
}
165+
.flatMap { it.getBeansOfType(type).values }
166+
}
154167
}
155168
}

0 commit comments

Comments
 (0)