本文整理汇总了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());
}
示例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);
}
示例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());
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}