Example usage for com.mongodb MongoClient getDefaultCodecRegistry

List of usage examples for com.mongodb MongoClient getDefaultCodecRegistry

Introduction

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

Prototype

public static CodecRegistry getDefaultCodecRegistry() 

Source Link

Document

Gets the default codec registry.

Usage

From source file:com.navercorp.pinpoint.plugin.mongo.interceptor.MongoCUDSessionInterceptor.java

License:Apache License

@Override
protected void prepareAfterTrace(Object target, Object[] args, Object result, Throwable throwable) {

    if (collectJson) {
        final boolean success = InterceptorUtils.isSuccess(throwable);
        if (success) {
            if (args != null) {
                StringBuilder bson = new StringBuilder();
                ParsingResult parsingResult;

                for (Object arg : args) {

                    if (bson.length() != 0) {
                        bson.append(", ");
                    }/*from  w ww .  j  a v a  2  s  .c o  m*/

                    if (arg instanceof Bson) {
                        if (arg instanceof BasicDBObject) {
                            bson.append(((BasicDBObject) arg).toJson());
                        } else if (arg instanceof BsonDocument) {
                            bson.append(((BsonDocument) arg).toJson());
                        } else if (arg instanceof Document) {
                            bson.append(((Document) arg).toJson());
                        } else {
                            bson.append(((Bson) arg)
                                    .toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry())
                                    .toJson());
                        }
                        //TODO leave comments for further use
                        //                        if(arg instanceof BsonDocumentWrapper) {
                        //                            bson.append(arg.toString());
                        //                        }
                        //                        if(arg instanceof CommandResult) {
                        //                            bson.append(arg.toString());
                        //                        }
                        //                        if(arg instanceof RawBsonDocument) {
                        //                            bson.append(arg.toString());
                        //                        }
                    }
                }
                parsingResult = traceContext.parseJson(bson.toString());

                if (parsingResult != null) {
                    ((ParsingResultAccessor) target)._$PINPOINT$_setParsingResult(parsingResult);
                } else {
                    if (logger.isErrorEnabled()) {
                        logger.error("sqlParsing fail. parsingResult is null bson:{}", bson);
                    }
                }
            }
        }
    }
}

From source file:com.navercorp.pinpoint.plugin.mongo.interceptor.MongoRSessionInterceptor.java

License:Apache License

@Override
protected void prepareAfterTrace(Object target, Object[] args, Object result, Throwable throwable) {
    if (collectJson) {
        final boolean success = InterceptorUtils.isSuccess(throwable);
        if (success) {
            if (args != null) {
                StringBuilder bson = new StringBuilder();
                ParsingResult parsingResult;

                for (Object arg : args) {
                    if (bson.length() != 0) {
                        bson.append(", ");
                    }/* w  w w.jav a  2 s .  c  o  m*/

                    if (arg instanceof Bson) {
                        if (arg instanceof BasicDBObject) {
                            bson.append(((BasicDBObject) arg).toJson());
                        } else if (arg instanceof BsonDocument) {
                            bson.append(((BsonDocument) arg).toJson());
                        } else if (arg instanceof Document) {
                            bson.append(((Document) arg).toJson());
                        } else {
                            bson.append(((Bson) arg)
                                    .toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry())
                                    .toJson());
                        }
                        //TODO leave comments for further use
                        //                        if(arg instanceof BsonDocumentWrapper) {
                        //                            bson.append(arg.toString());
                        //                        }
                        //                        if(arg instanceof CommandResult) {
                        //                            bson.append(arg.toString());
                        //                        }
                        //                        if(arg instanceof RawBsonDocument) {
                        //                            bson.append(arg.toString());
                        //                        }
                    }
                }
                parsingResult = traceContext.parseJson(bson.toString());

                if (parsingResult != null) {
                    ((ParsingResultAccessor) target)._$PINPOINT$_setParsingResult(parsingResult);
                } else {
                    if (logger.isErrorEnabled()) {
                        logger.error("sqlParsing fail. parsingResult is null bson:{}", bson);
                    }
                }
            }
        }
    }
}

From source file:com.sample.db.Database.java

private CodecRegistry getApplicationCodecRegistry() {
    return CodecRegistries.fromRegistries(CodecRegistries.fromProviders(new ApplicationCodecProvider()),
            MongoClient.getDefaultCodecRegistry());
}

From source file:com.shampan.db.codec.AlbumCodec.java

public AlbumCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}

From source file:com.shampan.db.codec.BasicProfileCodec.java

public BasicProfileCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}

From source file:com.shampan.db.codec.CountriesCodec.java

public CountriesCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}

From source file:com.shampan.db.codec.LoginAttemptCodec.java

public LoginAttemptCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}

From source file:com.shampan.db.codec.MessageCodec.java

public MessageCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}

From source file:com.shampan.db.codec.MessageDetailsCodec.java

public MessageDetailsCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}

From source file:com.shampan.db.codec.NotificationCodec.java

public NotificationCodec() {
    this.documentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
}