Example usage for org.springframework.context.support GenericApplicationContext getBeanDefinitionNames

List of usage examples for org.springframework.context.support GenericApplicationContext getBeanDefinitionNames

Introduction

In this page you can find the example usage for org.springframework.context.support GenericApplicationContext getBeanDefinitionNames.

Prototype

@Override
    public String[] getBeanDefinitionNames() 

Source Link

Usage

From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.impl.utils.PentahoSystemHelper.java

private static ApplicationContext getSpringApplicationContext() {

    String[] fns = { "pentahoObjects.spring.xml", "adminPlugins.xml", "sessionStartupActions.xml",
            "systemListeners.xml", "pentahoSystemConfig.xml" }; //$NON-NLS-2$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$

    GenericApplicationContext appCtx = new GenericApplicationContext();
    XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);

    for (String fn : fns) {
        File f = new File(getSolutionPath() + SYSTEM_FOLDER + "/" + fn); //$NON-NLS-1$
        if (f.exists()) {
            FileSystemResource fsr = new FileSystemResource(f);
            xmlReader.loadBeanDefinitions(fsr);
        }/* w  w w  .ja  v a  2s  .co  m*/
    }

    String[] beanNames = appCtx.getBeanDefinitionNames();
    System.out.println("Loaded Beans: "); //$NON-NLS-1$
    for (String n : beanNames) {
        System.out.println("bean: " + n); //$NON-NLS-1$
    }
    return appCtx;
}

From source file:com.fortify.processrunner.ConfigFilesTest.java

@Test
public void testConfigFiles() {
    String[] files = new File("processrunner-config").list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".xml");
        }/*w  ww .j  a  v a2  s  .  c o  m*/
    });
    for (String file : files) {
        GenericApplicationContext ctx = SpringContextUtil.loadApplicationContextFromFiles(true,
                "processrunner-config/" + file);
        System.out.println(ctx + ": " + Arrays.asList(ctx.getBeanDefinitionNames()));
    }
}

From source file:net.cpollet.jixture.spring.TestConfiguration.java

@Test
public void springConfigurationIsWorking() {
    GenericApplicationContext applicationContext = new GenericApplicationContext( //
            new ClassPathXmlApplicationContext("classpath:/spring/jpa2-unit-test-context.xml"));

    for (String beanName : applicationContext.getBeanDefinitionNames()) {
        if (!applicationContext.getBeanDefinition(beanName).isAbstract()) {
            logger.info("Requesting bean {}", beanName);
            applicationContext.getBean(beanName);
        }//  ww  w  . j av  a  2  s .c  o m
    }
}