Spring Data MongoDB - Core

org.springframework.data.mongodb.core
Class MongoOptionsFactoryBean

java.lang.Object
  extended by org.springframework.data.mongodb.core.MongoOptionsFactoryBean
All Implemented Interfaces:
FactoryBean<com.mongodb.MongoOptions>, InitializingBean

public class MongoOptionsFactoryBean
extends Object
implements FactoryBean<com.mongodb.MongoOptions>, InitializingBean

A factory bean for construction of a MongoOptions instance.

Author:
Graeme Rocher, Mark Pollack, Mike Saavedra, Thomas Darimont

Constructor Summary
MongoOptionsFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 com.mongodb.MongoOptions getObject()
           
 Class<?> getObjectType()
           
 boolean isSingleton()
           
 void setAutoConnectRetry(boolean autoConnectRetry)
          Configures whether or not the system retries automatically on a failed connect.
 void setConnectionsPerHost(int connectionsPerHost)
          Configures the maximum number of connections allowed per host until we will block.
 void setConnectTimeout(int connectTimeout)
          Configures the connect timeout in milliseconds.
 void setMaxAutoConnectRetryTime(long maxAutoConnectRetryTime)
          Configures the maximum amount of time in millisecons to spend retrying to open connection to the same server.
 void setMaxWaitTime(int maxWaitTime)
          Max wait time of a blocking thread for a connection.
 void setSlaveOk(boolean slaveOk)
          Specifies if the driver is allowed to read from secondaries or slaves.
 void setSocketKeepAlive(boolean socketKeepAlive)
          Configures whether or not to have socket keep alive turned on (SO_KEEPALIVE).
 void setSocketTimeout(int socketTimeout)
          Configures the socket timeout.
 void setSsl(boolean ssl)
          Specifies if the driver should use an SSL connection to Mongo.
 void setSslSocketFactory(SSLSocketFactory sslSocketFactory)
          Specifies the SSLSocketFactory to use for creating SSL connections to Mongo.
 void setThreadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier)
          A multiplier for connectionsPerHost for # of threads that can block a connection.
 void setWriteFsync(boolean writeFsync)
          Configures whether or not to fsync.
 void setWriteNumber(int writeNumber)
          This specifies the number of servers to wait for on the write operation, and exception raising behavior.
 void setWriteTimeout(int writeTimeout)
          Configures the timeout for write operations in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MongoOptionsFactoryBean

public MongoOptionsFactoryBean()
Method Detail

setConnectionsPerHost

public void setConnectionsPerHost(int connectionsPerHost)
Configures the maximum number of connections allowed per host until we will block.

Parameters:
connectionsPerHost -

setThreadsAllowedToBlockForConnectionMultiplier

public void setThreadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier)
A multiplier for connectionsPerHost for # of threads that can block a connection. If connectionsPerHost is 10, and threadsAllowedToBlockForConnectionMultiplier is 5, then 50 threads can block. If more threads try to block an exception will be thrown.

Parameters:
threadsAllowedToBlockForConnectionMultiplier -

setMaxWaitTime

public void setMaxWaitTime(int maxWaitTime)
Max wait time of a blocking thread for a connection.

Parameters:
maxWaitTime -

setConnectTimeout

public void setConnectTimeout(int connectTimeout)
Configures the connect timeout in milliseconds. Defaults to 0 (infinite time).

Parameters:
connectTimeout -

setSocketTimeout

public void setSocketTimeout(int socketTimeout)
Configures the socket timeout. Defaults to 0 (infinite time).

Parameters:
socketTimeout -

setSocketKeepAlive

public void setSocketKeepAlive(boolean socketKeepAlive)
Configures whether or not to have socket keep alive turned on (SO_KEEPALIVE). Defaults to false.

Parameters:
socketKeepAlive -

setWriteNumber

public void setWriteNumber(int writeNumber)
This specifies the number of servers to wait for on the write operation, and exception raising behavior. The 'w' option to the getlasterror command. Defaults to 0.

Parameters:
writeNumber - the number of servers to wait for on the write operation, and exception raising behavior.

setWriteTimeout

public void setWriteTimeout(int writeTimeout)
Configures the timeout for write operations in milliseconds. This defaults to 0 (indefinite).

Parameters:
writeTimeout -

setWriteFsync

public void setWriteFsync(boolean writeFsync)
Configures whether or not to fsync. The 'fsync' option to the getlasterror command. Defaults to false.

Parameters:
writeFsync - to fsync on write (true), otherwise false.

setAutoConnectRetry

public void setAutoConnectRetry(boolean autoConnectRetry)
Configures whether or not the system retries automatically on a failed connect. This defaults to false.


setMaxAutoConnectRetryTime

public void setMaxAutoConnectRetryTime(long maxAutoConnectRetryTime)
Configures the maximum amount of time in millisecons to spend retrying to open connection to the same server. This defaults to 0, which means to use the default 15s if autoConnectRetry is on.

Parameters:
maxAutoConnectRetryTime - the maxAutoConnectRetryTime to set

setSlaveOk

public void setSlaveOk(boolean slaveOk)
Specifies if the driver is allowed to read from secondaries or slaves. Defaults to false.

Parameters:
slaveOk - true if the driver should read from secondaries or slaves.

setSsl

public void setSsl(boolean ssl)
Specifies if the driver should use an SSL connection to Mongo. This defaults to false. By default SSLSocketFactory.getDefault() will be used. See setSslSocketFactory(SSLSocketFactory) if you want to configure a custom factory.

Parameters:
ssl - true if the driver should use an SSL connection.
See Also:
setSslSocketFactory(SSLSocketFactory)

setSslSocketFactory

public void setSslSocketFactory(SSLSocketFactory sslSocketFactory)
Specifies the SSLSocketFactory to use for creating SSL connections to Mongo. Defaults to SSLSocketFactory.getDefault(). Implicitly activates setSsl(boolean) if a non-null value is given.

Parameters:
sslSocketFactory - the sslSocketFactory to use.
See Also:
setSsl(boolean)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

getObject

public com.mongodb.MongoOptions getObject()
Specified by:
getObject in interface FactoryBean<com.mongodb.MongoOptions>

getObjectType

public Class<?> getObjectType()
Specified by:
getObjectType in interface FactoryBean<com.mongodb.MongoOptions>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean<com.mongodb.MongoOptions>

Spring Data MongoDB - Core

Copyright © 2011-2013-2014 Pivotal. All Rights Reserved.