forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate Couchbase setup from Spring Data
This commit separates the basic setup of Couchbase from Spring Data so that a `Bucket` and `Cluster` bucket beans are exposed even if Spring Data is not available. A basic setup happens if `spring.couchbase.bootstrap-hosts` is specified, configuring the `default` bucket with no authentication unless specified otherwise. If Spring Data is available, those beans are re-used by default to configure the `CouchbaseTemplate` and other repository-related beans. Closes spring-projectsgh-5347
- Loading branch information
Showing
20 changed files
with
835 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...gframework/boot/autoconfigure/data/couchbase/CouchbaseConfigurerAdapterConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://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.boot.autoconfigure.data.couchbase; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration.CouchbaseConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.couchbase.config.CouchbaseConfigurer; | ||
|
||
/** | ||
* Adapt the core Couchbase configuration to an expected {@link CouchbaseConfigurer} | ||
* if necessary. | ||
* | ||
* @author Stephane Nicoll | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass(CouchbaseConfigurer.class) | ||
@ConditionalOnBean(CouchbaseConfiguration.class) | ||
class CouchbaseConfigurerAdapterConfiguration { | ||
|
||
private final CouchbaseConfiguration configuration; | ||
|
||
CouchbaseConfigurerAdapterConfiguration(CouchbaseConfiguration configuration) { | ||
this.configuration = configuration; | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public CouchbaseConfigurer springBootCouchbaseConfigurer() throws Exception { | ||
return new SpringBootCouchbaseConfigurer(this.configuration.couchbaseEnvironment(), | ||
this.configuration.couchbaseCluster(), this.configuration.couchbaseClusterInfo(), | ||
this.configuration.couchbaseClient()); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://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.boot.autoconfigure.data.couchbase; | ||
|
||
import javax.validation.Validator; | ||
|
||
import com.couchbase.client.java.Bucket; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.data.couchbase.core.mapping.event.ValidatingCouchbaseEventListener; | ||
import org.springframework.data.couchbase.repository.CouchbaseRepository; | ||
|
||
/** | ||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Couchbase support. | ||
* | ||
* @author Eddú Meléndez | ||
* @author Stephane Nicoll | ||
* @since 1.4.0 | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({Bucket.class, CouchbaseRepository.class}) | ||
@AutoConfigureAfter(CouchbaseAutoConfiguration.class) | ||
@EnableConfigurationProperties(CouchbaseDataProperties.class) | ||
@Import({ CouchbaseConfigurerAdapterConfiguration.class, | ||
SpringBootCouchbaseDataConfiguration.class }) | ||
public class CouchbaseDataAutoConfiguration { | ||
|
||
@Configuration | ||
@ConditionalOnClass(Validator.class) | ||
public static class ValidationConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnBean(Validator.class) | ||
public ValidatingCouchbaseEventListener validationEventListener( | ||
Validator validator) { | ||
return new ValidatingCouchbaseEventListener(validator); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.