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

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

Introduction

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

Prototype

@Override
    public String[] getAliases(String name) 

Source Link

Usage

From source file:com.opengamma.component.factory.AbstractSpringComponentFactory.java

/**
 * Registers a set of beans by type./* w w  w.j a v  a  2s.c  o  m*/
 * 
 * @param <T> the type
 * @param repo  the repository to register in, not null
 * @param type  the type of bean to extract from the Spring context, not null
 * @param appContext  the Spring context, not null
 */
protected <T> void registerInfrastructureByType(ComponentRepository repo, Class<T> type,
        GenericApplicationContext appContext) {
    String[] beanNames = appContext.getBeanNamesForType(type);
    for (String beanName : beanNames) {
        T bean = appContext.getBean(beanName, type);
        String name = simplifyName(type, beanName);
        repo.registerComponent(type, name, bean);
        String[] aliases = appContext.getAliases(beanName);
        for (String alias : aliases) {
            name = simplifyName(type, alias);
            repo.registerComponent(type, name, bean);
        }
    }
}