Skip to content

Genericize ApplicationListener [SPR-4610] #9287

Closed

Description

@spring-projects-issues

Paul Benedict opened SPR-4610 and commented

It would be fantastic if ApplicationListener could be genericized so that the event argument automatically becomes the parameterized type. Maybe worth looking at in 3.0? In any event (pun intended), the framework could then skip over invoking the handler if the typed argument is not the correct type. This would eliminate the boilerplate of "if (event instanceof MySubclassEvent)" checks.

Can anything be done like this in 2.5?


Affects: 2.5.2

1 votes, 1 watchers

Activity

  1. spring-projects-issues commented on Mar 22, 2008

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    This is on the plan for Spring 3.0 M1 in June. I'm afraid there won't be any such support in the 2.5 series since we're about to focus all our new feature efforts on 3.0 M1/M2. Furthermore, implementing such generically typed listener detection isn't completely trivial due to Java's half-baked support for reflective analysis of generic declaration.

    FYI, we're aiming for a 3.0 RC1 in August, so a production version of this is hopefully not too far away...

    Juergen

  2. added
    type: enhancement
    in: core
    on Jan 11, 2019
  3. added this to the 3.0 M2 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions