ext.spring.PersistenceSpringFactory.kt Maven / Gradle / Ivy
package ext.spring
import ext.spring.model.RyoDomaiState
import org.ryoframework.core.domain.adapter.IDomainInfraConfig
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.AutoConfigureOrder
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.Ordered
import javax.sql.DataSource
@Configuration
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnClass(DataSource::class, IDomainInfraConfig::class)
internal class PersistenceSpringFactory {
companion object {
private val logger = LoggerFactory.getLogger(PersistenceSpringFactory::class.java)
}
@Suppress("SpringJavaInjectionPointsAutowiringInspection")
@Bean
fun domainState(dataSource: DataSource, config: IDomainInfraConfig): RyoDomaiState {
logger.info("Exécution des migrations base de données.")
config.evolutions().apply(dataSource)
logger.info("Migrations appliquées.")
return RyoDomaiState()
}
}