/** * Gets a collection with a given name. * * @param name the name of the collection to return * @return the collection * @throws IllegalArgumentException if the name is invalid * @see MongoNamespace#checkCollectionNameValidity(String) */ public DBCollection getCollection(final String name) { DBCollection collection = collectionCache.get(name); if (collection != null) { return collection; } collection = new DBCollection(name, this, executor); if (mongo.getMongoClientOptions().getDbDecoderFactory() != DefaultDBDecoder.FACTORY) { collection.setDBDecoderFactory(mongo.getMongoClientOptions().getDbDecoderFactory()); } if (mongo.getMongoClientOptions().getDbEncoderFactory() != DefaultDBEncoder.FACTORY) { collection.setDBEncoderFactory(mongo.getMongoClientOptions().getDbEncoderFactory()); } DBCollection old = collectionCache.putIfAbsent(name, collection); return old != null ? old : collection; }
/** * Creates a new {@code MongoOptions} with the given options. This class is deprecated, use {@link com.mongodb.MongoClientOptions}. * * @param options the MongoClientOptions to copy values from into the new MongoOptions. * @deprecated use {@link com.mongodb.MongoClientOptions} */ @SuppressWarnings("deprecation") @Deprecated public MongoOptions(final MongoClientOptions options) { connectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); maxWaitTime = options.getMaxWaitTime(); connectTimeout = options.getConnectTimeout(); socketFactory = options.getSocketFactory(); socketTimeout = options.getSocketTimeout(); socketKeepAlive = options.isSocketKeepAlive(); readPreference = options.getReadPreference(); dbDecoderFactory = options.getDbDecoderFactory(); dbEncoderFactory = options.getDbEncoderFactory(); description = options.getDescription(); writeConcern = options.getWriteConcern(); alwaysUseMBeans = options.isAlwaysUseMBeans(); requiredReplicaSetName = options.getRequiredReplicaSetName(); }
requiredReplicaSetName = options.getRequiredReplicaSetName(); dbDecoderFactory = options.getDbDecoderFactory(); dbEncoderFactory = options.getDbEncoderFactory(); socketFactory = options.socketFactory; cursorFinalizerEnabled = options.isCursorFinalizerEnabled();
Assert.assertEquals(TestDBEncoderFactory.class, options.getDbEncoderFactory().getClass());
Assert.assertEquals(TestDBEncoderFactory.class, options.getDbEncoderFactory().getClass());
/** * Gets a collection with a given name. * * @param name the name of the collection to return * @return the collection * @throws IllegalArgumentException if the name is invalid * @see MongoNamespace#checkCollectionNameValidity(String) */ public DBCollection getCollection(final String name) { DBCollection collection = collectionCache.get(name); if (collection != null) { return collection; } collection = new DBCollection(name, this, executor); if (mongo.getMongoClientOptions().getDbDecoderFactory() != DefaultDBDecoder.FACTORY) { collection.setDBDecoderFactory(mongo.getMongoClientOptions().getDbDecoderFactory()); } if (mongo.getMongoClientOptions().getDbEncoderFactory() != DefaultDBEncoder.FACTORY) { collection.setDBEncoderFactory(mongo.getMongoClientOptions().getDbEncoderFactory()); } DBCollection old = collectionCache.putIfAbsent(name, collection); return old != null ? old : collection; }
/** * Creates a new {@code MongoOptions} with the given options. This class is deprecated, use {@link com.mongodb.MongoClientOptions}. * * @param options the MongoClientOptions to copy values from into the new MongoOptions. * @deprecated use {@link com.mongodb.MongoClientOptions} */ @SuppressWarnings("deprecation") @Deprecated public MongoOptions(final MongoClientOptions options) { connectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); maxWaitTime = options.getMaxWaitTime(); connectTimeout = options.getConnectTimeout(); socketFactory = options.getSocketFactory(); socketTimeout = options.getSocketTimeout(); socketKeepAlive = options.isSocketKeepAlive(); readPreference = options.getReadPreference(); dbDecoderFactory = options.getDbDecoderFactory(); dbEncoderFactory = options.getDbEncoderFactory(); description = options.getDescription(); writeConcern = options.getWriteConcern(); alwaysUseMBeans = options.isAlwaysUseMBeans(); requiredReplicaSetName = options.getRequiredReplicaSetName(); }
requiredReplicaSetName = options.getRequiredReplicaSetName(); dbDecoderFactory = options.getDbDecoderFactory(); dbEncoderFactory = options.getDbEncoderFactory(); socketFactory = options.socketFactory; cursorFinalizerEnabled = options.isCursorFinalizerEnabled();