|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
|
* Copyright 2012-2016 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -16,22 +16,17 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.data.couchbase;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import com.couchbase.client.java.Cluster;
|
|
|
|
|
import com.couchbase.client.java.cluster.ClusterInfo;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties;
|
|
|
|
|
import org.springframework.boot.autoconfigure.domain.EntityScanner;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.data.annotation.Persistent;
|
|
|
|
|
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
|
|
|
|
|
import org.springframework.data.couchbase.config.AbstractCouchbaseDataConfiguration;
|
|
|
|
|
import org.springframework.data.couchbase.config.BeanNames;
|
|
|
|
|
import org.springframework.data.couchbase.config.CouchbaseConfigurer;
|
|
|
|
|
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
|
|
|
@ -46,53 +41,24 @@ import org.springframework.data.couchbase.repository.support.IndexManager;
|
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
|
*/
|
|
|
|
|
@Configuration
|
|
|
|
|
@ConditionalOnMissingBean(AbstractCouchbaseConfiguration.class)
|
|
|
|
|
@ConditionalOnMissingBean(AbstractCouchbaseDataConfiguration.class)
|
|
|
|
|
@ConditionalOnBean(CouchbaseConfigurer.class)
|
|
|
|
|
class SpringBootCouchbaseDataConfiguration extends AbstractCouchbaseConfiguration {
|
|
|
|
|
class SpringBootCouchbaseDataConfiguration extends AbstractCouchbaseDataConfiguration {
|
|
|
|
|
|
|
|
|
|
private final ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
private final CouchbaseProperties properties;
|
|
|
|
|
|
|
|
|
|
private final CouchbaseDataProperties dataProperties;
|
|
|
|
|
private final CouchbaseDataProperties properties;
|
|
|
|
|
|
|
|
|
|
private final CouchbaseConfigurer couchbaseConfigurer;
|
|
|
|
|
|
|
|
|
|
SpringBootCouchbaseDataConfiguration(ApplicationContext applicationContext,
|
|
|
|
|
CouchbaseProperties properties,
|
|
|
|
|
CouchbaseDataProperties dataProperties,
|
|
|
|
|
CouchbaseDataProperties properties,
|
|
|
|
|
ObjectProvider<CouchbaseConfigurer> couchbaseConfigurer) {
|
|
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
|
this.properties = properties;
|
|
|
|
|
this.dataProperties = dataProperties;
|
|
|
|
|
this.couchbaseConfigurer = couchbaseConfigurer.getIfAvailable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected List<String> getBootstrapHosts() {
|
|
|
|
|
return this.properties.getBootstrapHosts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected String getBucketName() {
|
|
|
|
|
return this.properties.getBucket().getName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected String getBucketPassword() {
|
|
|
|
|
return this.properties.getBucket().getPassword();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Cluster couchbaseCluster() throws Exception {
|
|
|
|
|
return couchbaseConfigurer().couchbaseCluster();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ClusterInfo couchbaseClusterInfo() throws Exception {
|
|
|
|
|
return couchbaseConfigurer().couchbaseClusterInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected CouchbaseConfigurer couchbaseConfigurer() {
|
|
|
|
|
return this.couchbaseConfigurer;
|
|
|
|
@ -100,7 +66,7 @@ class SpringBootCouchbaseDataConfiguration extends AbstractCouchbaseConfiguratio
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Consistency getDefaultConsistency() {
|
|
|
|
|
return this.dataProperties.getConsistency();
|
|
|
|
|
return this.properties.getConsistency();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -127,7 +93,7 @@ class SpringBootCouchbaseDataConfiguration extends AbstractCouchbaseConfiguratio
|
|
|
|
|
@ConditionalOnMissingBean(name = BeanNames.COUCHBASE_INDEX_MANAGER)
|
|
|
|
|
@Bean(name = BeanNames.COUCHBASE_INDEX_MANAGER)
|
|
|
|
|
public IndexManager indexManager() {
|
|
|
|
|
if (this.dataProperties.isAutoIndex()) {
|
|
|
|
|
if (this.properties.isAutoIndex()) {
|
|
|
|
|
return new IndexManager(true, true, true);
|
|
|
|
|
}
|
|
|
|
|
return new IndexManager(false, false, false);
|
|
|
|
|