* Releases all instances bound to this dispatcher instance.
*/
public void cleanup() {
// clean up ObjectFactory
ObjectFactory objectFactory = getContainer().getInstance(ObjectFactory.class);
if (objectFactory == null) {
if (LOG.isWarnEnabled()) {
LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed");
}
}
if (objectFactory instanceof ObjectFactoryDestroyable) {
try {
((ObjectFactoryDestroyable)objectFactory).destroy();
}
catch(Exception e) {
// catch any exception that may occurred during destroy() and log it
LOG.error("exception occurred while destroying ObjectFactory [#0]", e, objectFactory.toString());
}
}
// clean up Dispatcher itself for this thread
instance.set(null);