Restore couchbase support
This commit effectively reverts the changes that were applied to workaround the breakage in spring-data-couchbase. Closes gh-8200
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -17,11 +17,8 @@
|
||||
package org.springframework.boot.autoconfigure.data.couchbase;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.couchbase.client.java.Cluster;
|
||||
import com.couchbase.client.java.cluster.ClusterInfo;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -38,7 +35,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
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;
|
||||
@@ -150,32 +147,7 @@ public class CouchbaseDataAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomCouchbaseConfiguration extends AbstractCouchbaseConfiguration {
|
||||
|
||||
@Override
|
||||
protected List<String> getBootstrapHosts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBucketName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBucketPassword() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cluster couchbaseCluster() throws Exception {
|
||||
return couchbaseConfigurer().couchbaseCluster();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterInfo couchbaseClusterInfo() throws Exception {
|
||||
return couchbaseConfigurer().couchbaseClusterInfo();
|
||||
}
|
||||
static class CustomCouchbaseConfiguration extends AbstractCouchbaseDataConfiguration {
|
||||
|
||||
@Override
|
||||
protected CouchbaseConfigurer couchbaseConfigurer() {
|
||||
|
||||
@@ -17,7 +17,6 @@ package sample.data.couchbase;
|
||||
|
||||
import java.net.ConnectException;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -33,7 +32,6 @@ public class SampleCouchbaseApplicationTests {
|
||||
public OutputCapture outputCapture = new OutputCapture();
|
||||
|
||||
@Test
|
||||
@Ignore("See #8200")
|
||||
public void testDefaultSettings() throws Exception {
|
||||
try {
|
||||
new SpringApplicationBuilder(SampleCouchbaseApplication.class)
|
||||
|
||||
Reference in New Issue
Block a user