File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
spring-context/src/main/java/org/springframework/context/event Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
87
87
/**
88
88
* Spring Expression Language (SpEL) attribute used for making the
89
89
* event handling conditional.
90
- * <p>Default is "", meaning the event is always handled.
90
+ * <p>Default is {@code ""}, meaning the event is always handled.
91
+ * <p>The SpEL expression evaluates against a dedicated context that
92
+ * provides the following meta-data:
93
+ * <ul>
94
+ * <li>{@code #root.event}, {@code #root.args} for
95
+ * references to the {@link ApplicationEvent} and method arguments
96
+ * respectively.</li>
97
+ * <li>Method arguments can be accessed by index. For instance the
98
+ * first argument can be accessed via {@code #root.args[0]}, {@code #p0}
99
+ * or {@code #a0}. Arguments can also be accessed by name if that
100
+ * information is available.</li>
101
+ * </ul>
91
102
*/
92
103
String condition () default "" ;
93
104
Original file line number Diff line number Diff line change @@ -8191,8 +8191,8 @@ event is equal to `foo`:
8191
8191
[source,java,indent=0]
8192
8192
[subs="verbatim,quotes"]
8193
8193
----
8194
- @EventListener(condition = "#event .test == 'foo'")
8195
- public void processBlackListEvent(BlackListEvent event ) {
8194
+ @EventListener(condition = "#blEvent .test == 'foo'")
8195
+ public void processBlackListEvent(BlackListEvent blEvent ) {
8196
8196
// notify appropriate parties via notificationAddress...
8197
8197
}
8198
8198
----
@@ -8205,22 +8205,22 @@ available to the context so one can use them for conditional event processing:
8205
8205
|===
8206
8206
| Name| Location| Description| Example
8207
8207
8208
- | event
8208
+ | Event
8209
8209
| root object
8210
8210
| The actual `ApplicationEvent`
8211
8211
| `#root.event`
8212
8212
8213
- | args
8213
+ | Arguments array
8214
8214
| root object
8215
8215
| The arguments (as array) used for invoking the target
8216
8216
| `#root.args[0]`
8217
8217
8218
- | __argument name__
8218
+ | __Argument name__
8219
8219
| evaluation context
8220
8220
| Name of any of the method arguments. If for some reason the names are not available
8221
8221
(e.g. no debug information), the argument names are also available under the `#a<#arg>`
8222
8222
where __#arg__ stands for the argument index (starting from 0).
8223
- | `#iban ` or `#a0` (one can also use `#p0` or `#p<#arg>` notation as an alias).
8223
+ | `#blEvent ` or `#a0` (one can also use `#p0` or `#p<#arg>` notation as an alias).
8224
8224
|===
8225
8225
8226
8226
Note that `#root.event` allows you to access to the underlying event, even if your method
You can’t perform that action at this time.
0 commit comments