Class ExternalMongoConnector

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

    public class ExternalMongoConnector
    extends java.lang.Object
    implements MongoConnector
    The implementation of MongoConnector that doesn't own the lifecycle of MongoClient.
    • 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

      • ExternalMongoConnector

        public ExternalMongoConnector​(com.mongodb.WriteConcern writeConcern,
                                      com.mongodb.client.MongoDatabase database)
        Constructs an instance of ExternalMongoConnector.
        Parameters:
        writeConcern - instance of WriteConcern. Each MongoCollection produced by getCollection(String) will be configured with this write concern.
        database - MongoDatabase instance. Will be used to produce collections.
      • ExternalMongoConnector

        public ExternalMongoConnector​(com.mongodb.client.MongoClient mongoClient,
                                      java.lang.String dbName)
      • ExternalMongoConnector

        public ExternalMongoConnector​(com.mongodb.WriteConcern writeConcern,
                                      com.mongodb.client.MongoClient mongoClient,
                                      java.lang.String dbName)
        Constructs an instance of ExternalMongoConnector.
        Parameters:
        writeConcern - instance of WriteConcern. Each MongoCollection produced by getCollection(String) will be configured with this write concern.
        mongoClient - instance of MongoClient.
        dbName - name of the database that will be used to produce collections.
    • 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