mike_shysh
12/02/2019, 1:58 PMor it's enough just
object DBProvider {
private lateinit var dbSession: Session
fun getDBSession(): Session {
if (!::dbSession.isInitialized) {
dbSession = when (dbType) {
DBTypes.MYSQL.type -> MySqlSession(host = dbHost, port = dbPort).getSession()
DBTypes.ORACLE.type -> OracleSession(host = dbHost, port = dbPort).getSession()
else -> throw Exception("Unsupported DB type - $dbType.")
}
}
return dbSession
}
...