Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on @EventListener SpEL features is not very clear [SPR-14812] #19378

Closed
spring-projects-issues opened this issue Oct 14, 2016 · 1 comment

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 14, 2016

Dave Syer opened SPR-14812 and commented

The documentation has an example where the condition in an @EventListener uses #event in a SpEL expression. Then there is a table where all the examples are #root.*. What is this #root, and why is it not used in the previous example? What are "the arguments (as array) used for invoking the target"? What is the target - isn't the listener method always invoked with a single argument, which is an event (all the examples look like that)?


Reference URL: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#context-functionality-events-annotation

Referenced from: commits 19db042, 0254102, 196200b

Backported to: 4.2.9

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 15, 2016

Stéphane Nicoll commented

Interesting. I guess you must be complaining about the cache documentation for SpEL as well. That example made the mistake of naming the parameter "event" I guess.

A SpEL expression can be parsed against a root object. That root object can be any pojo and expose whatever contextual property you want. In the case of events, this is EventExpressionRootObject

The section before that table states

Each SpEL expression evaluates again a dedicated context. The next table lists the items made available to the context so one can use them for conditional event processing:

Which is basically what I just explained. I should add such "context" is mapped to #root.

I guess the args parameter is rather dumb isn't it? I assumed I started with the idea to support more use cases and never revisited the decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants