private <T> ListDatabasesIterable<T> createListDatabasesIterable(@Nullable final ClientSession clientSession, final Class<T> clazz) { return MongoIterables.listDatabasesOf(clientSession, clazz, getMongoClientOptions().getCodecRegistry(), ReadPreference.primary(), createOperationExecutor()); }
private <TResult> ChangeStreamIterable<TResult> createChangeStreamIterable(@Nullable final ClientSession clientSession, final List<? extends Bson> pipeline, final Class<TResult> resultClass) { MongoClientOptions clientOptions = getMongoClientOptions(); return MongoIterables.changeStreamOf(clientSession, "admin", clientOptions.getCodecRegistry(), clientOptions.getReadPreference(), clientOptions.getReadConcern(), createOperationExecutor(), pipeline, resultClass, ChangeStreamLevel.CLIENT); }
private DatastoreImpl(final Morphia morphia, final Mapper mapper, final MongoClient mongoClient, final MongoDatabase database) { this.morphia = morphia; this.mapper = mapper; this.mongoClient = mongoClient; this.database = database.withCodecRegistry(CodecRegistries.fromRegistries( mongoClient.getMongoClientOptions().getCodecRegistry(), MongoClientSettings.getDefaultCodecRegistry())); this.db = mongoClient.getDB(database.getName()); this.defConcern = mongoClient.getWriteConcern(); this.indexHelper = new IndexHelper(mapper, database); }
/** * @param databaseName the name of the database to retrieve * @return a {@code MongoDatabase} representing the specified database * @throws IllegalArgumentException if databaseName is invalid * @see MongoNamespace#checkDatabaseNameValidity(String) */ public MongoDatabase getDatabase(final String databaseName) { MongoClientOptions clientOptions = getMongoClientOptions(); return new MongoDatabaseImpl(databaseName, clientOptions.getCodecRegistry(), clientOptions.getReadPreference(), clientOptions.getWriteConcern(), clientOptions.getRetryWrites(), clientOptions.getReadConcern(), createOperationExecutor()); }
retryWrites = options.getRetryWrites(); readConcern = options.getReadConcern(); codecRegistry = options.getCodecRegistry(); serverSelector = options.getServerSelector(); sslEnabled = options.isSslEnabled();
public MongoDatabase getDatabase(final String databaseName) { MongoClientOptions clientOptions = getMongoClientOptions(); return new MongoDatabaseImpl(databaseName, clientOptions.getCodecRegistry(), clientOptions.getReadPreference(), clientOptions.getWriteConcern(), createOperationExecutor()); }
private <T> ListDatabasesIterable<T> createListDatabasesIterable(@Nullable final ClientSession clientSession, final Class<T> clazz) { return MongoIterables.listDatabasesOf(clientSession, clazz, getMongoClientOptions().getCodecRegistry(), ReadPreference.primary(), createOperationExecutor()); }
private <TResult> ChangeStreamIterable<TResult> createChangeStreamIterable(@Nullable final ClientSession clientSession, final List<? extends Bson> pipeline, final Class<TResult> resultClass) { MongoClientOptions clientOptions = getMongoClientOptions(); return MongoIterables.changeStreamOf(clientSession, "admin", clientOptions.getCodecRegistry(), clientOptions.getReadPreference(), clientOptions.getReadConcern(), createOperationExecutor(), pipeline, resultClass, ChangeStreamLevel.CLIENT); }
/** * Retrieves the database with the specified {@code name} on the {@code client}. * The database will be created if it does not already exist. * * @param client the MongoDB client, connected on the server * @param name the name of the database * * @return the database */ @Nonnull private MongoDatabase createDatabase(MongoClient client, String name) { final CodecRegistry registry = fromRegistries( client.getMongoClientOptions().getCodecRegistry(), fromProviders(PojoCodecProvider.builder().automatic(true).build())); return client.getDatabase(name) .withCodecRegistry(registry) .withWriteConcern(WriteConcern.MAJORITY) .withReadConcern(ReadConcern.MAJORITY); } }
/** * @param databaseName the name of the database to retrieve * @return a {@code MongoDatabase} representing the specified database * @throws IllegalArgumentException if databaseName is invalid * @see MongoNamespace#checkDatabaseNameValidity(String) */ public MongoDatabase getDatabase(final String databaseName) { MongoClientOptions clientOptions = getMongoClientOptions(); return new MongoDatabaseImpl(databaseName, clientOptions.getCodecRegistry(), clientOptions.getReadPreference(), clientOptions.getWriteConcern(), clientOptions.getRetryWrites(), clientOptions.getReadConcern(), createOperationExecutor()); }
retryWrites = options.getRetryWrites(); readConcern = options.getReadConcern(); codecRegistry = options.getCodecRegistry(); serverSelector = options.getServerSelector(); sslEnabled = options.isSslEnabled();