Example usage for com.mongodb MongoClientOptions.Builder dbEncoderFactory

List of usage examples for com.mongodb MongoClientOptions.Builder dbEncoderFactory

Introduction

In this page you can find the example usage for com.mongodb MongoClientOptions.Builder dbEncoderFactory.

Prototype

DBEncoderFactory dbEncoderFactory

To view the source code for com.mongodb MongoClientOptions.Builder dbEncoderFactory.

Click Source Link

Usage

From source file:com.github.nlloyd.hornofmongo.adaptor.Mongo.java

License:Open Source License

private void initMongoConnection() throws UnknownHostException {
    if ((innerMongo == null)) {
        MongoClientOptions.Builder builder = MongoClientOptions.builder();
        if (mongoOptions != null) {
            //Restore previous options
            builder.description(mongoOptions.description);
            builder.connectionsPerHost(mongoOptions.connectionsPerHost);
            builder.threadsAllowedToBlockForConnectionMultiplier(
                    mongoOptions.threadsAllowedToBlockForConnectionMultiplier);
            builder.maxWaitTime(mongoOptions.maxWaitTime);
            builder.connectTimeout(mongoOptions.connectTimeout);
            builder.socketTimeout(mongoOptions.socketTimeout);
            builder.socketKeepAlive(mongoOptions.socketKeepAlive);
        }//  w  w  w .jav  a2s  .c  om
        MongoClientOptions clientOptions = builder.dbEncoderFactory(HornOfMongoBSONEncoder.FACTORY).build();
        this.innerMongo = new com.mongodb.MongoClient(this.hosts, clientOptions);
        if (options != 0)
            this.innerMongo.setOptions(options);
    }
    if (mongoScope.useMongoShellWriteConcern())
        innerMongo.setWriteConcern(WriteConcern.UNACKNOWLEDGED);
}