17
17
18
18
import reactor .core .publisher .Flux ;
19
19
import reactor .core .publisher .Mono ;
20
+ import reactor .util .function .Tuple2 ;
20
21
21
22
import java .util .ArrayList ;
22
23
import java .util .List ;
26
27
import org .reactivestreams .Publisher ;
27
28
28
29
import org .springframework .core .convert .converter .Converter ;
29
- import org .springframework .core .env .StandardEnvironment ;
30
30
import org .springframework .data .expression .ReactiveValueEvaluationContextProvider ;
31
31
import org .springframework .data .expression .ValueEvaluationContext ;
32
32
import org .springframework .data .expression .ValueEvaluationContextProvider ;
33
33
import org .springframework .data .expression .ValueExpression ;
34
- import org .springframework .data .expression .ValueExpressionParser ;
35
34
import org .springframework .data .mapping .model .EntityInstantiators ;
36
- import org .springframework .data .mapping .model .SpELExpressionEvaluator ;
37
35
import org .springframework .data .mapping .model .ValueExpressionEvaluator ;
38
36
import org .springframework .data .mongodb .core .MongoOperations ;
39
37
import org .springframework .data .mongodb .core .ReactiveFindOperation .FindWithProjection ;
55
53
import org .springframework .data .mongodb .util .json .ParameterBindingContext ;
56
54
import org .springframework .data .mongodb .util .json .ParameterBindingDocumentCodec ;
57
55
import org .springframework .data .repository .query .ParameterAccessor ;
58
- import org .springframework .data .repository .query .QueryMethodValueEvaluationContextAccessor ;
59
- import org .springframework .data .repository .query .ReactiveQueryMethodEvaluationContextProvider ;
60
56
import org .springframework .data .repository .query .RepositoryQuery ;
61
57
import org .springframework .data .repository .query .ResultProcessor ;
62
58
import org .springframework .data .repository .query .ValueExpressionDelegate ;
63
59
import org .springframework .data .spel .ExpressionDependencies ;
64
60
import org .springframework .data .util .TypeInformation ;
65
- import org .springframework .expression .ExpressionParser ;
66
- import org .springframework .expression .spel .standard .SpelExpressionParser ;
67
61
import org .springframework .lang .Nullable ;
68
62
import org .springframework .util .Assert ;
69
63
import org .springframework .util .ObjectUtils ;
70
64
import org .springframework .util .StringUtils ;
71
65
72
66
import com .mongodb .MongoClientSettings ;
73
- import reactor .util .function .Tuple2 ;
74
67
75
68
/**
76
69
* Base class for reactive {@link RepositoryQuery} implementations for MongoDB.
@@ -90,41 +83,6 @@ public abstract class AbstractReactiveMongoQuery implements RepositoryQuery {
90
83
private final ValueExpressionDelegate valueExpressionDelegate ;
91
84
private final ReactiveValueEvaluationContextProvider valueEvaluationContextProvider ;
92
85
93
- /**
94
- * Creates a new {@link AbstractReactiveMongoQuery} from the given {@link MongoQueryMethod} and
95
- * {@link MongoOperations}.
96
- *
97
- * @param method must not be {@literal null}.
98
- * @param operations must not be {@literal null}.
99
- * @param expressionParser must not be {@literal null}.
100
- * @param evaluationContextProvider must not be {@literal null}.
101
- * @deprecated use the constructor version with {@link ValueExpressionDelegate}
102
- */
103
- @ Deprecated (since = "4.4.0" )
104
- public AbstractReactiveMongoQuery (ReactiveMongoQueryMethod method , ReactiveMongoOperations operations ,
105
- ExpressionParser expressionParser , ReactiveQueryMethodEvaluationContextProvider evaluationContextProvider ) {
106
-
107
- Assert .notNull (method , "MongoQueryMethod must not be null" );
108
- Assert .notNull (operations , "ReactiveMongoOperations must not be null" );
109
- Assert .notNull (expressionParser , "SpelExpressionParser must not be null" );
110
- Assert .notNull (evaluationContextProvider , "ReactiveEvaluationContextExtension must not be null" );
111
-
112
- this .method = method ;
113
- this .operations = operations ;
114
- this .instantiators = new EntityInstantiators ();
115
- this .valueExpressionDelegate = new ValueExpressionDelegate (new QueryMethodValueEvaluationContextAccessor (new StandardEnvironment (), evaluationContextProvider .getEvaluationContextProvider ()), ValueExpressionParser .create (() -> expressionParser ));
116
-
117
- MongoEntityMetadata <?> metadata = method .getEntityInformation ();
118
- Class <?> type = metadata .getCollectionEntity ().getType ();
119
-
120
- this .findOperationWithProjection = operations .query (type );
121
- this .updateOps = operations .update (type );
122
- ValueEvaluationContextProvider valueContextProvider = valueExpressionDelegate .createValueContextProvider (
123
- method .getParameters ());
124
- Assert .isInstanceOf (ReactiveValueEvaluationContextProvider .class , valueContextProvider , "ValueEvaluationContextProvider must be reactive" );
125
- this .valueEvaluationContextProvider = (ReactiveValueEvaluationContextProvider ) valueContextProvider ;
126
- }
127
-
128
86
/**
129
87
* Creates a new {@link AbstractReactiveMongoQuery} from the given {@link MongoQueryMethod} and
130
88
* {@link MongoOperations}.
@@ -151,9 +109,10 @@ public AbstractReactiveMongoQuery(ReactiveMongoQueryMethod method, ReactiveMongo
151
109
152
110
this .findOperationWithProjection = operations .query (type );
153
111
this .updateOps = operations .update (type );
154
- ValueEvaluationContextProvider valueContextProvider = valueExpressionDelegate .createValueContextProvider (
155
- method .getParameters ());
156
- Assert .isInstanceOf (ReactiveValueEvaluationContextProvider .class , valueContextProvider , "ValueEvaluationContextProvider must be reactive" );
112
+ ValueEvaluationContextProvider valueContextProvider = valueExpressionDelegate
113
+ .createValueContextProvider (method .getParameters ());
114
+ Assert .isInstanceOf (ReactiveValueEvaluationContextProvider .class , valueContextProvider ,
115
+ "ValueEvaluationContextProvider must be reactive" );
157
116
this .valueEvaluationContextProvider = (ReactiveValueEvaluationContextProvider ) valueContextProvider ;
158
117
}
159
118
@@ -439,8 +398,8 @@ private Mono<Tuple2<ValueExpressionEvaluator, ParameterBindingDocumentCodec>> ex
439
398
return getValueExpressionEvaluatorLater (dependencies , accessor ).zipWith (Mono .just (codec ));
440
399
}
441
400
442
- private Document decode (Tuple2 <ValueExpressionEvaluator , ParameterBindingDocumentCodec > expressionEvaluator , String source , MongoParameterAccessor accessor ,
443
- ParameterBindingDocumentCodec codec ) {
401
+ private Document decode (Tuple2 <ValueExpressionEvaluator , ParameterBindingDocumentCodec > expressionEvaluator ,
402
+ String source , MongoParameterAccessor accessor , ParameterBindingDocumentCodec codec ) {
444
403
445
404
ParameterBindingContext bindingContext = new ParameterBindingContext (accessor ::getBindableValue ,
446
405
expressionEvaluator .getT1 ());
@@ -457,26 +416,6 @@ protected Mono<ParameterBindingDocumentCodec> getParameterBindingCodec() {
457
416
return getCodecRegistry ().map (ParameterBindingDocumentCodec ::new );
458
417
}
459
418
460
- /**
461
- * Obtain a {@link Mono publisher} emitting the {@link SpELExpressionEvaluator} suitable to evaluate expressions
462
- * backed by the given dependencies.
463
- *
464
- * @param dependencies must not be {@literal null}.
465
- * @param accessor must not be {@literal null}.
466
- * @return a {@link Mono} emitting the {@link SpELExpressionEvaluator} when ready.
467
- * @since 3.4
468
- * @deprecated since 4.4.0, use
469
- * {@link #getValueExpressionEvaluatorLater(ExpressionDependencies, MongoParameterAccessor)} instead
470
- */
471
- @ Deprecated (since = "4.4.0" )
472
- protected Mono <SpELExpressionEvaluator > getSpelEvaluatorFor (ExpressionDependencies dependencies ,
473
- MongoParameterAccessor accessor ) {
474
- return valueEvaluationContextProvider .getEvaluationContextLater (accessor .getValues (), dependencies )
475
- .map (evaluationContext -> (SpELExpressionEvaluator ) new DefaultSpELExpressionEvaluator (
476
- new SpelExpressionParser (), evaluationContext .getEvaluationContext ()))
477
- .defaultIfEmpty (DefaultSpELExpressionEvaluator .unsupported ());
478
- }
479
-
480
419
/**
481
420
* Obtain a {@link ValueExpressionEvaluator} suitable to evaluate expressions.
482
421
*
@@ -490,8 +429,8 @@ ValueExpressionEvaluator getValueExpressionEvaluator(MongoParameterAccessor acce
490
429
@ Override
491
430
public <T > T evaluate (String expressionString ) {
492
431
ValueExpression expression = valueExpressionDelegate .parse (expressionString );
493
- ValueEvaluationContext evaluationContext = valueEvaluationContextProvider . getEvaluationContext ( accessor . getValues (),
494
- expression .getExpressionDependencies ());
432
+ ValueEvaluationContext evaluationContext = valueEvaluationContextProvider
433
+ . getEvaluationContext ( accessor . getValues (), expression .getExpressionDependencies ());
495
434
return (T ) expression .evaluate (evaluationContext );
496
435
}
497
436
};
@@ -509,8 +448,9 @@ public <T> T evaluate(String expressionString) {
509
448
protected Mono <ValueExpressionEvaluator > getValueExpressionEvaluatorLater (ExpressionDependencies dependencies ,
510
449
MongoParameterAccessor accessor ) {
511
450
512
- return valueEvaluationContextProvider .getEvaluationContextLater (accessor .getValues (), dependencies )
513
- .map (evaluationContext -> new ValueExpressionDelegateValueExpressionEvaluator (valueExpressionDelegate , valueExpression -> evaluationContext ));
451
+ return valueEvaluationContextProvider .getEvaluationContextLater (accessor .getValues (), dependencies )
452
+ .map (evaluationContext -> new ValueExpressionDelegateValueExpressionEvaluator (valueExpressionDelegate ,
453
+ valueExpression -> evaluationContext ));
514
454
}
515
455
516
456
/**
0 commit comments