1515 */
1616package org .springframework .vault .repository .mapping ;
1717
18+ import org .springframework .data .expression .ValueExpression ;
19+ import org .springframework .data .expression .ValueExpressionParser ;
1820import org .springframework .data .keyvalue .core .mapping .AnnotationBasedKeySpaceResolver ;
1921import org .springframework .data .keyvalue .core .mapping .BasicKeyValuePersistentEntity ;
2022import org .springframework .data .keyvalue .core .mapping .KeySpaceResolver ;
2123import org .springframework .data .util .TypeInformation ;
2224import org .springframework .expression .Expression ;
23- import org .springframework .expression .ParserContext ;
2425import org .springframework .expression .common .LiteralExpression ;
25- import org .springframework .expression .spel .standard .SpelExpressionParser ;
2626import org .springframework .lang .Nullable ;
27+ import org .springframework .util .ObjectUtils ;
2728import org .springframework .util .StringUtils ;
2829
2930/**
3536public class BasicVaultPersistentEntity <T > extends BasicKeyValuePersistentEntity <T , VaultPersistentProperty >
3637 implements VaultPersistentEntity <T > {
3738
38- private static final SpelExpressionParser PARSER = new SpelExpressionParser ();
39+ private static final ValueExpressionParser PARSER = ValueExpressionParser . create ();
3940
4041 private final String backend ;
4142
42- private final @ Nullable Expression backendExpression ;
43+ private final @ Nullable ValueExpression backendExpression ;
4344
4445 /**
4546 * Creates new {@link BasicVaultPersistentEntity}.
@@ -86,10 +87,9 @@ public BasicVaultPersistentEntity(TypeInformation<T> information, @Nullable KeyS
8687 * @return
8788 */
8889 @ Nullable
89- private static Expression detectExpression (String potentialExpression ) {
90-
91- Expression expression = PARSER .parseExpression (potentialExpression , ParserContext .TEMPLATE_EXPRESSION );
92- return expression instanceof LiteralExpression ? null : expression ;
90+ private static ValueExpression detectExpression (String potentialExpression ) {
91+ ValueExpression expression = PARSER .parse (potentialExpression );
92+ return expression .isLiteral () ? null : expression ;
9393 }
9494
9595 @ Override
@@ -102,7 +102,7 @@ public String getSecretBackend() {
102102
103103 return this .backendExpression == null //
104104 ? this .backend //
105- : this .backendExpression .getValue ( getEvaluationContext (null ), String . class );
105+ : ObjectUtils . nullSafeToString ( this .backendExpression .evaluate ( getValueEvaluationContext (null )) );
106106 }
107107
108108}
0 commit comments