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


Java MongoMappingContext类代码示例

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


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

示例1: mappingMongoConverter

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Bean
public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory,
		MongoMappingContext context, BeanFactory beanFactory) {
	DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
	MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver,
			context);

	// remove _class field
	mappingConverter.setTypeMapper(new DefaultMongoTypeMapper(null));

	try {
		mappingConverter
				.setCustomConversions(beanFactory.getBean(CustomConversions.class));
	}
	catch (NoSuchBeanDefinitionException ex) {
		// Ignore
	}
	return mappingConverter;
}
 
开发者ID:ralscha,项目名称:eds-starter6-simple-mongodb,代码行数:20,代码来源:MongoConfig.java

示例2: mappingMongoConverter

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(MongoConverter.class)
public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory,
		MongoMappingContext context, BeanFactory beanFactory) {
	DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
	MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver,
			context);
	try {
		mappingConverter
				.setCustomConversions(beanFactory.getBean(CustomConversions.class));
	}
	catch (NoSuchBeanDefinitionException ex) {
		// Ignore
	}
	return mappingConverter;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:MongoDataAutoConfiguration.java

示例3: testFieldNamingStrategy

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
public void testFieldNamingStrategy(String strategy,
		Class<? extends FieldNamingStrategy> expectedType) {
	this.context = new AnnotationConfigApplicationContext();
	if (strategy != null) {
		EnvironmentTestUtils.addEnvironment(this.context,
				"spring.data.mongodb.field-naming-strategy:" + strategy);
	}
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
	this.context.refresh();
	MongoMappingContext mappingContext = this.context
			.getBean(MongoMappingContext.class);
	FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils
			.getField(mappingContext, "fieldNamingStrategy");
	assertThat(fieldNamingStrategy.getClass()).isEqualTo(expectedType);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:MongoDataAutoConfigurationTests.java

示例4: testFieldNamingStrategy

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
public void testFieldNamingStrategy(String strategy,
		Class<? extends FieldNamingStrategy> expectedType) {
	this.context = new AnnotationConfigApplicationContext();
	if (strategy != null) {
		EnvironmentTestUtils.addEnvironment(this.context,
				"spring.data.mongodb.field-naming-strategy:" + strategy);
	}
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
	this.context.refresh();
	MongoMappingContext mappingContext = this.context
			.getBean(MongoMappingContext.class);
	FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils
			.getField(mappingContext, "fieldNamingStrategy");
	assertEquals(expectedType, fieldNamingStrategy.getClass());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:MongoDataAutoConfigurationTests.java

示例5: createIndecesFor

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
protected void createIndecesFor(final Class<?> type) {
	final MongoMappingContext mappingContext =
			(MongoMappingContext) getMongoTemplate().getConverter().getMappingContext();
	final MongoPersistentEntityIndexResolver indexResolver =
			new MongoPersistentEntityIndexResolver(mappingContext);
	for (final IndexDefinitionHolder indexToCreate : indexResolver.resolveIndexForClass(type)) {
		createIndex(indexToCreate);
	}
}
 
开发者ID:ralfstuckert,项目名称:mongorule,代码行数:10,代码来源:MongoCleanupRule.java

示例6: naiveMongoTemplate

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Primary
@Bean(name = "naiveMongoTemplate")
public MongoTemplate naiveMongoTemplate() throws Exception {
    MappingMongoConverter converter =
            new MappingMongoConverter(new DefaultDbRefResolver(naiveFactory()), new MongoMappingContext());
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));
    return new MongoTemplate(naiveFactory(), converter);
}
 
开发者ID:zhangtr,项目名称:canal-mongo,代码行数:9,代码来源:MultipleMongoConfig.java

示例7: completeMongoTemplate

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Bean
@Qualifier("completeMongoTemplate")
public MongoTemplate completeMongoTemplate() throws Exception {
    MappingMongoConverter converter =
            new MappingMongoConverter(new DefaultDbRefResolver(completeFactory()), new MongoMappingContext());
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));
    return new MongoTemplate(completeFactory(), converter);
}
 
开发者ID:zhangtr,项目名称:canal-mongo,代码行数:9,代码来源:MultipleMongoConfig.java

示例8: MongoContainer

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
public MongoContainer(MongoClient mongoClient,
					  MongoTemplate template,
					  MongoDbFactory mongoDbFactory,
					  MongoMappingContext context,
					  Environment environment) {
	this.mongoClient = mongoClient;
	this.template = template;
	this.mongoDbFactory = mongoDbFactory;
	this.context = context;
}
 
