|
From: Colin S. <col...@ex...> - 2004-11-07 15:22:00
|
+1 I think.
I don't like backwards incompatible changes, but the existing
implementation is simply wrong for any bean that is deployed into the
context, nobody in that case should be relying on the present sequence
as it doesn't make sense. I guess the other option is to not send out
the event to beans that have been destroyed, but that is a lot of work,
never mind mixing concerns that shouldn't be mixed, I think.
Now, do we have to worry about external objects (not deployed and
broadcast to automatically), that register for events manually, with the
appcontext?. Changing the sequence might mess them up, if they think
destroy has already been called on all beans. However, I don't see much
choice in the matter. I think most usage of the eventing mechanism will
be for application events (not context evetns), with the beans deployed
into the context, and we don't want to send those spurious events after
they have theoretically been destroyed.
jürgen höller [werk3AT] wrote:
>Good point. I guess hardly anyone relies on ContextClosedEvent anyway, but for the sake of a clear state of listeners, we should publish that event *before* destroying beans. I'm inclinced to change that for 1.1.2 (which I now intend to release mid next week).
>
>Juergen
>
>
>________________________________
>
>Von: spr...@li... im Auftrag von Colin Sampaleanu
>Gesendet: Do 04.11.2004 02:08
>An: spr...@li...
>Betreff: [Springframework-developer] ContextClosedEvent
>
>
>
>I'm just documenting somehting on the ContextClosedEvent. It's called
>when all singletons have been destroyed (i.e. destroy method has been
>called)
>
> public void close() {
> if (logger.isInfoEnabled()) {
> logger.info("Closing application context [" +
>getDisplayName() + "]");
> }
>
> // Destroy all cached singletons in this context,
> // invoking DisposableBean.destroy and/or "destroy-method".
> ConfigurableListableBeanFactory beanFactory = getBeanFactory();
> if (beanFactory != null) {
> beanFactory.destroySingletons();
> }
>
> // publish corresponding event
> publishEvent(new ContextClosedEvent(this));
> }
>
>I've personally never used the context closed event, but what I have to
>ask here is, does nobody else think this sequence is not usable and/or
>potentially dangerous. On the not usable part, an event listener must
>not have a destroy method, since the onApplicationEvent() would end up
>being called after the bean has been destroyed. As for potentially
>dangerous, that's if somebody forgets that they can't have a destroy
>method, and then spring does call the two methods in the wrong sequence.
>
>Colin
>
>
|