@Configuration public abstract class AbstractCouchbaseConfiguration extends Object
| Constructor and Description |
|---|
AbstractCouchbaseConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
abbreviateFieldNames()
Set to true if field names should be abbreviated with the
CamelCaseAbbreviatingFieldNamingStrategy. |
protected void |
configureRepositoryOperationsMapping(RepositoryOperationsMapping mapping)
In order to customize the mapping between repositories/entity types to couchbase templates,
use the provided mapping's api (eg. in order to have different buckets backing different repositories).
|
com.couchbase.client.java.Bucket |
couchbaseClient()
Return the
Bucket instance to connect to. |
com.couchbase.client.java.Cluster |
couchbaseCluster()
Returns the
Cluster instance to connect to. |
com.couchbase.client.java.cluster.ClusterInfo |
couchbaseClusterInfo() |
com.couchbase.client.java.env.CouchbaseEnvironment |
couchbaseEnvironment() |
CouchbaseMappingContext |
couchbaseMappingContext()
Creates a
CouchbaseMappingContext equipped with entity classes scanned from the mapping base package. |
CouchbaseTemplate |
couchbaseTemplate()
Creates a
CouchbaseTemplate. |
CustomConversions |
customConversions()
Register custom Converters in a
CustomConversions object if required. |
protected FieldNamingStrategy |
fieldNamingStrategy()
Configures a
FieldNamingStrategy on the CouchbaseMappingContext instance created. |
protected abstract List<String> |
getBootstrapHosts()
The list of hostnames (or IP addresses) to bootstrap from.
|
protected abstract String |
getBucketName()
The name of the bucket to connect to.
|
protected abstract String |
getBucketPassword()
The password of the bucket (can be an empty string).
|
protected Consistency |
getDefaultConsistency()
Configures the default consistency for generated
view queries
and N1QL queries in repositories. |
protected com.couchbase.client.java.env.CouchbaseEnvironment |
getEnvironment()
Override this method if you want a customized
CouchbaseEnvironment. |
protected Set<Class<?>> |
getInitialEntitySet()
Scans the mapping base package for classes annotated with
Document. |
protected String |
getMappingBasePackage()
Return the base package to scan for mapped
Documents. |
IndexManager |
indexManager()
Register an
IndexManager bean that will be used to process ViewIndexed,
N1qlPrimaryIndexed and N1qlSecondaryIndexed annotations on repositories
to automatically create indexes. |
protected boolean |
isEnvironmentManagedBySpring()
Is the
getEnvironment() to be destroyed by Spring? |
MappingCouchbaseConverter |
mappingCouchbaseConverter()
Creates a
MappingCouchbaseConverter using the configured couchbaseMappingContext(). |
RepositoryOperationsMapping |
repositoryOperationsMapping()
Creates the
RepositoryOperationsMapping bean which will be used by the framework to choose which
CouchbaseOperations should back which CouchbaseRepository. |
TranslationService |
translationService()
Creates a
TranslationService. |
String |
typeKey()
Determines the name of the field that will store the type information for complex types when
using the
mappingCouchbaseConverter(). |
protected abstract List<String> getBootstrapHosts()
protected abstract String getBucketName()
protected abstract String getBucketPassword()
protected boolean isEnvironmentManagedBySpring()
getEnvironment() to be destroyed by Spring?protected com.couchbase.client.java.env.CouchbaseEnvironment getEnvironment()
CouchbaseEnvironment.
This environment will be managed by Spring, which will call its shutdown()
method upon bean destruction, unless you override isEnvironmentManagedBySpring()
as well to return false.DefaultCouchbaseEnvironment.@Bean(destroyMethod="shutdown", name="couchbaseEnv") public com.couchbase.client.java.env.CouchbaseEnvironment couchbaseEnvironment()
@Bean(destroyMethod="disconnect", name="couchbaseCluster") public com.couchbase.client.java.Cluster couchbaseCluster() throws Exception
Cluster instance to connect to.Exception - on Bean construction failure.@Bean(name="couchbaseClusterInfo") public com.couchbase.client.java.cluster.ClusterInfo couchbaseClusterInfo() throws Exception
Exception@Bean(destroyMethod="close", name="couchbaseBucket") public com.couchbase.client.java.Bucket couchbaseClient() throws Exception
Bucket instance to connect to.Exception - on Bean construction failure.@Bean(name="couchbaseTemplate") public CouchbaseTemplate couchbaseTemplate() throws Exception
CouchbaseTemplate.
This uses couchbaseClusterInfo(), couchbaseClient(), mappingCouchbaseConverter(),
, translationService() and getDefaultConsistency() for construction.Exception - on Bean construction failure.@Bean(name="couchbaseRepositoryOperationsMapping") public RepositoryOperationsMapping repositoryOperationsMapping() throws Exception
RepositoryOperationsMapping bean which will be used by the framework to choose which
CouchbaseOperations should back which CouchbaseRepository.
Override configureRepositoryOperationsMapping(RepositoryOperationsMapping) in order to customize this.Exceptionprotected void configureRepositoryOperationsMapping(RepositoryOperationsMapping mapping)
mapping - the default mapping (will associate all repositories to the default template).public String typeKey()
mappingCouchbaseConverter().
Defaults to .@Bean(name="couchbaseMappingConverter") public MappingCouchbaseConverter mappingCouchbaseConverter() throws Exception
MappingCouchbaseConverter using the configured couchbaseMappingContext().Exception - on Bean construction failure.@Bean(name="couchbaseTranslationService") public TranslationService translationService()
TranslationService.@Bean(name="couchbaseMappingContext") public CouchbaseMappingContext couchbaseMappingContext() throws Exception
CouchbaseMappingContext equipped with entity classes scanned from the mapping base package.Exception - on Bean construction failure.@Bean(name="couchbaseCustomConversions") public CustomConversions customConversions()
CustomConversions object if required. These
CustomConversions will be registered with the mappingCouchbaseConverter() and
couchbaseMappingContext(). Returns an empty CustomConversions instance by default.@Bean(name="couchbaseIndexManager") public IndexManager indexManager()
IndexManager bean that will be used to process ViewIndexed,
N1qlPrimaryIndexed and N1qlSecondaryIndexed annotations on repositories
to automatically create indexes. By default, since such automatic creations are discouraged in
production envrironment, the configuration will assume the worst and will ignore these annotations.
If you are sure this configuration used in a context where such automatic creations are desired (eg.
you want automatic index creation in Dev, just not in Prod, and this configuration is the Dev one),
override the bean and use the IndexManager.IndexManager() constructor (or
IndexManager.IndexManager(boolean, boolean, boolean) constructor with appropriate flags set to true to
activate).protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException
Document.ClassNotFoundException - if initial entity sets could not be loaded.protected String getMappingBasePackage()
Documents. Will return the package name of the configuration
class (the concrete class, not this one here) by default.
So if you have a com.acme.AppConfig extending AbstractCouchbaseConfiguration the base package
will be considered com.acme unless the method is overridden to implement alternate behavior.
Document classes or null to not enable scanning for
entities.protected boolean abbreviateFieldNames()
CamelCaseAbbreviatingFieldNamingStrategy.protected FieldNamingStrategy fieldNamingStrategy()
FieldNamingStrategy on the CouchbaseMappingContext instance created.protected Consistency getDefaultConsistency()
view queries
and N1QL queries in repositories.consistency to apply by default on generated queries.Copyright © 2011-2015–2016 Pivotal Software, Inc.. All rights reserved.