开发者ID:marrow16,项目名称:Nasapi,代码行数:11,代码来源:MongoContainer.java

示例9: mongoContainer

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
/**
 * Create the Mongo container (used by scripts to access MongoDB)
 * @param mongoClient - the MongoClient (from Spring)
 * @param environment - the environment
 * @return the MongoContainer
 */
@Bean
public MongoContainer mongoContainer(MongoClient mongoClient,
									  MongoTemplate template,
									  MongoDbFactory mongoDbFactory,
									  MongoMappingContext context,
									  Environment environment) {
	return new MongoContainer(mongoClient, template, mongoDbFactory, context, environment);
}
 
开发者ID:marrow16,项目名称:Nasapi,代码行数:15,代码来源:Nasapi.java

示例10: initMongoMappingContext

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
private void initMongoMappingContext(String[] domainPackage) {
    BeanDefinitionBuilder mappingContextBuilder = BeanDefinitionBuilder.genericBeanDefinition(MongoMappingContext.class);
    Set<String> classesToAdd = getInititalEntityClasses(domainPackage);
    if (classesToAdd != null) {
        mappingContextBuilder.addPropertyValue("initialEntitySet", classesToAdd);
    }

    BEAN_DEFINITION_MAP.put(MONGO_MAPPING_CONTEXT_BEAN_NAME, mappingContextBuilder.getBeanDefinition());
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:10,代码来源:MongoBeanDefinitionRegistrar.java

示例11: mongoMappingContext

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MongoMappingContext mongoMappingContext(BeanFactory beanFactory)
		throws ClassNotFoundException {
	MongoMappingContext context = new MongoMappingContext();
	context.setInitialEntitySet(new EntityScanner(this.applicationContext)
			.scan(Document.class, Persistent.class));
	Class<?> strategyClass = this.properties.getFieldNamingStrategy();
	if (strategyClass != null) {
		context.setFieldNamingStrategy(
				(FieldNamingStrategy) BeanUtils.instantiate(strategyClass));
	}
	return context;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:MongoDataAutoConfiguration.java

示例12: usesAutoConfigurationPackageToPickUpDocumentTypes

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Test
public void usesAutoConfigurationPackageToPickUpDocumentTypes() {
	this.context = new AnnotationConfigApplicationContext();
	String cityPackage = City.class.getPackage().getName();
	AutoConfigurationPackages.register(this.context, cityPackage);
	this.context.register(MongoAutoConfiguration.class,
			MongoDataAutoConfiguration.class);
	this.context.refresh();
	assertDomainTypesDiscovered(this.context.getBean(MongoMappingContext.class),
			City.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:MongoDataAutoConfigurationTests.java

示例13: entityScanShouldSetInitialEntitySet

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void entityScanShouldSetInitialEntitySet() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	this.context.register(EntityScanConfig.class,
			PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
			MongoDataAutoConfiguration.class);
	this.context.refresh();
	MongoMappingContext mappingContext = this.context
			.getBean(MongoMappingContext.class);
	Set<Class<?>> initialEntitySet = (Set<Class<?>>) ReflectionTestUtils
			.getField(mappingContext, "initialEntitySet");
	assertThat(initialEntitySet).containsOnly(City.class, Country.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:MongoDataAutoConfigurationTests.java

示例14: assertDomainTypesDiscovered

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void assertDomainTypesDiscovered(MongoMappingContext mappingContext,
		Class<?>... types) {
	Set<Class> initialEntitySet = (Set<Class>) ReflectionTestUtils
			.getField(mappingContext, "initialEntitySet");
	assertThat(initialEntitySet).containsOnly(types);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:MongoDataAutoConfigurationTests.java

示例15: testDefaultRepositoryConfiguration

import org.springframework.data.mongodb.core.mapping.MongoMappingContext; //导入依赖的package包/类
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
	prepareApplicationContext(TestConfiguration.class);

	assertThat(this.context.getBean(CityRepository.class)).isNotNull();
	Mongo mongo = this.context.getBean(Mongo.class);
	assertThat(mongo).isInstanceOf(MongoClient.class);
	MongoMappingContext mappingContext = this.context
			.getBean(MongoMappingContext.class);
	@SuppressWarnings("unchecked")
	Set<? extends Class<?>> entities = (Set<? extends Class<?>>) ReflectionTestUtils
			.getField(mappingContext, "initialEntitySet");
	assertThat(entities).hasSize(1);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:MongoRepositoriesAutoConfigurationTests.java


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