public class MongoDbUri extends Object
The set of possible options is a combination of the standard
MongoDB URI options and the complete set of fields supported by the
MongoClientConfiguration
class. The driver uses the Java beans
standard to define the label for each field.
readTimeout
and the number of ticks is defined by
maxIdleTickCount
.maxPendingOperationsPerConnection
which can be used to control how
aggressively the driver will apply back pressure.waitQueueMultiple
this option does not make sense for
an asynchronous driver.UuidElement.UuidElement(String, byte, java.util.UUID)
and
UuidElement.LEGACY_UUID_SUBTTYPE
.
The current set of auto-mapped fields is listed below. See the linked documentation for details on the fields values.
autoDiscoverServers
connectionModel
connectTimeout
lockType
maxCachedStringEntries
maxCachedStringLength
maxConnectionCount
maxIdleTickCount
maxPendingOperationsPerConnection
maxSecondaryLag
minConnectionCount
readTimeout
reconnectTimeout
usingSoKeepalive
Any credentials, default read preference, and default durability will also be
determined via the URI. See the CredentialEditor
,
ReadPreferenceEditor
, and DurabilityEditor
for details
Modifier and Type | Field and Description |
---|---|
static String |
MONGODB_URI_PREFIX
The prefix for a MongoDB URI.
|
static String |
MONGODBS_URI_PREFIX
The prefix for a MongoDB URI that uses SSL.
|
Constructor and Description |
---|
MongoDbUri(String mongoDbUri)
Creates a new MongoDbUri.
|
Modifier and Type | Method and Description |
---|---|
String |
getDatabase()
Returns the database contained in the URI.
|
List<String> |
getHosts()
Returns the hosts contained in the URI.
|
String |
getOptions()
Returns the options contained in the URI.
|
Map<String,String> |
getParsedOptions()
Returns the options contained in the URI parsed into a map of token
values.
|
String |
getPassword()
Returns the password contained in the URI.
|
String |
getUserName()
Returns the user name contained in the URI.
|
List<String> |
getValuesFor(String field)
Returns the values for a single property.
|
static boolean |
isUri(String mongoDbUri)
Tests if the
mongoDbUri starts with the correct prefix to be a
MongoDB URI. |
boolean |
isUseSsl()
Returns true if the URL uses the "mongodbs://" prefix.
|
String |
toString() |
public static final String MONGODB_URI_PREFIX
public static final String MONGODBS_URI_PREFIX
public MongoDbUri(String mongoDbUri) throws IllegalArgumentException
mongoDbUri
- The configuration for the connection to MongoDB expressed as a
MongoDB URL.IllegalArgumentException
- If the mongoDbUri is not a properly formated MongoDB
style URL.public static boolean isUri(String mongoDbUri)
mongoDbUri
starts with the correct prefix to be a
MongoDB URI.mongoDbUri
- The presumed MongoDB URI.mongoDbUri
starts with
"mongodb://" of "mongodbs://".public String getDatabase()
public List<String> getHosts()
public String getOptions()
public Map<String,String> getParsedOptions()
public String getPassword()
null
.public String getUserName()
null
.public List<String> getValuesFor(String field)
field
- The field to return all values for.public boolean isUseSsl()
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.