@Beta public class MongoDataConnection extends DataConnectionBase
According to MongoClient
documentation, the client object is responsible for maintaining connection pool,
so this data connection just returns one, cached client.
Modifier and Type | Field and Description |
---|---|
static String |
CONNECTION_STRING_PROPERTY
Name of a property which holds connection string to the mongodb instance.
|
static String |
DATABASE_PROPERTY
Name of a property with a database name hint.
|
Constructor and Description |
---|
MongoDataConnection(DataConnectionConfig config)
Creates a new data connection based on given config.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Closes underlying client.
|
com.mongodb.client.MongoClient |
getClient()
Returns an instance of
MongoClient . |
String |
getDatabaseName()
Returns the database name hint.
|
List<DataConnectionResource> |
listResources()
Lists all MongoDB collections in all databases.
|
static DataConnectionConfig |
mongoDataConnectionConf(String name,
String connectionString)
Helper method to create new
MongoDataConnection with given name and connection string. |
getConfig, getName, release, retain
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
options
public static final String CONNECTION_STRING_PROPERTY
public static final String DATABASE_PROPERTY
listResources()
will return only collection from db with this
name, but client is not restricted to this database. It can be used to specify database to which SQL Mappings
will point.public MongoDataConnection(DataConnectionConfig config)
@Nonnull public com.mongodb.client.MongoClient getClient()
MongoClient
.
If client is DataConnectionConfig.isShared() and there will be still some usages of given client,
the MongoClient.close() method won't take an effect.public String getDatabaseName()
@Nonnull public List<DataConnectionResource> listResources()
public void destroy()
@Nonnull public static DataConnectionConfig mongoDataConnectionConf(String name, String connectionString)
MongoDataConnection
with given name and connection string.Copyright © 2023 Hazelcast, Inc.. All rights reserved.