本文整理匯總了Java中org.springframework.data.repository.core.support.AbstractRepositoryMetadata類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractRepositoryMetadata類的具體用法?Java AbstractRepositoryMetadata怎麽用?Java AbstractRepositoryMetadata使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractRepositoryMetadata類屬於org.springframework.data.repository.core.support包,在下文中一共展示了AbstractRepositoryMetadata類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerBeansForRoot
import org.springframework.data.repository.core.support.AbstractRepositoryMetadata; //導入依賴的package包/類
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource config) {
super.registerBeansForRoot(registry, config);
Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();
Collection<BeanDefinition> candidates = config.getCandidates(resourceLoader);
for (BeanDefinition candidate : candidates) {
Class<?> repositoryInterface = loadRepositoryInterface(candidate.getBeanClassName(), resourceLoader);
if (null == repositoryInterface) {
continue;
}
RepositoryMetadata metadata = AbstractRepositoryMetadata.getMetadata(repositoryInterface);
if (null == metadata) {
continue;
}
initialEntitySet.add(metadata.getDomainType());
}
Object source = config.getSource();
String sqlSessionFactoryRef = config.getAttribute("sqlSessionFactoryRef");
sqlSessionFactoryRef = (null == sqlSessionFactoryRef ? DEFAULT_SQL_SESSION_FACTORY_BEAN_NAME : sqlSessionFactoryRef);
BeanDefinitionBuilder mappingContextBuilder = BeanDefinitionBuilder.rootBeanDefinition(MybatisMappingContext.class);
mappingContextBuilder.addPropertyValue("initialEntitySet", initialEntitySet);
registerIfNotAlreadyRegistered(mappingContextBuilder.getBeanDefinition(), registry, sqlSessionFactoryRef.concat(MAPPING_CONTEXT_SUFFIX), source);
// create database dialect
BeanDefinitionBuilder dialectBuilder = BeanDefinitionBuilder.rootBeanDefinition(DialectFactoryBean.class);
dialectBuilder.addPropertyReference("sqlSessionFactory", sqlSessionFactoryRef);
registerIfNotAlreadyRegistered(dialectBuilder.getBeanDefinition(), registry, sqlSessionFactoryRef.concat(DIALECT_BEAN_NAME_SUFFIX), source);
// create sqlSessionTemplate bean.
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SqlSessionTemplate.class);
builder.addConstructorArgReference(sqlSessionFactoryRef);
registerIfNotAlreadyRegistered(builder.getBeanDefinition(), registry, sqlSessionFactoryRef.concat(SQL_SESSION_TEMPLATE_BEAN_NAME_SUFFIX), source);
// create mybatis mapper register
if (config instanceof MybatisAnnotationRepositoryConfigurationSource) {
String[] mapperLocations = ((MybatisAnnotationRepositoryConfigurationSource) config).getMapperLocations();
if (null != mapperLocations && mapperLocations.length > 0) {
BeanDefinitionBuilder builder1 = BeanDefinitionBuilder.rootBeanDefinition(MybatisMappersRegister.class);
builder1.addPropertyReference("sqlSessionFactory", sqlSessionFactoryRef);
builder1.addPropertyValue("locations", mapperLocations);
registerIfNotAlreadyRegistered(builder1.getBeanDefinition(), registry, sqlSessionFactoryRef.concat("_MapperLocations"), source);
}
}
}