Skip to content

Introduce removeApplicationListener in ConfigurableApplicationContext #14023

Closed
@spring-projects-issues

Description

@spring-projects-issues

Archie Cobbs opened SPR-9387 and commented

I have some object which need to receive some ApplicationEvents that are sent around in my application.

However, these objects have a lifecycle that does not match with the lifecycle of normal beans in the application context (their lifecycle is shorter).

Therefore, I have these beans marked @Configurable, and they are ApplicationContextAware so they can get a reference to the application context (which is assumed to be a ConfigurableApplicationContext.

Then, when they "start" they register as listeners for application events via ConfigurableApplicationContext.addApplicationListener(). However, when they "stop" there is no way for them to unregister themselves as listeners, because there is no corresponding method ConfigurableApplicationContext.removeApplicationListener().

So this request is simply to add ConfigurableApplicationContext.removeApplicationListener().

If there is some more elegant way to do what I'm trying to do please let me know. But just from the face of it, it seems weirdly asymmetrical to have a public addFooListener() method without a corresponding removeFooListener() method.

Thanks.


Affects: 3.1.1

Issue Links:

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions