Skip to content

Instantly share code, notes, and snippets.

@Kotlin-Native
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save Kotlin-Native/60c5d5ed849b4bf4115c to your computer and use it in GitHub Desktop.

Select an option

Save Kotlin-Native/60c5d5ed849b4bf4115c to your computer and use it in GitHub Desktop.
public void connectCdiAndSpring(@Observes AfterBeanDiscovery event, BeanManager manager)
throws ClassNotFoundException {
ConfigurableApplicationContext springContext
= new ClassPathXmlApplicationContext(new String[] { "classpath:application-context.xml"}, false);
springContext.addBeanFactoryPostProcessor(new DependencyRegisteringPostProcessor(manager, cdiBeans));
springContext.refresh();
for (String beanName: springContext.getBeanDefinitionNames()) {
BeanDefinition beanDefinition
= springContext.getBeanFactory().getBeanDefinition(beanName);
if (!CdiScope.class.getName().equals(beanDefinition.getScope())) {
event.addBean(createBean(…));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment