public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException { EventSubscriber subscriber = managedSubscribers.get(beanName); if (subscriber != null) { EventBus eventBus = getEventBus(eventBusName(subscriber)); eventBus.subscribe(topic(subscriber), subscriber); } return bean; }
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { if (managedSubscribers.containsKey(beanName)) { try { EventSubscriber subscriber = managedSubscribers.get(beanName); EventBus eventBus = getEventBus(eventBusName(subscriber)); eventBus.unsubscribe(topic(subscriber), subscriber); } catch (Exception e) { log.error("An exception occurred while unsubscribing an event listener", e); } finally { managedSubscribers.remove(beanName); } } }