時間:2023-03-15來源:系統城裝機大師作者:佚名
判斷Bean是否是監聽器,如果是監聽器就將當前Bean加入監聽器集合
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof ApplicationListener) { // potentially not detected as a listener by getBeanNamesForType retrieval Boolean flag = this .singletonNames.get(beanName); if (Boolean.TRUE.equals(flag)) { // singleton bean (top-level or inner): register on the fly this .applicationContext.addApplicationListener((ApplicationListener<?>) bean); } else if (Boolean.FALSE.equals(flag)) { if (logger.isWarnEnabled() && ! this .applicationContext.containsBean(beanName)) { // inner bean with other scope - can't reliably process events logger.warn( "Inner bean '" + beanName + "' implements ApplicationListener interface " + "but is not reachable for event multicasting by its containing ApplicationContext " + "because it does not have singleton scope. Only top-level listener beans are allowed " + "to be of non-singleton scope." ); } this .singletonNames.remove(beanName); } } return bean; } |
如果當前Bean是監聽器,就將當前Bean從監聽器集合中移除
1 2 3 4 5 6 7 8 9 10 11 12 |
public void postProcessBeforeDestruction(Object bean, String beanName) { if (bean instanceof ApplicationListener) { try { ApplicationEventMulticaster multicaster = this .applicationContext.getApplicationEventMulticaster(); multicaster.removeApplicationListener((ApplicationListener<?>) bean); multicaster.removeApplicationListenerBean(beanName); } catch (IllegalStateException ex) { // ApplicationEventMulticaster not initialized yet - no need to remove a listener } } } |
以上就是ApplicationListenerDetector監聽器判斷demo的詳細內容
2023-03-15
Keil uVision5 5.38官方下載、安裝及注冊超詳細圖文教程2023-03-11
Jmeter如何將每次測試的結果保存到文件中2023-03-11
Jmeter測試時遇到的各種亂碼問題及解決mediaDevices 的介紹 我們這里用到getUserMedia 的 api 把獲取到的 stream 用一個 video 來展示 樣式部分 陰影的設置 完整代碼...
2023-03-09