com.driver733.mapstructfluent.ApplicationContextService.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of processor-spring Show documentation
Show all versions of processor-spring Show documentation
Generator of fluent extension functions for mapstruct mappers
package com.driver733.mapstructfluent
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
@Component
private class ApplicationContextService(
private val context: ApplicationContext
) {
companion object {
private lateinit var context: ApplicationContext
fun getBean(clazz: Class) = context.getBean(clazz)
}
@PostConstruct
fun initialize() {
Companion.context = context
}
}
fun Class.getBean() = ApplicationContextService.getBean(this)