Description
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:
- Support DisposableBean on prototype and @Configurable beans using weak references [SPR-9391] #14027 Support DisposableBean on prototype and
@Configurable
beans using weak references
1 votes, 4 watchers