List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBeanDefinitionNames
@Override
public String[] getBeanDefinitionNames()
From source file:org.jboss.seam.spring.extension.SpringContextBootstrapExtension.java
public void loadSpringContext(@Observes BeforeBeanDiscovery beforeBeanDiscovery, BeanManager beanManager) { InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream(Locations.SEAM_SPRING_CONTEXTS_LOCATION); if (inputStream != null) { Properties contextLocations = new Properties(); try {/* ww w. ja v a 2 s . co m*/ contextLocations.load(inputStream); for (String contextName : contextLocations.stringPropertyNames()) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( contextLocations.getProperty(contextName)); contextDefinitions.put(contextName, context); for (String beanDefinitionName : context.getBeanDefinitionNames()) { vetoedTypes.add( context.getBeanFactory().getBeanDefinition(beanDefinitionName).getBeanClassName()); } } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } }
From source file:org.cometd.annotation.spring.SpringAnnotationTest.java
@Test public void testSpringWiringOfCometDServices() throws Exception { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); applicationContext.setConfigLocation("classpath:applicationContext.xml"); applicationContext.refresh();//from www.j av a2 s . c o m String beanName = Introspector.decapitalize(SpringBayeuxService.class.getSimpleName()); String[] beanNames = applicationContext.getBeanDefinitionNames(); assertTrue(Arrays.asList(beanNames).contains(beanName)); SpringBayeuxService service = (SpringBayeuxService) applicationContext.getBean(beanName); assertNotNull(service); assertNotNull(service.dependency); assertNotNull(service.bayeuxServer); assertNotNull(service.serverSession); assertTrue(service.active); assertEquals(1, service.bayeuxServer.getChannel(SpringBayeuxService.CHANNEL).getSubscribers().size()); applicationContext.close(); assertFalse(service.active); }