List of usage examples for com.mongodb MongoClient getDefaultCodecRegistry
public static CodecRegistry getDefaultCodecRegistry()
From source file:io.lumeer.storage.mongodb.MongoUtils.java
License:Open Source License
public static String convertBsonToJson(Bson object) { return object.toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry()).toJson(); }
From source file:io.mandrel.config.MongoConfiguration.java
License:Apache License
@Bean public Builder options() { CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(), CodecRegistries.fromCodecs(new LocalDateTimeCodec(), new HostAndPortCodec(), new LocalDateTimeCodec())); return MongoClientOptions.builder().codecRegistry(codecRegistry); }
From source file:io.sip3.tapir.twig.configuration.MongoConfiguration.java
License:Apache License
@Bean public CodecRegistry registry(Codec[] codecs) { return CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(), CodecRegistries.fromCodecs(codecs)); }
From source file:net.netzgut.integral.mongo.configuration.MongoConfigurationBuilder.java
License:Apache License
/** * Builds a {@link net.netzgut.integral.mongo.servics.MongoService} instance * based on the provided arguments / with senseful fallbacks *//* w w w . j a v a 2 s . co m*/ public MongoConfiguration build() { return new MongoConfiguration() { @Override public ServerAddress getServerAddress() { return new ServerAddress(MongoConfigurationBuilder.this.host, MongoConfigurationBuilder.this.port); } @Override public String getDatabaseName() { return MongoConfigurationBuilder.this.databaseName; } @Override public List<MongoCredential> getCredentials() { return MongoConfigurationBuilder.this.credentials; } @Override public MongoClientOptions getClientOptions() { if (MongoConfigurationBuilder.this.options == null) { Builder builder = MongoClientOptions.builder(); if (MongoConfigurationBuilder.this.serverMonitorListeners.isEmpty() == false) { MongoConfigurationBuilder.this.serverMonitorListeners .forEach(builder::addServerMonitorListener); } if (MongoConfigurationBuilder.this.codecs.isEmpty() == false) { CodecRegistry customRegistry = CodecRegistries .fromCodecs(MongoConfigurationBuilder.this.codecs); CodecRegistry defaultRegistry = MongoClient.getDefaultCodecRegistry(); CodecRegistry combinedRegistry = CodecRegistries.fromRegistries(customRegistry, defaultRegistry); builder.codecRegistry(combinedRegistry); } options(builder.build()); } return MongoConfigurationBuilder.this.options; } }; }
From source file:org.apache.beam.sdk.io.mongodb.FindQuery.java
License:Apache License
/** Convert the Bson filters into a BsonDocument via default encoding. */ static BsonDocument bson2BsonDocument(Bson filters) { return filters.toBsonDocument(BasicDBObject.class, MongoClient.getDefaultCodecRegistry()); }
From source file:org.bson.jvm.Bson.java
License:Apache License
/** * The codec registry to be used for {@link MongoClient}. The driver's * default codec registry will be appended after ours. * <p>/*w w w . j av a 2 s . c o m*/ * Note that the results of this method are cached, unlike * {@link #getCodecRegistry(CodecRegistry)}. * * @return The codec registry */ public static CodecRegistry getCodecRegistry() { BsonImplementation implementation = getImplementation(); CodecRegistry codecRegistry = codecRegistries.get(implementation); if (codecRegistry == null) { codecRegistry = getCodecRegistry(MongoClient.getDefaultCodecRegistry()); CodecRegistry existing = codecRegistries.putIfAbsent(implementation, codecRegistry); if (existing != null) codecRegistry = existing; } return codecRegistry; }
From source file:org.jongo.JongoNative.java
License:Apache License
private static CodecRegistry createCodecRegistry(Mapper mapper) { CodecRegistry defaultRegistry = MongoClient.getDefaultCodecRegistry(); CodecRegistry jongoRegistry = CodecRegistries.fromProviders(new BsonValueCodecProvider(), new JongoCodecProvider(mapper)); return CodecRegistries.fromRegistries(defaultRegistry, jongoRegistry); }
From source file:org.opencb.cellbase.lib.impl.GeneMongoDBAdaptor.java
License:Apache License
@Override public QueryResult nativeGet(Query query, QueryOptions options) { Bson bson = parseQuery(query);/* www .ja va 2 s . c o m*/ logger.debug("query: {}", bson.toBsonDocument(Document.class, MongoClient.getDefaultCodecRegistry()).toJson()); return mongoDBCollection.find(bson, options); }
From source file:org.opencb.cellbase.lib.impl.VariantMongoDBAdaptor.java
License:Apache License
@Override public QueryResult<Variant> get(Query query, QueryOptions options) { Bson bson = parseQuery(query);// w w w .j a v a2s. c o m // options.put(MongoDBCollection.SKIP_COUNT, true); // FIXME: patch to exclude annotation.additionalAttributes from the results - restore the call to the common // FIXME: addPrivateExcludeOptions as soon as the variation collection is updated with the new form of the // FIXME: additionalAttributes field options = addVariantPrivateExcludeOptions(options); // options = addPrivateExcludeOptions(options); logger.debug("query: {}", bson.toBsonDocument(Document.class, MongoClient.getDefaultCodecRegistry()).toJson()); return mongoDBCollection.find(bson, null, Variant.class, options); }
From source file:org.opencb.cellbase.lib.impl.VariantMongoDBAdaptor.java
License:Apache License
@Override public QueryResult nativeGet(Query query, QueryOptions options) { Bson bson = parseQuery(query);/* w w w .j a va 2 s.co m*/ // options.put(MongoDBCollection.SKIP_COUNT, true); logger.debug("query: {}", bson.toBsonDocument(Document.class, MongoClient.getDefaultCodecRegistry()).toJson()); return mongoDBCollection.find(bson, options); }