Example usage for org.springframework.context.support ClassPathXmlApplicationContext getBeanNamesForType

List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBeanNamesForType

Introduction

In this page you can find the example usage for org.springframework.context.support ClassPathXmlApplicationContext getBeanNamesForType.

Prototype

@Override
    public String[] getBeanNamesForType(ResolvableType type) 

Source Link

Usage

From source file:fr.itinerennes.bundler.cli.GtfsItinerennesBundler.java

private void listTasksAndExit(final ClassPathXmlApplicationContext context) {
    System.out.println("Available tasks:");
    for (final String tName : context.getBeanNamesForType(AbstractTask.class)) {
        System.out.printf(" - %s\n", tName);
    }//from  w  w  w .j  av a  2  s  .  c  o  m
    System.exit(0);
}

From source file:kr.okplace.job.launch.DefaultJobLoader.java

public void loadResource(String path) {

    @SuppressWarnings("resource")
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { path },
            applicationContext);// w w w . ja v a2s . co m
    String[] names = context.getBeanNamesForType(Job.class);
    for (String name : names) {
        configurations.put(name, path);
    }
}

From source file:org.entando.entando.aps.system.XmlWebApplicationContext.java

@Override
public String[] getBeanNamesForType(Class<?> type) {
    String[] beanNames = super.getBeanNamesForType(type);
    List<ClassPathXmlApplicationContext> contexts = (List<ClassPathXmlApplicationContext>) this
            .getServletContext().getAttribute("pluginsContextsList");
    Set removedPluginsSubMenuSet = (Set<String>) this.getServletContext()
            .getAttribute("removedPluginsSubMenuSet");
    if (contexts != null) {
        for (ClassPathXmlApplicationContext classPathXmlApplicationContext : contexts) {
            String[] beanNamesTemp = classPathXmlApplicationContext.getBeanNamesForType(type);
            beanNames = (String[]) ArrayUtils.addAll(beanNames, beanNamesTemp);
            HashSet hs = new HashSet();
            for (int i = 0; i < beanNames.length; i++) {
                String beanName = beanNames[i];
                hs.add(beanName);/*from   w  ww  .j a v a 2  s. c  o  m*/
            }
            beanNames = (String[]) hs.toArray(new String[0]);
            Arrays.sort(beanNames);
        }
    }
    Set hs = new HashSet();
    for (int i = 0; i < beanNames.length; i++) {
        String beanName = beanNames[i];
        if (removedPluginsSubMenuSet != null && removedPluginsSubMenuSet.contains(beanName)) {
            continue;
        }
        hs.add(beanName);
    }
    beanNames = (String[]) hs.toArray(new String[0]);
    Arrays.sort(beanNames);
    return beanNames;
}