List of usage examples for com.mongodb MongoClient getDefaultCodecRegistry
public static CodecRegistry getDefaultCodecRegistry()
From source file:com.shampan.db.codec.StatusCodec.java
public StatusCodec() { this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class); }
From source file:com.shampan.db.codec.UserCodec.java
public UserCodec() { this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class); }
From source file:com.shampan.db.codec.VideoCategoryCodec.java
public VideoCategoryCodec() { this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class); }
From source file:com.shampan.db.codec.VideoCodec.java
public VideoCodec() { this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class); }
From source file:com.torodb.testing.mongodb.docker.ShardedClusterMixin.java
License:Apache License
@Override public default void shardCollection(String dbName, String colName, Bson key) { BsonDocument keyAsBsonDoc = key.toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry()); getClient().getDatabase("admin").runCommand(new BsonDocument() .append("shardCollection", new BsonString(dbName + "." + colName)).append("key", keyAsBsonDoc)); }
From source file:de.anycook.db.drafts.mongo.Mongo.java
License:Open Source License
protected Mongo() { logger = LogManager.getLogger(getClass()); final CodecRegistry codecRegistry = CodecRegistries.fromRegistries( CodecRegistries.fromProviders(new DraftCodecProvider()), MongoClient.getDefaultCodecRegistry()); final MongoClientOptions options = MongoClientOptions.builder().codecRegistry(codecRegistry).build(); client = new MongoClient(new ServerAddress(), options); }
From source file:de.gwdg.europeanaqa.client.rest.DocumentTransformer.java
public DocumentTransformer(MongoDatabase mongoDb) { CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry()); codec = new DocumentCodec(codecRegistry, new BsonTypeClassMap()); this.mongoDb = mongoDb; }
From source file:DutyDatabase.DutyScheduleDB.java
License:Open Source License
/** * Creates a connection to a running MongoDB instance using the required codecs. *//*from ww w .j a v a2s . com*/ public DutyScheduleDB() { //Create codec registry with LocalDateCodec. CodecRegistry codecRegistry = CodecRegistries.fromRegistries( CodecRegistries.fromCodecs(new LocalDateCodec()), CodecRegistries.fromProviders(new RaCodecProvider(), new DutyBlockCodecProvider(), new ScheduledDutyCodecProvider()), MongoClient.getDefaultCodecRegistry()); MongoClientOptions options = MongoClientOptions.builder().codecRegistry(codecRegistry).build(); mongoClient = new MongoClient(new ServerAddress(), options); db = mongoClient.getDatabase("DutySchedulerDB"); }
From source file:io.dirigible.mongodb.jdbc.MongodbResultSet.java
License:Apache License
private void buildMetadata() throws SQLException { // if(this.rsMetadata==null) this.rsMetadata = new MongodbResultSetMetaData( this.stmnt.getConnection().unwrap(MongodbConnection.class).getCollectionName()); // if(this.rsMetadata.getColumnCount() < this.currentDoc.size()) this.rsMetadata.setColumnCount(this.currentDoc.size()); Set<Entry<String, BsonValue>> docEntries = this.currentDoc .toBsonDocument(this.currentDoc.getClass(), MongoClient.getDefaultCodecRegistry()).entrySet(); for (Entry<String, BsonValue> docEntry : docEntries) { // if(!this.rsMetadata.keys().containsKey(docEntry.getKey())){ this.rsMetadata.keys().put(docEntry.getKey(), docEntry.getValue().getBsonType()); // } }//from w w w . j a va 2 s . c om }
From source file:io.lumeer.storage.mongodb.MongoDbStorage.java
License:Open Source License
@Override public void connect(final List<StorageConnection> connections, final String database, final Boolean useSsl) { final List<ServerAddress> addresses = new ArrayList<>(); connections.forEach(c -> {/*from ww w. jav a 2 s .c om*/ addresses.add(new ServerAddress(c.getHost(), c.getPort())); }); MongoCredential credential = null; if (connections.size() > 0 && connections.get(0).getUserName() != null && !connections.get(0).getUserName().isEmpty()) { credential = MongoCredential.createScramSha1Credential(connections.get(0).getUserName(), database, connections.get(0).getPassword()); } final MongoClientOptions.Builder optionsBuilder = (new MongoClientOptions.Builder()).connectTimeout(30000); if (useSsl) { optionsBuilder.sslEnabled(true).socketFactory(NaiveTrustManager.getSocketFactory()) .sslInvalidHostNameAllowed(true); } final CodecRegistry defaultRegistry = MongoClient.getDefaultCodecRegistry(); final CodecRegistry codecRegistry = CodecRegistries.fromCodecs(new BigDecimalCodec(), new RoleCodec()); final CodecRegistry providersRegistry = CodecRegistries.fromProviders(new PermissionsCodecProvider(), new PermissionCodecProvider(), new QueryCodecProvider(), new ViewCodecProvider(), new AttributeCodecProvider(), new LinkInstanceCodecProvider(), new LinkTypeCodecProvider(), new UserCodecProvider(), new GroupCodecProvider(), new PaymentCodecProvider(), new CompanyContactCodedProvider(), new UserLoginEventCodecProvider(), new FeedbackCodecProvider()); final CodecRegistry registry = CodecRegistries.fromRegistries(defaultRegistry, codecRegistry, providersRegistry); if (credential != null) { this.mongoClient = new MongoClient(addresses, credential, optionsBuilder.codecRegistry(registry).build()); } else { this.mongoClient = new MongoClient(addresses, optionsBuilder.codecRegistry(registry).build()); } this.database = mongoClient.getDatabase(database); this.datastore = (AdvancedDatastore) morphia.createDatastore(this.mongoClient, database); }