InterceptorAwareBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (metaData.isInterceptedBean(beanName)) { return createProxyForBean(beanName, bean); } else { return bean; } } InterceptorAwareBeanPostProcessor();  InterceptorAwareBeanPostProcessor(InterceptorMetaDataBean metaData, ConfigurableListableBeanFactory beanFactory); @Override Object postProcessAfterInitialization(Object bean, String beanName); @Override Object postProcessBeforeInitialization(Object bean, String beanName);  }
@Test public void testProxying() throws Throwable { Simple_MyServiceInterface_Impl simple_MyServiceInterface_Impl = (Simple_MyServiceInterface_Impl) processor.postProcessAfterInitialization(beanFactory.getBean("simple_MyServiceInterface_Impl"), "simple_MyServiceInterface_Impl"); Assert.assertTrue(AopUtils.isCglibProxy(simple_MyServiceInterface_Impl)); }
@Test public void testWorkingInterceptor() throws Throwable { Simple_MyServiceInterface_Impl simple_MyServiceInterface_Impl = (Simple_MyServiceInterface_Impl) processor.postProcessAfterInitialization(beanFactory.getBean("simple_MyServiceInterface_Impl"), "simple_MyServiceInterface_Impl"); Assert.assertTrue(simple_MyServiceInterface_Impl.sayGoodBye().equals("Good bye_hello_world")); Assert.assertTrue(simple_MyServiceInterface_Impl.sayHello().equals("Hello_hello_world")); Assert.assertTrue(simple_MyServiceInterface_Impl.sayHello("Geek").equals("Geek_hello_world")); }