return bean;
}
private <T> void register(Class<T> clazz) {
if (this.applicationContext instanceof AbstractRefreshableConfigApplicationContext) {
BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(clazz).getBeanDefinition();
AbstractRefreshableConfigApplicationContext ac = (AbstractRefreshableConfigApplicationContext) this.applicationContext;
DefaultListableBeanFactory bf = (DefaultListableBeanFactory) ac.getBeanFactory();
bf.registerBeanDefinition(clazz.getName(), beanDefinition);
} else if (this.applicationContext instanceof GenericApplicationContext) {
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(clazz).getBeanDefinition();
GenericApplicationContext ac = (GenericApplicationContext) this.applicationContext;
ac.registerBeanDefinition(clazz.getName(), beanDefinition);
} else {
throw new NoSuchBeanDefinitionException(clazz);
}
}