@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 |
AUTH_DB_PROPERTY
Name of the property holding the name of the database in which user is created.
|
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.
|
static String |
HOST_PROPERTY
Name of a property which holds host:port address of the mongodb instance.
|
static String |
PASSWORD_PROPERTY
Name of the property holding user password.
|
static String |
USERNAME_PROPERTY
Name of the property holding username.
|
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. |
Collection<String> |
resourceTypes()
Returns the list of possible values for
DataConnectionResource.type() ,
that will be returned when DataConnection.listResources() is called. |
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 static final String USERNAME_PROPERTY
public static final String PASSWORD_PROPERTY
public static final String HOST_PROPERTY
public static final String AUTH_DB_PROPERTY
admin
.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()
@Nonnull public Collection<String> resourceTypes()
DataConnection
DataConnectionResource.type()
,
that will be returned when DataConnection.listResources()
is called. Returned values are case-insensitive,
e.g. DataConnectionResource.type()
may return MY_RES
and this method my_res
.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.