|
From: <jue...@we...> - 2004-11-07 13:41:13
|
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).
=20
Juergen
=20
________________________________
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 =3D =
getBeanFactory();
if (beanFactory !=3D 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
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=3D5588&alloc_id=3D12065&op=3Dclick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|