Fix broken build

Fix couchbase support until a solution is determined for
https://jira.spring.io/browse/DATACOUCH-279

See gh-8200
pull/8204/head
Stephane Nicoll 8 years ago
parent e9029d223a
commit 98d2ed85e4

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

@ -17,8 +17,11 @@
package org.springframework.boot.autoconfigure.data.couchbase; package org.springframework.boot.autoconfigure.data.couchbase;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Set; import java.util.Set;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.cluster.ClusterInfo;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -35,7 +38,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.data.couchbase.config.AbstractCouchbaseDataConfiguration; import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
import org.springframework.data.couchbase.config.BeanNames; import org.springframework.data.couchbase.config.BeanNames;
import org.springframework.data.couchbase.config.CouchbaseConfigurer; import org.springframework.data.couchbase.config.CouchbaseConfigurer;
import org.springframework.data.couchbase.core.CouchbaseTemplate; import org.springframework.data.couchbase.core.CouchbaseTemplate;
@ -147,7 +150,32 @@ public class CouchbaseDataAutoConfigurationTests {
} }
@Configuration @Configuration
static class CustomCouchbaseConfiguration extends AbstractCouchbaseDataConfiguration { 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();
}
@Override @Override
protected CouchbaseConfigurer couchbaseConfigurer() { protected CouchbaseConfigurer couchbaseConfigurer() {

Loading…
Cancel
Save