17
17
package org .springframework .data .couchbase .config ;
18
18
19
19
import static com .couchbase .client .java .ClusterOptions .clusterOptions ;
20
- import static org .springframework .data .couchbase .config .BeanNames .COUCHBASE_MAPPING_CONTEXT ;
21
20
22
21
import java .util .Collections ;
23
22
import java .util .HashSet ;
24
23
import java .util .Set ;
25
24
26
- import com .couchbase .client .java .query .QueryScanConsistency ;
27
25
import org .springframework .beans .factory .config .BeanDefinition ;
28
26
import org .springframework .context .annotation .Bean ;
29
27
import org .springframework .context .annotation .ClassPathScanningCandidateComponentProvider ;
67
65
import com .couchbase .client .java .env .ClusterEnvironment ;
68
66
import com .couchbase .client .java .json .JacksonTransformers ;
69
67
import com .couchbase .client .java .json .JsonValueModule ;
68
+ import com .couchbase .client .java .query .QueryScanConsistency ;
70
69
import com .fasterxml .jackson .databind .ObjectMapper ;
71
70
72
71
/**
@@ -136,17 +135,11 @@ protected Authenticator authenticator() {
136
135
public CouchbaseClientFactory couchbaseClientFactory (final Cluster couchbaseCluster ) {
137
136
return new SimpleCouchbaseClientFactory (couchbaseCluster , getBucketName (), getScopeName ());
138
137
}
139
- /*
140
- @Bean
141
- public ReactiveCouchbaseClientFactory reactiveCouchbaseClientFactory(final Cluster couchbaseCluster) {
142
- return new SimpleReactiveCouchbaseClientFactory(couchbaseCluster, getBucketName(), getScopeName());
143
- }
144
- */
138
+
145
139
@ Bean (destroyMethod = "disconnect" )
146
140
public Cluster couchbaseCluster (ClusterEnvironment couchbaseClusterEnvironment ) {
147
- Cluster c = Cluster .connect (getConnectionString (),
141
+ return Cluster .connect (getConnectionString (),
148
142
clusterOptions (authenticator ()).environment (couchbaseClusterEnvironment ));
149
- return c ;
150
143
}
151
144
152
145
@ Bean (destroyMethod = "shutdown" )
@@ -171,29 +164,24 @@ protected void configureEnvironment(final ClusterEnvironment.Builder builder) {
171
164
172
165
@ Bean (name = BeanNames .COUCHBASE_TEMPLATE )
173
166
public CouchbaseTemplate couchbaseTemplate (CouchbaseClientFactory couchbaseClientFactory ,
174
- MappingCouchbaseConverter mappingCouchbaseConverter , TranslationService couchbaseTranslationService ) {
175
- return new CouchbaseTemplate (couchbaseClientFactory ,
176
- mappingCouchbaseConverter ,
177
- couchbaseTranslationService , getDefaultConsistency ());
167
+ MappingCouchbaseConverter mappingCouchbaseConverter , TranslationService couchbaseTranslationService ) {
168
+ return new CouchbaseTemplate (couchbaseClientFactory , mappingCouchbaseConverter , couchbaseTranslationService ,
169
+ getDefaultConsistency ());
178
170
}
179
171
180
172
public CouchbaseTemplate couchbaseTemplate (CouchbaseClientFactory couchbaseClientFactory ,
181
- MappingCouchbaseConverter mappingCouchbaseConverter ) {
182
- return couchbaseTemplate (couchbaseClientFactory ,
183
- mappingCouchbaseConverter ,
184
- new JacksonTranslationService ());
173
+ MappingCouchbaseConverter mappingCouchbaseConverter ) {
174
+ return couchbaseTemplate (couchbaseClientFactory , mappingCouchbaseConverter , new JacksonTranslationService ());
185
175
}
186
176
187
177
@ Bean (name = BeanNames .REACTIVE_COUCHBASE_TEMPLATE )
188
- public ReactiveCouchbaseTemplate reactiveCouchbaseTemplate (
189
- CouchbaseClientFactory couchbaseClientFactory ,
178
+ public ReactiveCouchbaseTemplate reactiveCouchbaseTemplate (CouchbaseClientFactory couchbaseClientFactory ,
190
179
MappingCouchbaseConverter mappingCouchbaseConverter , TranslationService couchbaseTranslationService ) {
191
- return new ReactiveCouchbaseTemplate (couchbaseClientFactory , mappingCouchbaseConverter ,
192
- couchbaseTranslationService , getDefaultConsistency ());
180
+ return new ReactiveCouchbaseTemplate (couchbaseClientFactory , mappingCouchbaseConverter , couchbaseTranslationService ,
181
+ getDefaultConsistency ());
193
182
}
194
183
195
- public ReactiveCouchbaseTemplate reactiveCouchbaseTemplate (
196
- CouchbaseClientFactory couchbaseClientFactory ,
184
+ public ReactiveCouchbaseTemplate reactiveCouchbaseTemplate (CouchbaseClientFactory couchbaseClientFactory ,
197
185
MappingCouchbaseConverter mappingCouchbaseConverter ) {
198
186
return reactiveCouchbaseTemplate (couchbaseClientFactory , mappingCouchbaseConverter ,
199
187
new JacksonTranslationService ());
@@ -301,7 +289,7 @@ public TranslationService couchbaseTranslationService() {
301
289
/**
302
290
* Creates a {@link CouchbaseMappingContext} equipped with entity classes scanned from the mapping base package.
303
291
*/
304
- @ Bean (COUCHBASE_MAPPING_CONTEXT )
292
+ @ Bean (BeanNames . COUCHBASE_MAPPING_CONTEXT )
305
293
public CouchbaseMappingContext couchbaseMappingContext (CustomConversions customConversions ) throws Exception {
306
294
CouchbaseMappingContext mappingContext = new CouchbaseMappingContext ();
307
295
mappingContext .setInitialEntitySet (getInitialEntitySet ());
@@ -358,7 +346,8 @@ public CouchbaseTransactionalOperator transactionalOperator(
358
346
@ Role (BeanDefinition .ROLE_INFRASTRUCTURE )
359
347
public TransactionInterceptor transactionInterceptor (TransactionManager couchbaseTransactionManager ) {
360
348
TransactionAttributeSource transactionAttributeSource = new AnnotationTransactionAttributeSource ();
361
- TransactionInterceptor interceptor = new CouchbaseTransactionInterceptor (couchbaseTransactionManager , transactionAttributeSource );
349
+ TransactionInterceptor interceptor = new CouchbaseTransactionInterceptor (couchbaseTransactionManager ,
350
+ transactionAttributeSource );
362
351
interceptor .setTransactionAttributeSource (transactionAttributeSource );
363
352
if (couchbaseTransactionManager != null ) {
364
353
interceptor .setTransactionManager (couchbaseTransactionManager );
0 commit comments