diff --git a/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java b/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java index c36d5e8b..e38e0a0e 100644 --- a/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java +++ b/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java @@ -62,11 +62,7 @@ import static com.couchbase.client.java.ClusterOptions.*; * @author Subhashni Balakrishnan */ @Configuration -public abstract class AbstractCouchbaseConfiguration implements CouchbaseConfigurer { - - protected CouchbaseConfigurer couchbaseConfigurer() { - return this; - } +public abstract class AbstractCouchbaseConfiguration { public abstract String getConnectionString(); @@ -85,20 +81,18 @@ public abstract class AbstractCouchbaseConfiguration implements CouchbaseConfigu } @Bean - public CouchbaseClientFactory couchbaseClientFactory() throws Exception { - return new SimpleCouchbaseClientFactory(couchbaseConfigurer().couchbaseCluster(), getBucketName(), getScopeName()); + public CouchbaseClientFactory couchbaseClientFactory(Cluster couchbaseCluster) { + return new SimpleCouchbaseClientFactory(couchbaseCluster, getBucketName(), getScopeName()); } - @Override @Bean - public Cluster couchbaseCluster() throws Exception { + public Cluster couchbaseCluster(ClusterEnvironment couchbaseClusterEnvironment) { return Cluster.connect( getConnectionString(), - clusterOptions(authenticator()).environment(couchbaseConfigurer().couchbaseClusterEnvironment()) + clusterOptions(authenticator()).environment(couchbaseClusterEnvironment) ); } - @Override @Bean(destroyMethod = "shutdown") public ClusterEnvironment couchbaseClusterEnvironment() { ClusterEnvironment.Builder builder = ClusterEnvironment.builder(); @@ -148,7 +142,7 @@ public abstract class AbstractCouchbaseConfiguration implements CouchbaseConfigu */ protected Set> getInitialEntitySet() throws ClassNotFoundException { String basePackage = getMappingBasePackage(); - Set> initialEntitySet = new HashSet>(); + Set> initialEntitySet = new HashSet<>(); if (StringUtils.hasText(basePackage)) { ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider( diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseConfigurer.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseConfigurer.java deleted file mode 100644 index 041e583a..00000000 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseConfigurer.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2020 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.couchbase.config; - -import com.couchbase.client.java.Cluster; -import com.couchbase.client.java.env.ClusterEnvironment; - -/** - * Strategy interface for users to provide as a factory for custom components needed - * by the Couchbase integration. - * - * This allows to centralize instantiation of Couchbase SDK core elements. - * - * @author Stephane Nicoll - * @author Michael Nitschinger - */ -public interface CouchbaseConfigurer { - - /** - * Set up the underlying main {@link ClusterEnvironment}, allowing tuning of the Couchbase SDK. - * - * @throws Exception in case of error during the ClusterEnvironment instantiation. - */ - ClusterEnvironment couchbaseClusterEnvironment() throws Exception; - - /** - * Set up the underlying main {@link Cluster} reference to be used by the Spring Data framework - * when storing into Couchbase. - * - * @throws Exception in case of error during the Cluster instantiation. - */ - Cluster couchbaseCluster() throws Exception; - -}