Permalink
Browse files

Updated MongoOptions to sync up with options provided in Java Driver.

  • Loading branch information...
1 parent 9d20d21 commit d0bd9d8ab0ea751e5e4261781eea7a925422b094 @bwmcadams bwmcadams committed May 29, 2012
Showing with 35 additions and 7 deletions.
  1. +35 −7 casbah-core/src/main/scala/MongoOptions.scala
View
42 casbah-core/src/main/scala/MongoOptions.scala
@@ -24,6 +24,10 @@ package com.mongodb.casbah
import scalaj.collection.Imports._
+import com.mongodb.{ DBCursor , DBCollection , DBDecoderFactory, DBEncoderFactory}
+
+import javax.net.SocketFactory
+
/**
* Helper class for creating MongoOptions instances
*
@@ -33,6 +37,7 @@ import scalaj.collection.Imports._
*/
object MongoOptions {
+ val Defaults = new MongoOptions()
/**
* Instantiate a new MongoOptions instance
*
@@ -46,13 +51,25 @@ object MongoOptions {
* @see ServerAddress
* @see MongoDBAddress
*/
- def apply(autoConnectRetry: Boolean = new MongoOptions().autoConnectRetry,
- connectionsPerHost: Int = new MongoOptions().connectionsPerHost,
- threadsAllowedToBlockForConnectionMultiplier: Int = new MongoOptions().threadsAllowedToBlockForConnectionMultiplier,
- maxWaitTime: Int = new MongoOptions().maxWaitTime,
- connectTimeout: Int = new MongoOptions().connectTimeout,
- socketTimeout: Int = new MongoOptions().socketTimeout,
- socketKeepAlive: Boolean = new MongoOptions().socketKeepAlive) = {
+ def apply(autoConnectRetry: Boolean = Defaults.autoConnectRetry,
+ connectionsPerHost: Int = Defaults.connectionsPerHost,
+ threadsAllowedToBlockForConnectionMultiplier: Int = Defaults.threadsAllowedToBlockForConnectionMultiplier,
+ maxWaitTime: Int = Defaults.maxWaitTime,
+ connectTimeout: Int = Defaults.connectTimeout,
+ socketTimeout: Int = Defaults.socketTimeout,
+ socketKeepAlive: Boolean = Defaults.socketKeepAlive,
+ maxAutoConnectRetryTime: Long = Defaults.maxAutoConnectRetryTime,
+ slaveOk: Boolean = Defaults.slaveOk,
+ safe: Boolean = Defaults.safe,
+ w: Int = Defaults.w,
+ wTimeout: Int = Defaults.wtimeout,
+ fsync: Boolean = Defaults.fsync,
+ j: Boolean = Defaults.j,
+ dbDecoderFactory: DBDecoderFactory = Defaults.dbDecoderFactory,
+ dbEncoderFactory: DBEncoderFactory = Defaults.dbEncoderFactory,
+ socketFactory: SocketFactory = Defaults.socketFactory,
+ description: String = Defaults.description
+ ) = {
val options = new MongoOptions;
options.autoConnectRetry = autoConnectRetry
@@ -62,6 +79,17 @@ object MongoOptions {
options.connectTimeout = connectTimeout
options.socketTimeout = socketTimeout
options.socketKeepAlive = socketKeepAlive
+ options.maxAutoConnectRetryTime = maxAutoConnectRetryTime
+ options.slaveOk = slaveOk
+ options.safe = safe
+ options.w = w
+ options.wtimeout = wTimeout
+ options.fsync = fsync
+ options.j = j
+ options.dbDecoderFactory = dbDecoderFactory
+ options.dbEncoderFactory = dbEncoderFactory
+ options.socketFactory = socketFactory
+ options.description = description
options
}

0 comments on commit d0bd9d8

Please sign in to comment.