All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.komapper.r2dbc.R2dbcSessions.kt Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package org.komapper.r2dbc

import io.r2dbc.spi.ConnectionFactory
import org.komapper.core.LoggerFacade
import org.komapper.core.spi.findByPriority
import org.komapper.r2dbc.spi.R2dbcSessionFactory
import java.util.ServiceLoader

/**
 * The provider of [R2dbcSession].
 */
object R2dbcSessions {
    /**
     * @param connectionFactory the connection factory
     * @param loggerFacade the logger facade
     * @return the [R2dbcSession] instance.
     */
    fun get(connectionFactory: ConnectionFactory, loggerFacade: LoggerFacade): R2dbcSession {
        val loader = ServiceLoader.load(R2dbcSessionFactory::class.java)
        val factory = loader.findByPriority()
        return factory?.create(connectionFactory, loggerFacade) ?: DefaultR2dbcSession(connectionFactory)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy