DATACOUCH-192 - Prefix all bean names with "couchbase"

This commit is contained in:
Simon Baslé
2016-01-27 15:38:14 +01:00
parent 8f5e9e3df8
commit 933ff0feaa
5 changed files with 30 additions and 13 deletions

View File

@@ -165,7 +165,7 @@ public abstract class AbstractCouchbaseConfiguration {
*
* @throws Exception
*/
@Bean(name = BeanNames.REPO_OPERATIONS_MAPPING)
@Bean(name = BeanNames.COUCHBASE_OPERATIONS_MAPPING)
public RepositoryOperationsMapping repositoryOperationsMapping() throws Exception {
//create a base mapping that associates all repositories to the default template
RepositoryOperationsMapping baseMapping = new RepositoryOperationsMapping(couchbaseTemplate());
@@ -201,7 +201,7 @@ public abstract class AbstractCouchbaseConfiguration {
*
* @throws Exception on Bean construction failure.
*/
@Bean
@Bean(name = BeanNames.COUCHBASE_MAPPING_CONVERTER)
public MappingCouchbaseConverter mappingCouchbaseConverter() throws Exception {
MappingCouchbaseConverter converter = new MappingCouchbaseConverter(couchbaseMappingContext(), typeKey());
converter.setCustomConversions(customConversions());
@@ -213,7 +213,7 @@ public abstract class AbstractCouchbaseConfiguration {
*
* @return TranslationService, defaulting to JacksonTranslationService.
*/
@Bean
@Bean(name = BeanNames.COUCHBASE_TRANSLATION_SERVICE)
public TranslationService translationService() {
final JacksonTranslationService jacksonTranslationService = new JacksonTranslationService();
jacksonTranslationService.afterPropertiesSet();
@@ -225,7 +225,7 @@ public abstract class AbstractCouchbaseConfiguration {
*
* @throws Exception on Bean construction failure.
*/
@Bean
@Bean(name = BeanNames.COUCHBASE_MAPPING_CONTEXT)
public CouchbaseMappingContext couchbaseMappingContext() throws Exception {
CouchbaseMappingContext mappingContext = new CouchbaseMappingContext();
mappingContext.setInitialEntitySet(getInitialEntitySet());
@@ -241,7 +241,7 @@ public abstract class AbstractCouchbaseConfiguration {
*
* @return must not be {@literal null}.
*/
@Bean
@Bean(name = BeanNames.COUCHBASE_CUSTOM_CONVERSIONS)
public CustomConversions customConversions() {
return new CustomConversions(Collections.emptyList());
}

View File

@@ -16,6 +16,8 @@
package org.springframework.data.couchbase.config;
import org.springframework.core.convert.converter.Converter;
/**
* Contains default bean names that will be used when no "id" is supplied to the beans.
*
@@ -46,7 +48,7 @@ public class BeanNames {
/**
* Refers to the "<couchbase:translation-service />" bean
*/
static final String TRANSLATION_SERVICE = "couchbaseTranslationService";
static final String COUCHBASE_TRANSLATION_SERVICE = "couchbaseTranslationService";
/**
* Refers to the "<couchbase:clusterInfo>" bean
@@ -56,10 +58,25 @@ public class BeanNames {
/**
* The bean that stores custom mapping between repositories and their backing couchbaseOperations.
*/
public static final String REPO_OPERATIONS_MAPPING = "repositoryOperationsMapping";
public static final String COUCHBASE_OPERATIONS_MAPPING = "couchbaseRepositoryOperationsMapping";
/**
* The bean that drives how some indexes are automatically created.
*/
public static final String COUCHBASE_INDEX_MANAGER = "couchbaseIndexManager";
/**
* The bean that performs conversion to/from representation suitable for storage in couchbase.
*/
public static final String COUCHBASE_MAPPING_CONVERTER = "couchbaseMappingConverter";
/**
* The bean that stores mapping metadata for entities stored in couchbase.
*/
public static final String COUCHBASE_MAPPING_CONTEXT = "couchbaseMappingContext";
/**
* The bean that registers custom {@link Converter Converters} to encode/decode entity members.
*/
public static final String COUCHBASE_CUSTOM_CONVERSIONS = "couchbaseCustomConversions";
}

View File

@@ -67,12 +67,12 @@ public class CouchbaseTranslationServiceParser extends AbstractSingleBeanDefinit
* @param element the XML element which contains the attributes.
* @param definition the bean definition to work with.
* @param parserContext encapsulates the parsing state and configuration.
* @return the ID to work with (e.g., "translationService")
* @return the ID to work with (e.g., "couchbaseTranslationService")
*/
@Override
protected String resolveId(final Element element, final AbstractBeanDefinition definition, final ParserContext parserContext) {
String id = super.resolveId(element, definition, parserContext);
return StringUtils.hasText(id) ? id : BeanNames.TRANSLATION_SERVICE;
return StringUtils.hasText(id) ? id : BeanNames.COUCHBASE_TRANSLATION_SERVICE;
}
}

View File

@@ -55,9 +55,9 @@ public class CouchbaseRepositoryConfigurationExtension extends RepositoryConfigu
@Override
public void postProcess(final BeanDefinitionBuilder builder, final AnnotationRepositoryConfigurationSource config) {
builder.addDependsOn(BeanNames.REPO_OPERATIONS_MAPPING);
builder.addDependsOn(BeanNames.COUCHBASE_OPERATIONS_MAPPING);
builder.addDependsOn(BeanNames.COUCHBASE_INDEX_MANAGER);
builder.addPropertyReference("couchbaseOperationsMapping", BeanNames.REPO_OPERATIONS_MAPPING);
builder.addPropertyReference("couchbaseOperationsMapping", BeanNames.COUCHBASE_OPERATIONS_MAPPING);
builder.addPropertyReference("indexManager", BeanNames.COUCHBASE_INDEX_MANAGER);
}
}