Java 类org.springframework.data.repository.config.RepositoryConfigurationSource 实例源码

项目:spring-data-tarantool    文件:TarantoolRepositoryConfigurationExtension.java   
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {
    RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(TarantoolKeyValueTemplate.class);

    ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
            new RuntimeBeanReference(TARANTOOL_OPS_IMPL_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
            new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(2,
            new RuntimeBeanReference(TARANTOOL_CONVERTER_BEAN_NAME));

    keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

    return keyValueTemplateDefinition;
}
项目:spring-vault    文件:VaultRepositoryConfigurationExtension.java   
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {

    RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(
            VaultKeyValueTemplate.class);

    ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
            new RuntimeBeanReference(VAULT_ADAPTER_BEAN_NAME));

    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
            new RuntimeBeanReference(VAULT_MAPPING_CONTEXT_BEAN_NAME));

    keyValueTemplateDefinition
            .setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

    return keyValueTemplateDefinition;
}
项目:spring-data-keyvalue-redis    文件:RedisRepositoryConfigurationExtension.java   
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {

    RootBeanDefinition redisKeyValueAdapterDefinition = new RootBeanDefinition(RedisKeyValueAdapter.class);

    DirectFieldAccessor dfa = new DirectFieldAccessor(configurationSource);
    AnnotationAttributes aa = (AnnotationAttributes) dfa.getPropertyValue("attributes");

    GenericBeanDefinition indexConfiguration = new GenericBeanDefinition();
    indexConfiguration.setBeanClass(aa.getClass("indexConfiguration"));

    ConstructorArgumentValues constructorArgumentValuesForRedisKeyValueAdapter = new ConstructorArgumentValues();
    constructorArgumentValuesForRedisKeyValueAdapter.addGenericArgumentValue(indexConfiguration);
    redisKeyValueAdapterDefinition.setConstructorArgumentValues(constructorArgumentValuesForRedisKeyValueAdapter);

    RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(KeyValueTemplate.class);
    ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
    constructorArgumentValuesForKeyValueTemplate.addGenericArgumentValue(redisKeyValueAdapterDefinition);
    keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

    return keyValueTemplateDefinition;
}
项目:spring-data-keyvalue    文件:KeyValueRepositoryConfigurationExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {

    super.registerBeansForRoot(registry, configurationSource);

    RootBeanDefinition mappingContextDefinition = new RootBeanDefinition(KeyValueMappingContext.class);
    mappingContextDefinition.setSource(configurationSource.getSource());

    registerIfNotAlreadyRegistered(mappingContextDefinition, registry, getMappingContextBeanRef(), configurationSource);

    Optional<String> keyValueTemplateName = configurationSource.getAttribute(KEY_VALUE_TEMPLATE_BEAN_REF_ATTRIBUTE);

    // No custom template reference configured and no matching bean definition found
    if (keyValueTemplateName.isPresent() && getDefaultKeyValueTemplateRef().equals(keyValueTemplateName.get())
            && !registry.containsBeanDefinition(keyValueTemplateName.get())) {

        AbstractBeanDefinition beanDefinition = getDefaultKeyValueTemplateBeanDefinition(configurationSource);

        if (beanDefinition != null) {
            registerIfNotAlreadyRegistered(beanDefinition, registry, keyValueTemplateName.get(),
                    configurationSource.getSource());
        }
    }
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryConfigurationExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource config) {
    super.registerBeansForRoot(registry, config);

    if (!registry.containsBeanDefinition("documentDbMappingContext")) {
        final RootBeanDefinition definition = new RootBeanDefinition(DocumentDbMappingContext.class);
        definition.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE);
        definition.setSource(config.getSource());

        registry.registerBeanDefinition("documentDbMappingContext", definition);
    }
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryConfigurationExtensionUnitTest.java   
private static void assertHashRepo(Class<?> repositoryInterface,
                                   Collection<RepositoryConfiguration<RepositoryConfigurationSource>> configs) {
    for (final RepositoryConfiguration<?> config : configs) {
        if (config.getRepositoryInterface().equals(repositoryInterface.getName())) {
            return;
        }
    }

    fail("expected to find config for repository interface "
            + repositoryInterface.getName() + ", but got: " + configs.toString());
}
项目:spring-data-tarantool    文件:TarantoolRepositoryConfigurationExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {
    String tarantolSyncOpsRef = configurationSource.getAttribute("tarantoolSyncOpsRef");
    // register context
    RootBeanDefinition mappingContextDefinition = createTarantoolMappingContext();
    mappingContextDefinition.setSource(configurationSource.getSource());

    registerIfNotAlreadyRegistered(mappingContextDefinition, registry, MAPPING_CONTEXT_BEAN_NAME, configurationSource);

    // Register converter
    RootBeanDefinition redisConverterDefinition = createTarantoolConverterDefinition();
    redisConverterDefinition.setSource(configurationSource.getSource());

    registerIfNotAlreadyRegistered(redisConverterDefinition, registry, TARANTOOL_CONVERTER_BEAN_NAME, configurationSource);

    // register tarantoolOpsImpl
    RootBeanDefinition tarantoolOpsImplDefinition = new RootBeanDefinition(TarantoolOpsImpl.class);

    ConstructorArgumentValues constructorArgumentValuesForTarantoolOpsImpl = new ConstructorArgumentValues();
    if (StringUtils.hasText(tarantolSyncOpsRef)) {
        constructorArgumentValuesForTarantoolOpsImpl.addIndexedArgumentValue(0,
                new RuntimeBeanReference(tarantolSyncOpsRef));
    }

    tarantoolOpsImplDefinition.setConstructorArgumentValues(constructorArgumentValuesForTarantoolOpsImpl);

    registerIfNotAlreadyRegistered(tarantoolOpsImplDefinition, registry, TARANTOOL_OPS_IMPL_BEAN_NAME,
            configurationSource);

    super.registerBeansForRoot(registry, configurationSource);
}
项目:spring-data-jdbc-template    文件:JdbcTemplateRepositoryConfigExtension.java   
@Override
public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) {
    super.postProcess(builder, source);

    builder.addPropertyValue("configuration",
            JdbcTemplateRepositoryConfiguration.create(source.getAttribute("namedParameterJdbcOperationsBeanName")));
}
项目:spring-data-objectify    文件:ObjectifyRepositoryConfigurationExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {
       super.registerBeansForRoot(registry, configurationSource);

       RootBeanDefinition mappingContextDefinition = new RootBeanDefinition(ObjectifyMappingContext.class);
       mappingContextDefinition.setSource(configurationSource.getSource());

       registerIfNotAlreadyRegistered(mappingContextDefinition, registry, MAPPING_CONTEXT_BEAN_NAME, configurationSource);
   }
