Skip to content

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

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

Closed
spring-projects-issues opened this issue Oct 14, 2016 · 1 comment
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

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.

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3.4 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants