org.bson.BsonDocumentWrapper Java Examples

The following examples show how to use org.bson.BsonDocumentWrapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoSourceTask.java    From mongo-kafka with Apache License 2.0 6 votes vote down vote up
/**
 * This method also is responsible for caching the {@code resumeAfter} value for the change
 * stream.
 */
private void setCachedResultAndResumeToken() {
  MongoChangeStreamCursor<ChangeStreamDocument<Document>> changeStreamCursor =
      getChangeStreamIterable(sourceConfig, mongoClient).cursor();
  ChangeStreamDocument<Document> firstResult = changeStreamCursor.tryNext();
  if (firstResult != null) {
    cachedResult =
        new BsonDocumentWrapper<>(
            firstResult,
            ChangeStreamDocument.createCodec(
                Document.class, MongoClientSettings.getDefaultCodecRegistry()));
  }
  cachedResumeToken =
      firstResult != null ? firstResult.getResumeToken() : changeStreamCursor.getResumeToken();
  changeStreamCursor.close();
}
 
Example #2
Source File: BsonUtils.java    From stitch-android-sdk with Apache License 2.0 4 votes vote down vote up
public static <T> BsonDocument documentToBsonDocument(
    final T document,
    final CodecRegistry codecRegistry
) {
  return BsonDocumentWrapper.asBsonDocument(document, codecRegistry);
}
 
Example #3
Source File: JsonObjectBsonAdapter.java    From vertx-mongo-client with Apache License 2.0 4 votes vote down vote up
@Override
public <C> BsonDocument toBsonDocument(Class<C> documentClass, CodecRegistry codecRegistry) {
  return new BsonDocumentWrapper<>(obj, codecRegistry.get(JsonObject.class));
}