Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
turns out that was a bad idea, or, the revenge of the FactoryFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
freels committed Dec 22, 2010
1 parent 838a829 commit 46dd7ab
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ import net.lag.logging.Logger

class SqlDatabaseTimeoutException(msg: String, val timeout: Duration) extends SQLException(msg)

class TimingOutDatabaseFactory(val databaseFactory: DatabaseFactory,
val poolSize: Int,
val queueSize: Int,
val openTimeout: Duration,
val maxConnections: Int) extends DatabaseFactory {
private val timeout = new FutureTimeout(poolSize, queueSize)
class TimingOutDatabaseFactory(
val databaseFactory: DatabaseFactory,
val poolSize: Int,
val queueSize: Int,
val openTimeout: Duration,
val maxConnections: Int)
extends DatabaseFactory {

private def newTimeoutPool() = new FutureTimeout(poolSize, queueSize)

def apply(dbhosts: List[String], dbname: String, username: String, password: String,
urlOptions: Map[String, String]) = {
val dbLabel = if (dbname != null) dbname else "(null)"

new TimingOutDatabase(databaseFactory(dbhosts, dbname, username, password, urlOptions),
dbhosts, dbLabel, timeout, openTimeout, maxConnections)
dbhosts, dbLabel, newTimeoutPool(), openTimeout, maxConnections)
}
}

Expand Down

0 comments on commit 46dd7ab

Please sign in to comment.