File tree 3 files changed +8
-7
lines changed
kofu/src/main/kotlin/org/springframework/fu/kofu
3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ internal annotation class KofuMarker
26
26
/* *
27
27
* Kofu DSL base class.
28
28
*
29
- * Make sure to invoke `super.initialize(context)` from [initialize] in inherited classes to get the context initialized.
29
+ * Make sure to invoke `super.initialize(context)` in inherited classes to get the context initialized.
30
30
*
31
31
* @author Sebastien Deleuze
32
32
*/
33
33
@KofuMarker
34
- abstract class AbstractDsl : ApplicationContextInitializer < GenericApplicationContext > {
34
+ abstract class AbstractDsl {
35
35
36
36
@PublishedApi
37
37
internal lateinit var context: GenericApplicationContext
@@ -58,8 +58,9 @@ abstract class AbstractDsl : ApplicationContextInitializer<GenericApplicationCon
58
58
}
59
59
}
60
60
61
- override fun initialize (context : GenericApplicationContext ) {
61
+ internal open fun initialize (context : GenericApplicationContext ) {
62
62
this .context = context
63
63
}
64
64
65
+ internal fun toInitializer () = ApplicationContextInitializer <GenericApplicationContext > { initialize(it) }
65
66
}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ open class ConfigurationDsl(private val dsl: ConfigurationDsl.() -> Unit): Abstr
36
36
* @see configuration
37
37
* @sample org.springframework.fu.kofu.samples.applicationDslWithConfiguration
38
38
*/
39
- fun enable (configuration : ApplicationContextInitializer < GenericApplicationContext > ) {
39
+ fun enable (configuration : AbstractDsl ) {
40
40
configuration.initialize(context)
41
41
}
42
42
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import org.springframework.context.support.GenericApplicationContext
11
11
* @see application
12
12
* @author Sebastien Deleuze
13
13
*/
14
- abstract class KofuApplication (private val initializer : ApplicationContextInitializer < GenericApplicationContext > ) {
14
+ abstract class KofuApplication (private val initializer : AbstractDsl ) {
15
15
16
16
private var customizer: (ApplicationDsl .() -> Unit )? = null
17
17
@@ -31,8 +31,8 @@ abstract class KofuApplication(private val initializer: ApplicationContextInitia
31
31
if (! profiles.isEmpty()) {
32
32
app.setAdditionalProfiles(* profiles.split(" ," ).map { it.trim() }.toTypedArray())
33
33
}
34
- app.addInitializers(initializer)
35
- if (customizer != null ) app.addInitializers(ApplicationDsl (customizer!! ))
34
+ app.addInitializers(initializer.toInitializer() )
35
+ if (customizer != null ) app.addInitializers(ApplicationDsl (customizer!! ).toInitializer() )
36
36
System .setProperty(" spring.backgroundpreinitializer.ignore" , " true" )
37
37
System .setProperty(" spring.main.lazy-initialization" , " true" )
38
38
return app.run (* args)
You can’t perform that action at this time.
0 commit comments