use of org.springframework.beans.factory.support.DefaultSingletonBeanRegistry in project hutool by looly.
the class SpringUtil method unregisterBean.
/**
* 注销bean
* <p>
* 将Spring中的bean注销,请谨慎使用
*
* @param beanName bean名称
* @author shadow
* @since 5.7.7
*/
public static void unregisterBean(String beanName) {
final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory();
if (factory instanceof DefaultSingletonBeanRegistry) {
DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) factory;
registry.destroySingleton(beanName);
} else {
throw new UtilException("Can not unregister bean, the factory is not a DefaultSingletonBeanRegistry!");
}
}
use of org.springframework.beans.factory.support.DefaultSingletonBeanRegistry in project spring-cloud-stream by spring-cloud.
the class AbstractMessageChannelBinder method destroyErrorInfrastructure.
private void destroyErrorInfrastructure(ProducerDestination destination) {
String errorChannelName = errorsBaseName(destination);
String errorBridgeHandlerName = getErrorBridgeName(destination);
MessageHandler bridgeHandler = null;
if (getApplicationContext().containsBean(errorBridgeHandlerName)) {
bridgeHandler = getApplicationContext().getBean(errorBridgeHandlerName, MessageHandler.class);
}
if (getApplicationContext().containsBean(errorChannelName)) {
SubscribableChannel channel = getApplicationContext().getBean(errorChannelName, SubscribableChannel.class);
if (bridgeHandler != null) {
channel.unsubscribe(bridgeHandler);
((DefaultSingletonBeanRegistry) getApplicationContext().getBeanFactory()).destroySingleton(errorBridgeHandlerName);
}
((DefaultSingletonBeanRegistry) getApplicationContext().getBeanFactory()).destroySingleton(errorChannelName);
}
}
Aggregations