当前位置: 首页>>代码示例>>Java>>正文


Java CodecRegistries类代码示例

本文整理汇总了Java中org.bson.codecs.configuration.CodecRegistries的典型用法代码示例。如果您正苦于以下问题:Java CodecRegistries类的具体用法?Java CodecRegistries怎么用?Java CodecRegistries使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CodecRegistries类属于org.bson.codecs.configuration包,在下文中一共展示了CodecRegistries类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(CodecResolverTest.class)
                            .registerCodecResolver((CodecResolver) (type, typeCodecRegistry, codecConfiguration) -> {
                                if (TypeUtils.isAssignable(type, Base.class)) {
                                    return new DocumentCodec((Class<? extends Base>) type, typeCodecRegistry, codecConfiguration);
                                }
                                return null;
                            })
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:18,代码来源:CodecResolverTest.java

示例2: Repository

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
protected Repository(
    RepositorySetup configuration,
    String collectionName,
    Class<T> type) {

  this.configuration = checkNotNull(configuration, "configuration");
  checkNotNull(collectionName, "collectionName");
  checkNotNull(type, "type");

  final TypeAdapter<T> adapter = checkAdapter(configuration.gson.getAdapter(type), type);
  final MongoCollection<Document> collection = configuration.database.getCollection(collectionName);
  // combine default and immutables codec registries
  final CodecRegistry registry = CodecRegistries.fromRegistries(collection.getCodecRegistry(), BsonEncoding.registryFor(type, adapter));

  this.collection = collection
      .withCodecRegistry(registry)
      .withDocumentClass(type);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Repositories.java

示例3: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(Pojo.class.getPackage().getName())
                            .registerCodecResolver((CodecResolver) (type, typeCodecRegistry, codecConfiguration) -> {
                                if (TypeUtils.isAssignable(type, CustomId.class)) {
                                    return new CustomIdCodec((Class<CustomId>)type, typeCodecRegistry, codecConfiguration);
                                }
                                return null;
                            }).build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:17,代码来源:ExternalIdCodecProviderTest.java

示例4: buildCodecRegistries

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
private CodecRegistry buildCodecRegistries() {
	Codec<Document> defaultDocumentCodec = MongoClient.getDefaultCodecRegistry().get(Document.class);
	
	CodecRegistry codecRegistry = CodecRegistries.fromRegistries(
		MongoClient.getDefaultCodecRegistry(),
		CodecRegistries.fromCodecs(
			new BibleCodec(defaultDocumentCodec),
			new BookCodec(defaultDocumentCodec),
			new ChapterCodec(defaultDocumentCodec),
			new VerseCodec(defaultDocumentCodec),
			new UserCodec(defaultDocumentCodec)
		)
	);
	
	return codecRegistry;
}
 
开发者ID:aureliano,项目名称:verbum-domini,代码行数:17,代码来源:PersistenceManagerImpl.java

示例5: MongoStorage

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@SuppressWarnings( "unchecked" )
public MongoStorage( oap.storage.MongoClient mongoClient, String database, String table,
                     LockStrategy lockStrategy ) {
    super( IdentifierBuilder
        .annotation()
        .suggestion( ar -> ObjectId.get().toString() )
        .size( 24 )
        .idOptions()
        .build(), lockStrategy );
    this.database = mongoClient.getDatabase( database );


    final Object o = new TypeReference<Metadata<T>>() {};
    final CodecRegistry codecRegistry = CodecRegistries.fromRegistries(
        CodecRegistries.fromCodecs( new JsonCodec<>( ( TypeReference<Metadata> ) o,
            Metadata.class, ( m ) -> identifier.get( ( T ) m.object ) ) ),
        this.database.getCodecRegistry()
    );

    final Object metadataMongoCollection = this.database
        .getCollection( table, Metadata.class )
        .withCodecRegistry( codecRegistry );
    this.collection = ( MongoCollection<Metadata<T>> ) metadataMongoCollection;

    load();
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:27,代码来源:MongoStorage.java

示例6: MongoClientWrapper

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Inject
public MongoClientWrapper(MongoClientConfiguration configuration) throws
    UnreachableMongoServerException {
  try {
    MongoClientOptions options = toMongoClientOptions(configuration);
    ImmutableList<MongoCredential> credentials = toMongoCredentials(configuration);

    testAddress(configuration.getHostAndPort(), options);

    this.configuration = configuration;

    this.driverClient = new com.mongodb.MongoClient(
        new ServerAddress(
            configuration.getHostAndPort().getHostText(),
            configuration.getHostAndPort().getPort()),
        credentials,
        options
    );

    version = calculateVersion();
    codecRegistry = CodecRegistries.fromCodecs(new DocumentCodec());
    closed = false;
  } catch (com.mongodb.MongoException ex) {
    throw new UnreachableMongoServerException(configuration.getHostAndPort(), ex);
  }
}
 
开发者ID:torodb,项目名称:mongowp,代码行数:27,代码来源:MongoClientWrapper.java

示例7: parse

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
private BsonDocument parse(String where) {
  Bson bson = sqlParser.get(Bson.class, where);

  return bson.toBsonDocument(
      BsonDocument.class,
      CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:8,代码来源:MongoWhereClauseListenerTest.java

示例8: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(TypeCodecProviderTest.class)
                            .register(new CustomTypeCodecProvider(), new SetOfStringTypeCodecProvider())
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:13,代码来源:TypeCodecProviderTest.java

示例9: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(NoDiscriminatorForPolymorphicLeafClassesTest.class)
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:12,代码来源:NoDiscriminatorForPolymorphicLeafClassesTest.java

示例10: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder().register("de.bild.codec.model").build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:10,代码来源:TypesModelPackageTest.java

示例11: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder().register(PolymorphicTest.class).build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:10,代码来源:PolymorphicTest.java

示例12: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(UpdateTest.class)
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:12,代码来源:UpdateTest.java

示例13: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(NullHandlingTest.class)
                            .encodeNulls(false)
                            .decodeUndefinedHandlingStrategy(DecodeUndefinedHandlingStrategy.Strategy.KEEP_POJO_DEFAULT)
                            .encodeNullHandlingStrategy(EncodeNullHandlingStrategy.Strategy.KEEP_NULL)
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:15,代码来源:NullHandlingTest.java

示例14: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register("de.bild.codec.nonregisteredmodel.model")
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:12,代码来源:NonRegisteredModelClassTest.java

示例15: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入依赖的package包/类
/**
 *
 * @return a CodecRegistry build from the model package and the DefaultCodecRegistry from the mongo driver
 */
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    PojoCodecProvider.builder()
                            .register("de.bild.codec.tutorial.model")
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:15,代码来源:Tutorial.java


注:本文中的org.bson.codecs.configuration.CodecRegistries类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。