项目:spring-data-mybatis    文件:MybatisRepositoryConfigExtension.java   
@Override
public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) {
    String transactionManagerRef = source.getAttribute("transactionManagerRef");
    builder.addPropertyValue("transactionManager", null == transactionManagerRef ? DEFAULT_TRANSACTION_MANAGER_BEAN_NAME : transactionManagerRef);

    String sqlSessionFactoryRef = source.getAttribute("sqlSessionFactoryRef");
    sqlSessionFactoryRef = (null == sqlSessionFactoryRef ? DEFAULT_SQL_SESSION_FACTORY_BEAN_NAME : sqlSessionFactoryRef);
    builder.addPropertyReference("sqlSessionTemplate", sqlSessionFactoryRef.concat(SQL_SESSION_TEMPLATE_BEAN_NAME_SUFFIX));
    builder.addPropertyReference("dialect", sqlSessionFactoryRef.concat(DIALECT_BEAN_NAME_SUFFIX));
    builder.addPropertyReference("mappingContext", sqlSessionFactoryRef.concat(MAPPING_CONTEXT_SUFFIX));

}
项目:spring-vault    文件:VaultRepositoryConfigurationExtension.java   
private RootBeanDefinition createVaultMappingContext(
        RepositoryConfigurationSource configurationSource) {

    ConstructorArgumentValues mappingContextArgs = new ConstructorArgumentValues();

    RootBeanDefinition mappingContextBeanDef = new RootBeanDefinition(
            VaultMappingContext.class);
    mappingContextBeanDef.setConstructorArgumentValues(mappingContextArgs);
    mappingContextBeanDef.setSource(configurationSource.getSource());

    return mappingContextBeanDef;
}
项目:dubbox-solr    文件:SolrRepositoryConfigExtension.java   
private void registerSolrMappingContextIfNotPresent(BeanDefinitionRegistry registry,
        RepositoryConfigurationSource configurationSource) {

    RootBeanDefinition definition = new RootBeanDefinition(SimpleSolrMappingContext.class);
    definition.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE);
    definition.setSource(configurationSource.getSource());

    registerIfNotAlreadyRegistered(definition, registry, BeanDefinition.SOLR_MAPPTING_CONTEXT.getBeanName(), definition);
}
项目:ef-orm    文件:GqRepositoryConfigExtension.java   
@Override
    public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) {

        String transactionManagerRef = source.getAttribute("transactionManagerRef").get();
        builder.addPropertyValue("transactionManager",
                transactionManagerRef == null ? DEFAULT_TRANSACTION_MANAGER_BEAN_NAME : transactionManagerRef);

//      Iterable<String> s1=source.getBasePackages();
//      builder.addPropertyValue("transactionManagerRef",source.getAttribute("transactionManagerRef"));
        builder.addPropertyValue("namedQueryLocation", source.getNamedQueryLocation().orElse(null));
        builder.addPropertyValue("entityManagerFactoryRef",source.getAttribute("entityManagerFactoryRef").orElse(null));
        builder.addPropertyValue("repositoryImplementationPostfix", source.getAttribute("repositoryImplementationPostfix").orElse("Impl"));
    }
