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


Java CodecRegistries.fromRegistries方法代码示例

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


在下文中一共展示了CodecRegistries.fromRegistries方法的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: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: getCodecRegistry

import org.bson.codecs.configuration.CodecRegistries; //导入方法依赖的package包/类
@Bean()
public static CodecRegistry getCodecRegistry() {
    return CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(
                    new EnumCodecProvider(),
                    new CustomIdCodecProvider(),
                    PojoCodecProvider.builder()
                            .register(Pojo.class.getPackage().getName())
                            .ignoreTypesAnnotatedWith(IgnoreAnnotation.class)
                            .build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:14,代码来源:ExternalIdCodecProviderTest.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(SpecialFieldsMapCodecTest.class).build()
            ),
            MongoClient.getDefaultCodecRegistry());
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:10,代码来源:SpecialFieldsMapCodecTest.java

示例15: getCodecRegistry

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


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