Example usage for com.mongodb LazyDBCallback LazyDBCallback

List of usage examples for com.mongodb LazyDBCallback LazyDBCallback

Introduction

In this page you can find the example usage for com.mongodb LazyDBCallback LazyDBCallback.

Prototype

public LazyDBCallback(@Nullable final DBCollection collection) 

Source Link

Document

Construct an instance.

Usage

From source file:org.immutables.mongo.repository.internal.BsonEncoding.java

License:Apache License

public static DBObject unwrapJsonable(String json) {
    try {/*from  w  w w .ja va2s  .c o m*/
        JsonParser parser = JSON_FACTORY.createParser(json);
        parser.nextToken();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        BsonGenerator generator = BSON_FACTORY.createGenerator(outputStream);
        generator.copyCurrentStructure(parser);
        generator.close();
        parser.close();
        byte[] data = outputStream.toByteArray();
        return (DBObject) new LazyDBCallback(null).createObject(data, 0);
    } catch (IOException ex) {
        throw Throwables.propagate(ex);
    }
}