parent
c062835702
commit
196200bcc0
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -87,7 +87,18 @@ public @interface EventListener {
|
|||
/**
|
||||
* Spring Expression Language (SpEL) attribute used for making the
|
||||
* event handling conditional.
|
||||
* <p>Default is "", meaning the event is always handled.
|
||||
* <p>Default is {@code ""}, meaning the event is always handled.
|
||||
* <p>The SpEL expression evaluates against a dedicated context that
|
||||
* provides the following meta-data:
|
||||
* <ul>
|
||||
* <li>{@code #root.event}, {@code #root.args} for
|
||||
* references to the {@link ApplicationEvent} and method arguments
|
||||
* respectively.</li>
|
||||
* <li>Method arguments can be accessed by index. For instance the
|
||||
* first argument can be accessed via {@code #root.args[0]}, {@code #p0}
|
||||
* or {@code #a0}. Arguments can also be accessed by name if that
|
||||
* information is available.</li>
|
||||
* </ul>
|
||||
*/
|
||||
String condition() default "";
|
||||
|
||||
|
|
|
@ -8314,8 +8314,8 @@ event is equal to `foo`:
|
|||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@EventListener(condition = "#event.test == 'foo'")
|
||||
public void processBlackListEvent(BlackListEvent event) {
|
||||
@EventListener(condition = "#blEvent.test == 'foo'")
|
||||
public void processBlackListEvent(BlackListEvent blEvent) {
|
||||
// notify appropriate parties via notificationAddress...
|
||||
}
|
||||
----
|
||||
|
@ -8328,22 +8328,22 @@ available to the context so one can use them for conditional event processing:
|
|||
|===
|
||||
| Name| Location| Description| Example
|
||||
|
||||
| event
|
||||
| Event
|
||||
| root object
|
||||
| The actual `ApplicationEvent`
|
||||
| `#root.event`
|
||||
|
||||
| args
|
||||
| Arguments array
|
||||
| root object
|
||||
| The arguments (as array) used for invoking the target
|
||||
| `#root.args[0]`
|
||||
|
||||
| __argument name__
|
||||
| __Argument name__
|
||||
| evaluation context
|
||||
| Name of any of the method arguments. If for some reason the names are not available
|
||||
(e.g. no debug information), the argument names are also available under the `#a<#arg>`
|
||||
where __#arg__ stands for the argument index (starting from 0).
|
||||
| `#iban` or `#a0` (one can also use `#p0` or `#p<#arg>` notation as an alias).
|
||||
| `#blEvent` or `#a0` (one can also use `#p0` or `#p<#arg>` notation as an alias).
|
||||
|===
|
||||
|
||||
Note that `#root.event` allows you to access to the underlying event, even if your method
|
||||
|
|
Loading…
Reference in New Issue