@@ -21,6 +21,7 @@ package de.fhg.aisec.ids.rm
2121
2222import org.slf4j.Logger
2323import org.slf4j.LoggerFactory
24+ import org.springframework.beans.BeansException
2425import org.springframework.boot.context.event.ApplicationReadyEvent
2526import org.springframework.context.ApplicationContext
2627import 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