Class InternalMongoConnector

  • All Implemented Interfaces:
    MongoConnector, java.io.Closeable, java.lang.AutoCloseable

    public class InternalMongoConnector
    extends java.lang.Object
    implements MongoConnector
    The implementation of MongoConnector that owns the lifecycle of MongoClient.
    • Constructor Summary

      Constructors 
      Constructor Description
      InternalMongoConnector​(com.mongodb.WriteConcern writeConcern, java.lang.String uri, java.lang.String dbName)
      Constructs an instance of InternalMongoConnector from connection URI.
      InternalMongoConnector​(com.mongodb.WriteConcern writeConcern, java.lang.String uri, java.lang.String dbName, com.mongodb.MongoClientSettings.Builder settingsBuilder)
      Constructs an instance of InternalMongoConnector from 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 of InternalMongoConnector.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      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 of MongoCollection for internal uses.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InternalMongoConnector

        public InternalMongoConnector​(com.mongodb.WriteConcern writeConcern,
                                      java.lang.String uri,
                                      java.lang.String dbName)
                               throws org.quartz.SchedulerConfigException
        Constructs an instance of InternalMongoConnector from connection URI.
        Parameters:
        writeConcern - instance of WriteConcern. Each MongoCollection produced by getCollection(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.SchedulerConfigException
        Constructs an instance of InternalMongoConnector from connection URI and option builder.
        Parameters:
        writeConcern - instance of WriteConcern. Each MongoCollection produced by getCollection(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.SchedulerConfigException
        Constructs an instance of InternalMongoConnector.
        Parameters:
        writeConcern - instance of WriteConcern. Each MongoCollection produced by getCollection(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: MongoConnector
        Quartz-mongodb will call this method to get the instance of MongoCollection for internal uses. The collection is expected to be fully configured with correct WriteConcern.
        Specified by:
        getCollection in interface MongoConnector
        Parameters:
        collectionName - collection name.
        Returns:
        instance of MongoCollection.
      • close

        public void close()
        Description copied from interface: MongoConnector
        Quartz-mongodb will call this method when shutting down. Implementation can close MongoClient here.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface MongoConnector