File tree Expand file tree Collapse file tree
src/main/kotlin/co/statu/parsek Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import io.vertx.core.VertxOptions
1010import io.vertx.ext.web.Router
1111import io.vertx.kotlin.coroutines.CoroutineVerticle
1212import io.vertx.kotlin.coroutines.coAwait
13- import kotlinx.coroutines.runBlocking
1413import org.slf4j.LoggerFactory
1514import org.springframework.context.annotation.AnnotationConfigApplicationContext
1615
@@ -129,19 +128,11 @@ class Main : CoroutineVerticle() {
129128
130129 pluginManager.loadPlugins()
131130
132- logger.info(" Enabling plugins" )
133-
134- pluginManager.getPluginWrappers().forEach {
135- pluginManager.enablePlugin(it.pluginId)
136- }
137-
138131 pluginManager.startPlugins()
139132
140- runBlocking {
141- pluginManager.getActivePlugins().forEach {
142- it.onStart()
143- }
144- }
133+ logger.info(" Initializing plugins" )
134+
135+ pluginManager.initializePlugins()
145136 }
146137
147138 private fun initDependencyInjection () {
Original file line number Diff line number Diff line change @@ -114,4 +114,20 @@ class PluginManager(importPaths: List<Path>) : DefaultPluginManager(importPaths)
114114
115115 return super .disablePlugin(pluginId)
116116 }
117+
118+ fun getSortedPlugins (): List <PluginWrapper > {
119+ val resolver = DependencyResolver (versionManager)
120+ val result = resolver.resolve(plugins.values.map { it.descriptor })
121+ return result.sortedPlugins.map { plugins[it]!! }
122+ }
123+
124+ fun initializePlugins () {
125+ runBlocking {
126+ getSortedPlugins().forEach { wrapper ->
127+ if (wrapper.pluginState == PluginState .STARTED ) {
128+ (wrapper.plugin as ? ParsekPlugin )?.onStart()
129+ }
130+ }
131+ }
132+ }
117133}
Original file line number Diff line number Diff line change @@ -6,9 +6,7 @@ import co.statu.parsek.PluginManager
66import co.statu.parsek.ReleaseStage
77import co.statu.parsek.api.event.PluginEventListener
88import io.vertx.core.Vertx
9- import kotlinx.coroutines.Dispatchers
109import kotlinx.coroutines.runBlocking
11- import kotlinx.coroutines.withContext
1210import org.pf4j.Plugin
1311import org.pf4j.PluginState
1412import org.slf4j.Logger
@@ -88,17 +86,12 @@ abstract class ParsekPlugin : Plugin() {
8886 pluginEventManager.unRegister(this , eventListener)
8987 }
9088
91- @Deprecated(" Use onStart method." )
89+ @Deprecated(" Use onStart method." , level = DeprecationLevel . HIDDEN )
9290 override fun start () {
9391 }
9492
95- @Deprecated(" Use onStop method." )
93+ @Deprecated(" Use onStop method." , level = DeprecationLevel . HIDDEN )
9694 override fun stop () {
97- runBlocking {
98- withContext(Dispatchers .IO ) {
99- onStop()
100- }
101- }
10295 }
10396
10497 internal fun load () {
You can’t perform that action at this time.
0 commit comments