public final class MongoClients
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static CodecRegistry |
DEFAULT_CODEC_REGISTRY |
Modifier | Constructor and Description |
---|---|
private |
MongoClients() |
Modifier and Type | Method and Description |
---|---|
static MongoClient |
create()
Creates a new client with the default connection string "mongodb://localhost".
|
static MongoClient |
create(ConnectionString connectionString)
Create a new client with the given connection string.
|
static MongoClient |
create(ConnectionString connectionString,
MongoDriverInformation mongoDriverInformation)
Create a new client with the given connection string.
|
static MongoClient |
create(MongoClientSettings settings)
Create a new client with the given client settings.
|
static MongoClient |
create(MongoClientSettings settings,
MongoDriverInformation mongoDriverInformation)
Creates a new client with the given client settings.
|
private static MongoClient |
create(MongoClientSettings settings,
MongoDriverInformation mongoDriverInformation,
java.lang.String requestedStreamType) |
static MongoClient |
create(java.lang.String connectionString)
Create a new client with the given connection string as if by a call to
create(ConnectionString) . |
(package private) static CommandListener |
createCommandListener(java.util.List<CommandListener> commandListeners) |
(package private) static MongoClient |
createMongoClient(MongoClientSettings settings,
MongoDriverInformation mongoDriverInformation,
StreamFactory streamFactory,
StreamFactory heartbeatStreamFactory,
java.io.Closeable externalResourceCloser) |
static CodecRegistry |
getDefaultCodecRegistry()
Gets the default codec registry.
|
private static StreamFactory |
getStreamFactory(StreamFactoryFactory streamFactoryFactory,
SocketSettings socketSettings,
SslSettings sslSettings,
java.lang.String streamType) |
private static java.lang.String |
getStreamType(java.lang.String requestedStreamType) |
private static boolean |
isNetty(java.lang.String streamType) |
private static boolean |
isNio2(java.lang.String streamType) |
private static final CodecRegistry DEFAULT_CODEC_REGISTRY
public static MongoClient create()
public static MongoClient create(MongoClientSettings settings)
settings
- the settingspublic static MongoClient create(java.lang.String connectionString)
create(ConnectionString)
.connectionString
- the connectioncreate(ConnectionString)
public static MongoClient create(ConnectionString connectionString)
For each of the settings classed configurable via MongoClientSettings
, the connection string is applied by calling the
applyConnectionString
method on an instance of setting's builder class, building the setting, and adding it to an instance of
MongoClientSettings.Builder
.
The connection string's stream type is then applied by setting the
StreamFactory
to an instance of NettyStreamFactory,
connectionString
- the settingsjava.lang.IllegalArgumentException
- if the connection string's stream type is not one of "netty" or "nio2"ConnectionString.getStreamType()
,
MongoClientSettings.Builder
,
ClusterSettings.Builder.applyConnectionString(ConnectionString)
,
ConnectionPoolSettings.Builder.applyConnectionString(ConnectionString)
,
ServerSettings.Builder.applyConnectionString(ConnectionString)
,
SslSettings.Builder.applyConnectionString(ConnectionString)
,
SocketSettings.Builder.applyConnectionString(ConnectionString)
public static MongoClient create(MongoClientSettings settings, MongoDriverInformation mongoDriverInformation)
Note: Intended for driver and library authors to associate extra driver metadata with the connections.
settings
- the settingsmongoDriverInformation
- any driver information to associate with the MongoClientpublic static MongoClient create(ConnectionString connectionString, MongoDriverInformation mongoDriverInformation)
Note: Intended for driver and library authors to associate extra driver metadata with the connections.
connectionString
- the settingsmongoDriverInformation
- any driver information to associate with the MongoClientjava.lang.IllegalArgumentException
- if the connection string's stream type is not one of "netty" or "nio2"create(ConnectionString)
private static MongoClient create(MongoClientSettings settings, MongoDriverInformation mongoDriverInformation, java.lang.String requestedStreamType)
static MongoClient createMongoClient(MongoClientSettings settings, MongoDriverInformation mongoDriverInformation, StreamFactory streamFactory, StreamFactory heartbeatStreamFactory, java.io.Closeable externalResourceCloser)
public static CodecRegistry getDefaultCodecRegistry()
MongoClientSettings.getCodecRegistry()
private static StreamFactory getStreamFactory(StreamFactoryFactory streamFactoryFactory, SocketSettings socketSettings, SslSettings sslSettings, java.lang.String streamType)
private static boolean isNetty(java.lang.String streamType)
private static boolean isNio2(java.lang.String streamType)
private static java.lang.String getStreamType(java.lang.String requestedStreamType)
static CommandListener createCommandListener(java.util.List<CommandListener> commandListeners)