Package com.netgrif.quartz.mongodb.db
Class InternalMongoConnector
- java.lang.Object
-
- com.netgrif.quartz.mongodb.db.InternalMongoConnector
-
- All Implemented Interfaces:
MongoConnector,java.io.Closeable,java.lang.AutoCloseable
public class InternalMongoConnector extends java.lang.Object implements MongoConnector
The implementation ofMongoConnectorthat owns the lifecycle ofMongoClient.
-
-
Constructor Summary
Constructors Constructor Description InternalMongoConnector(com.mongodb.WriteConcern writeConcern, java.lang.String uri, java.lang.String dbName)Constructs an instance ofInternalMongoConnectorfrom connection URI.InternalMongoConnector(com.mongodb.WriteConcern writeConcern, java.lang.String uri, java.lang.String dbName, com.mongodb.MongoClientSettings.Builder settingsBuilder)Constructs an instance ofInternalMongoConnectorfrom connection URI and option builder.InternalMongoConnector(com.mongodb.WriteConcern writeConcern, java.util.List<com.mongodb.ServerAddress> seeds, java.util.Optional<com.mongodb.MongoCredential> credentials, com.mongodb.MongoClientSettings.Builder settingsBuilder, java.lang.String dbName)Constructs an instance ofInternalMongoConnector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Quartz-mongodb will call this method when shutting down.com.mongodb.client.MongoCollection<org.bson.Document>getCollection(java.lang.String collectionName)Quartz-mongodb will call this method to get the instance ofMongoCollectionfor internal uses.
-
-
-
Constructor Detail
-
InternalMongoConnector
public InternalMongoConnector(com.mongodb.WriteConcern writeConcern, java.lang.String uri, java.lang.String dbName) throws org.quartz.SchedulerConfigExceptionConstructs an instance ofInternalMongoConnectorfrom connection URI.- Parameters:
writeConcern- instance ofWriteConcern. EachMongoCollectionproduced bygetCollection(String)will be configured with this write concern.uri- MongoDB connection URI.dbName- name of the database that will be used to produce collections.- Throws:
org.quartz.SchedulerConfigException- if failed to create instance of MongoClient.
-
InternalMongoConnector
public InternalMongoConnector(com.mongodb.WriteConcern writeConcern, java.lang.String uri, java.lang.String dbName, com.mongodb.MongoClientSettings.Builder settingsBuilder) throws org.quartz.SchedulerConfigExceptionConstructs an instance ofInternalMongoConnectorfrom connection URI and option builder.- Parameters:
writeConcern- instance ofWriteConcern. EachMongoCollectionproduced bygetCollection(String)will be configured with this write concern.uri- MongoDB connection URI.dbName- name of the database that will be used to produce collections.settingsBuilder- default settings builder.- Throws:
org.quartz.SchedulerConfigException- if failed to create instance of MongoClient.
-
InternalMongoConnector
public InternalMongoConnector(com.mongodb.WriteConcern writeConcern, java.util.List<com.mongodb.ServerAddress> seeds, java.util.Optional<com.mongodb.MongoCredential> credentials, com.mongodb.MongoClientSettings.Builder settingsBuilder, java.lang.String dbName) throws org.quartz.SchedulerConfigExceptionConstructs an instance ofInternalMongoConnector.- Parameters:
writeConcern- instance ofWriteConcern. EachMongoCollectionproduced bygetCollection(String)will be configured with this write concern.seeds- list of server addresses.credentials- credentials used to authenticate all connections.settingsBuilder- default settings builder.dbName- name of the database that will be used to produce collections.- Throws:
org.quartz.SchedulerConfigException- if failed to create instance of MongoClient.
-
-
Method Detail
-
getCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getCollection(java.lang.String collectionName)
Description copied from interface:MongoConnectorQuartz-mongodb will call this method to get the instance ofMongoCollectionfor internal uses. The collection is expected to be fully configured with correctWriteConcern.- Specified by:
getCollectionin interfaceMongoConnector- Parameters:
collectionName- collection name.- Returns:
- instance of
MongoCollection.
-
close
public void close()
Description copied from interface:MongoConnectorQuartz-mongodb will call this method when shutting down. Implementation can closeMongoClienthere.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceMongoConnector
-
-