@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; }
@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; }
@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; }
@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()); } } }
@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); } }
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()); }
@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); }
@Override public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) { super.postProcess(builder, source); builder.addPropertyValue("configuration", JdbcTemplateRepositoryConfiguration.create(source.getAttribute("namedParameterJdbcOperationsBeanName"))); }
@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); }
@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)); }
private RootBeanDefinition createVaultMappingContext( RepositoryConfigurationSource configurationSource) { ConstructorArgumentValues mappingContextArgs = new ConstructorArgumentValues(); RootBeanDefinition mappingContextBeanDef = new RootBeanDefinition( VaultMappingContext.class); mappingContextBeanDef.setConstructorArgumentValues(mappingContextArgs); mappingContextBeanDef.setSource(configurationSource.getSource()); return mappingContextBeanDef; }
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); }
@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")); }
@Override public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) { super.registerBeansForRoot(registry, configurationSource); BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(SolrExceptionTranslator.class); registry.registerBeanDefinition("solrExceptionTranslator", definition.getBeanDefinition()); }
@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()); }
@Override public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) { super.postProcess(builder, source); }
@Override public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) { super.registerBeansForRoot(registry, configurationSource); }
@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); } } }
@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); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Class<? extends Map> getMapTypeToUse(RepositoryConfigurationSource source) { return (Class<? extends Map>) ((AnnotationMetadata) source.getSource()).getAnnotationAttributes( EnableMapRepositories.class.getName()).get("mapType"); }
@Override public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) { super.registerBeansForRoot(registry, configurationSource); registerSolrMappingContextIfNotPresent(registry, configurationSource); registerIfNotAlreadyRegistered(BeanDefinitionBuilder.genericBeanDefinition(SolrExceptionTranslator.class) .getBeanDefinition(), registry, "solrExceptionTranslator", configurationSource); }
@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); }
/** * 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; }