1
1
[[expressions-bean-references]]
2
2
= Bean References
3
3
4
- If the evaluation context has been configured with a bean resolver, you can
5
- look up beans from an expression by using the `@` symbol. The following example shows how
4
+ If the evaluation context has been configured with a bean resolver, you can look up beans
5
+ from an expression by using the `@` symbol as a prefix . The following example shows how
6
6
to do so:
7
7
8
8
[tabs]
15
15
StandardEvaluationContext context = new StandardEvaluationContext();
16
16
context.setBeanResolver(new MyBeanResolver());
17
17
18
- // This will end up calling resolve(context,"something") on MyBeanResolver during evaluation
19
- Object bean = parser.parseExpression("@something").getValue(context);
18
+ // This will end up calling resolve(context, "someBean") on MyBeanResolver
19
+ // during evaluation.
20
+ Object bean = parser.parseExpression("@someBean").getValue(context);
20
21
----
21
22
22
23
Kotlin::
@@ -27,13 +28,20 @@ Kotlin::
27
28
val context = StandardEvaluationContext()
28
29
context.setBeanResolver(MyBeanResolver())
29
30
30
- // This will end up calling resolve(context,"something") on MyBeanResolver during evaluation
31
- val bean = parser.parseExpression("@something").getValue(context)
31
+ // This will end up calling resolve(context, "someBean") on MyBeanResolver
32
+ // during evaluation.
33
+ val bean = parser.parseExpression("@someBean").getValue(context)
32
34
----
33
35
======
34
36
35
- To access a factory bean itself, you should instead prefix the bean name with an `&` symbol.
36
- The following example shows how to do so:
37
+ [NOTE]
38
+ ====
39
+ If a bean name contains a dot (`.`) or other special characters, you must provide the
40
+ name of the bean as a _string literal_ – for example, `@'order.service'`.
41
+ ====
42
+
43
+ To access a factory bean itself, you should instead prefix the bean name with an `&`
44
+ symbol. The following example shows how to do so:
37
45
38
46
[tabs]
39
47
======
45
53
StandardEvaluationContext context = new StandardEvaluationContext();
46
54
context.setBeanResolver(new MyBeanResolver());
47
55
48
- // This will end up calling resolve(context,"&foo") on MyBeanResolver during evaluation
49
- Object bean = parser.parseExpression("&foo").getValue(context);
56
+ // This will end up calling resolve(context, "&someFactoryBean") on
57
+ // MyBeanResolver during evaluation.
58
+ Object factoryBean = parser.parseExpression("&someFactoryBean").getValue(context);
50
59
----
51
60
52
61
Kotlin::
@@ -57,9 +66,8 @@ Kotlin::
57
66
val context = StandardEvaluationContext()
58
67
context.setBeanResolver(MyBeanResolver())
59
68
60
- // This will end up calling resolve(context,"&foo") on MyBeanResolver during evaluation
61
- val bean = parser.parseExpression("&foo").getValue(context)
69
+ // This will end up calling resolve(context, "&someFactoryBean") on
70
+ // MyBeanResolver during evaluation.
71
+ val factoryBean = parser.parseExpression("&someFactoryBean").getValue(context)
62
72
----
63
73
======
64
-
65
-
0 commit comments