Register a callback to be executed on destruction of the specified object in the scope (or at destruction of the entire scope, if the scope does not destroy individual objects but rather only terminates in its entirety).
Note: This is an optional operation. This method will only be called for scoped beans with actual destruction configuration (DisposableBean, destroy-method, DestructionAwareBeanPostProcessor). Implementations should do their best to execute a given callback at the appropriate time. If such a callback is not supported by the underlying runtime environment at all, the callback must be ignored and a corresponding warning should be logged.
Note that 'destruction' refers to to automatic destruction of the object as part of the scope's own lifecycle, not to the individual scoped object having been explicitly removed by the application. If a scoped object gets removed via this facade's {@link #remove(String)}method, any registered destruction callback should be removed as well, assuming that the removed object will be reused or manually destroyed.
@param name the name of the object to execute the destruction callback for
@param callback the destruction callback to be executed.Note that the passed-in Runnable will never throw an exception, so it can safely be executed without an enclosing try-catch block. Furthermore, the Runnable will usually be serializable, provided that its target object is serializable as well.
@see org.springframework.beans.factory.DisposableBean
@see org.springframework.beans.factory.support.AbstractBeanDefinition#getDestroyMethodName()
@see DestructionAwareBeanPostProcessor