18
18
19
19
import static com .couchbase .client .java .ClusterOptions .clusterOptions ;
20
20
21
- import java .util .ArrayList ;
21
+ import java .util .Collections ;
22
22
import java .util .HashSet ;
23
- import java .util .List ;
24
23
import java .util .Set ;
25
24
26
25
import org .springframework .beans .factory .config .BeanDefinition ;
27
26
import org .springframework .context .annotation .Bean ;
28
27
import org .springframework .context .annotation .ClassPathScanningCandidateComponentProvider ;
29
28
import org .springframework .context .annotation .Configuration ;
30
29
import org .springframework .context .annotation .Role ;
31
- import org .springframework .core .convert .converter .GenericConverter ;
32
30
import org .springframework .core .type .filter .AnnotationTypeFilter ;
33
31
import org .springframework .data .convert .CustomConversions ;
34
32
import org .springframework .data .couchbase .CouchbaseClientFactory ;
37
35
import org .springframework .data .couchbase .core .ReactiveCouchbaseTemplate ;
38
36
import org .springframework .data .couchbase .core .convert .CouchbaseCustomConversions ;
39
37
import org .springframework .data .couchbase .core .convert .MappingCouchbaseConverter ;
40
- import org .springframework .data .couchbase .core .convert .OtherConverters ;
41
38
import org .springframework .data .couchbase .core .convert .translation .JacksonTranslationService ;
42
39
import org .springframework .data .couchbase .core .convert .translation .TranslationService ;
43
40
import org .springframework .data .couchbase .core .mapping .CouchbaseMappingContext ;
@@ -152,9 +149,7 @@ public ClusterEnvironment couchbaseClusterEnvironment() {
152
149
if (!nonShadowedJacksonPresent ()) {
153
150
throw new CouchbaseException ("non-shadowed Jackson not present" );
154
151
}
155
- CryptoManager cryptoManager = cryptoManager ();
156
- builder .jsonSerializer (JacksonJsonSerializer .create (couchbaseObjectMapper (cryptoManager )));
157
- builder .cryptoManager (cryptoManager );
152
+ builder .jsonSerializer (JacksonJsonSerializer .create (couchbaseObjectMapper ()));
158
153
configureEnvironment (builder );
159
154
return builder .build ();
160
155
}
@@ -285,8 +280,8 @@ public MappingCouchbaseConverter mappingCouchbaseConverter(CouchbaseMappingConte
285
280
@ Bean
286
281
public TranslationService couchbaseTranslationService () {
287
282
final JacksonTranslationService jacksonTranslationService = new JacksonTranslationService ();
288
- jacksonTranslationService .setObjectMapper (couchbaseObjectMapper (cryptoManager ()));
289
283
jacksonTranslationService .afterPropertiesSet ();
284
+
290
285
// for sdk3, we need to ask the mapper _it_ uses to ignore extra fields...
291
286
JacksonTransformers .MAPPER .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false );
292
287
return jacksonTranslationService ;
@@ -313,25 +308,10 @@ public CouchbaseMappingContext couchbaseMappingContext(CustomConversions customC
313
308
*/
314
309
315
310
public ObjectMapper couchbaseObjectMapper () {
316
- return couchbaseObjectMapper (cryptoManager ());
317
- }
318
-
319
- /**
320
- * Creates a {@link ObjectMapper} for the jsonSerializer of the ClusterEnvironment
321
- *
322
- * @param cryptoManager
323
- * @return ObjectMapper
324
- */
325
-
326
- ObjectMapper mapper ;
327
-
328
- public ObjectMapper couchbaseObjectMapper (CryptoManager cryptoManager ) {
329
- if (mapper != null ) {
330
- return mapper ;
331
- }
332
- mapper = new ObjectMapper (); // or use the one from the Java SDK (?) JacksonTransformers.MAPPER
311
+ ObjectMapper mapper = new ObjectMapper ();
333
312
mapper .configure (com .fasterxml .jackson .databind .DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false );
334
313
mapper .registerModule (new JsonValueModule ());
314
+ CryptoManager cryptoManager = null ;
335
315
if (cryptoManager != null ) {
336
316
mapper .registerModule (new EncryptionModule (cryptoManager ));
337
317
}
@@ -340,7 +320,7 @@ public ObjectMapper couchbaseObjectMapper(CryptoManager cryptoManager) {
340
320
341
321
/**
342
322
* The default blocking transaction manager. It is an implementation of CallbackPreferringTransactionManager
343
- * CallbackPreferringTransactionManagers do not play well with test-cases that rely
323
+ * CallbackPreferrringTransactionmanagers do not play well with test-cases that rely
344
324
* on @TestTransaction/@BeforeTransaction/@AfterTransaction
345
325
*
346
326
* @param clientFactory
@@ -361,7 +341,6 @@ CouchbaseCallbackTransactionManager couchbaseTransactionManager(CouchbaseClientF
361
341
TransactionTemplate couchbaseTransactionTemplate (CouchbaseCallbackTransactionManager couchbaseTransactionManager ) {
362
342
return new TransactionTemplate (couchbaseTransactionManager );
363
343
}
364
-
365
344
/**
366
345
* The default TransactionalOperator.
367
346
*
@@ -400,28 +379,11 @@ protected boolean autoIndexCreation() {
400
379
* and {@link #couchbaseMappingContext(CustomConversions)}. Returns an empty {@link CustomConversions} instance by
401
380
* default.
402
381
*
403
- * @param cryptoManagerOptional optional cryptoManager. Make varargs for backwards compatibility.
404
382
* @return must not be {@literal null}.
405
383
*/
406
384
@ Bean (name = BeanNames .COUCHBASE_CUSTOM_CONVERSIONS )
407
- public CustomConversions customConversions (CryptoManager ... cryptoManagerOptional ) {
408
- assert (cryptoManagerOptional == null || cryptoManagerOptional .length <= 1 );
409
- CryptoManager cryptoManager = cryptoManagerOptional != null && cryptoManagerOptional .length == 1
410
- ? cryptoManagerOptional [0 ]
411
- : null ;
412
- List <GenericConverter > newConverters = new ArrayList ();
413
- // the cryptoConverters take an argument, so they cannot be created in the
414
- // static block of CouchbaseCustomConversions. And they must be set before the super() constructor
415
- // in CouchbaseCustomerConversions
416
- if (cryptoManager != null ) {
417
- newConverters .addAll (OtherConverters .getCryptoConverters (cryptoManager ));
418
- }
419
- return new CouchbaseCustomConversions (newConverters );
420
- }
421
-
422
- @ Bean
423
- protected CryptoManager cryptoManager () {
424
- return null ;
385
+ public CustomConversions customConversions () {
386
+ return new CouchbaseCustomConversions (Collections .emptyList ());
425
387
}
426
388
427
389
/**
0 commit comments