@Test public void test() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); GuavaEventBusRegisterBeanPostProcessor guavaEventBusRegisterBeanPostProcessor = new GuavaEventBusRegisterBeanPostProcessor(); guavaEventBusRegisterBeanPostProcessor.setBeanFactory(bf); bf.addBeanPostProcessor(guavaEventBusRegisterBeanPostProcessor); bf.registerBeanDefinition("guavaListener", new RootBeanDefinition(TestGuavaListener.class)); bf.registerBeanDefinition("eventBus", new RootBeanDefinition(EventBus.class)); EventBus eventBus = (EventBus) bf.getBean("eventBus"); TestGuavaListener listener = (TestGuavaListener) bf.getBean("guavaListener"); final int event = 120320; eventBus.post(event); assertThat(listener.getNumber(), is(event)); }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; }
GuavaEventBusRegisterBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware { @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } }
GuavaEventBusRegisterBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware { @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; }  }
GuavaEventBusRegisterBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware { @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); Object postProcessAfterInitialization(Object bean, String beanName); @Override void setBeanFactory(BeanFactory beanFactory); }
GuavaEventBusRegisterBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware { @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); Object postProcessAfterInitialization(Object bean, String beanName); @Override void setBeanFactory(BeanFactory beanFactory);  }