项目:spring-data-solr    文件:SolrRepositoryConfigExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {
    super.registerBeansForRoot(registry, configurationSource);

    BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(SolrExceptionTranslator.class);
    registry.registerBeanDefinition("solrExceptionTranslator", definition.getBeanDefinition());
}
项目:spring-data-keyvalue    文件:MapRepositoryConfigurationExtension.java   
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {

    BeanDefinitionBuilder adapterBuilder = BeanDefinitionBuilder.rootBeanDefinition(MapKeyValueAdapter.class);
    adapterBuilder.addConstructorArgValue(getMapTypeToUse(configurationSource));

    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(KeyValueTemplate.class);
    builder
            .addConstructorArgValue(ParsingUtils.getSourceBeanDefinition(adapterBuilder, configurationSource.getSource()));
    builder.setRole(BeanDefinition.ROLE_SUPPORT);

    return ParsingUtils.getSourceBeanDefinition(builder, configurationSource.getSource());
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryConfigurationExtension.java   
@Override
public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) {
    super.postProcess(builder, source);
}
项目:spring-boot-gae    文件:ObjectifyRepositoryConfigurationExtension.java   
@Override
public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) {
    super.postProcess(builder, source);
}
项目:lodsve-framework    文件:LodsveMongoRepositoryConfigurationExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {
    super.registerBeansForRoot(registry, configurationSource);
}
项目:spring-data-mybatis    文件:MybatisRepositoryConfigExtension.java   
@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);
        }
    }

}
项目:spring-vault    文件:VaultRepositoryConfigurationExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry,
        RepositoryConfigurationSource configurationSource) {

    Optional<String> vaultTemplateRef = configurationSource
            .getAttribute("vaultTemplateRef");

    RootBeanDefinition mappingContextDefinition = createVaultMappingContext(configurationSource);
    mappingContextDefinition.setSource(configurationSource.getSource());

    registerIfNotAlreadyRegistered(mappingContextDefinition, registry,
            VAULT_MAPPING_CONTEXT_BEAN_NAME, configurationSource);

    // register Adapter
    RootBeanDefinition vaultKeyValueAdapterDefinition = new RootBeanDefinition(
            VaultKeyValueAdapter.class);

    ConstructorArgumentValues constructorArgumentValuesForVaultKeyValueAdapter = new ConstructorArgumentValues();

    constructorArgumentValuesForVaultKeyValueAdapter.addIndexedArgumentValue(0,
            new RuntimeBeanReference(vaultTemplateRef.orElse("vaultTemplate")));

    vaultKeyValueAdapterDefinition
            .setConstructorArgumentValues(constructorArgumentValuesForVaultKeyValueAdapter);

    registerIfNotAlreadyRegistered(vaultKeyValueAdapterDefinition, registry,
            VAULT_ADAPTER_BEAN_NAME, configurationSource);

    Optional<String> keyValueTemplateName = configurationSource
            .getAttribute(KEY_VALUE_TEMPLATE_BEAN_REF_ATTRIBUTE);

    // No custom template reference configured and no matching bean definition found
    if (keyValueTemplateName.isPresent()
            && getDefaultKeyValueTemplateRef().equals(keyValueTemplateName.get())
            && !registry.containsBeanDefinition(keyValueTemplateName.get())) {

        AbstractBeanDefinition beanDefinition = getDefaultKeyValueTemplateBeanDefinition(configurationSource);

        registerIfNotAlreadyRegistered(beanDefinition, registry,
                keyValueTemplateName.get(), configurationSource.getSource());
    }

    super.registerBeansForRoot(registry, configurationSource);
}
项目:spring-data-keyvalue    文件:MapRepositoryConfigurationExtension.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Class<? extends Map> getMapTypeToUse(RepositoryConfigurationSource source) {

    return (Class<? extends Map>) ((AnnotationMetadata) source.getSource()).getAnnotationAttributes(
            EnableMapRepositories.class.getName()).get("mapType");
}
项目:dubbox-solr    文件:SolrRepositoryConfigExtension.java   
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {

    super.registerBeansForRoot(registry, configurationSource);

    registerSolrMappingContextIfNotPresent(registry, configurationSource);

    registerIfNotAlreadyRegistered(BeanDefinitionBuilder.genericBeanDefinition(SolrExceptionTranslator.class)
            .getBeanDefinition(), registry, "solrExceptionTranslator", configurationSource);
}
项目:ef-orm    文件:GqRepositoryConfigExtension.java   
@Override
    public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource config) {

        super.registerBeansForRoot(registry, config);

        Object source = config.getSource();

        registerIfNotAlreadyRegistered(new RootBeanDefinition(PAB_POST_PROCESSOR), registry,
                AnnotationConfigUtils.PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME, source);

//      RootBeanDefinition contextDefinition = new RootBeanDefinition(DefaultGqContext.class);
//      contextDefinition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    }
项目:spring-data-keyvalue    文件:KeyValueRepositoryConfigurationExtension.java   
/**
 * Get the default {@link RootBeanDefinition} for {@link org.springframework.data.keyvalue.core.KeyValueTemplate}.
 *
 * @return {@literal null} to explicitly not register a template.
 * @see #getDefaultKeyValueTemplateRef()
 */
@Nullable
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {
    return null;
}