Skip to content

Commit 390c4f5

Browse files
committed
DATACMNS-1838 - Accept ExpressionDependencies in BasicPersistentEntity.getEvaluationContext(…).
Allow obtaining an EvaluationContext with a reduced set of extensions that are required for ExpressionDependencies instead of initializing all extensions.
1 parent 949457f commit 390c4f5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.data.domain.Persistable;
3636
import org.springframework.data.mapping.*;
3737
import org.springframework.data.spel.EvaluationContextProvider;
38+
import org.springframework.data.spel.ExpressionDependencies;
3839
import org.springframework.data.support.IsNewStrategy;
3940
import org.springframework.data.support.PersistableIsNewStrategy;
4041
import org.springframework.data.util.Lazy;
@@ -537,10 +538,29 @@ public P next() {
537538
};
538539
}
539540

541+
/**
542+
* Obtain a {@link EvaluationContext} for a {@code rootObject}.
543+
*
544+
* @param rootObject must not be {@literal null}.
545+
* @return the evaluation context including all potential extensions.
546+
* @since 2.1
547+
*/
540548
protected EvaluationContext getEvaluationContext(Object rootObject) {
541549
return evaluationContextProvider.getEvaluationContext(rootObject);
542550
}
543551

552+
/**
553+
* Obtain a {@link EvaluationContext} for a {@code rootObject} given {@link ExpressionDependencies}.
554+
*
555+
* @param rootObject must not be {@literal null}.
556+
* @param dependencies must not be {@literal null}.
557+
* @return the evaluation context with extensions loaded that satisfy {@link ExpressionDependencies}.
558+
* @since 2.4.2
559+
*/
560+
protected EvaluationContext getEvaluationContext(Object rootObject, ExpressionDependencies dependencies) {
561+
return evaluationContextProvider.getEvaluationContext(rootObject, dependencies);
562+
}
563+
544564
/**
545565
* Returns the default {@link IsNewStrategy} to be used. Will be a {@link PersistentEntityIsNewStrategy} by default.
546566
* Note, that this strategy only gets used if the entity doesn't implement {@link Persistable} as this indicates the

0 commit comments

Comments
 (0)