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

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

Introduction

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

Prototype

@Override
    public String[] getAliases(String name) 

Source Link

Usage

From source file:com.home.ln_spring.ch4.xml.BeanNameAliasing.java

public static void main(String args[]) {
    GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    context.load("classpath:app-context-xml.xml");
    context.refresh();//w ww . jav a 2 s .c o m

    String str1 = (String) context.getBean("name1");
    String str2 = (String) context.getBean("name2");
    String str3 = (String) context.getBean("name3");
    String str4 = (String) context.getBean("name4");
    String str5 = (String) context.getBean("name5");
    String[] alias = (String[]) context.getAliases("name1");

    System.out.println(str1 == str2);
    System.out.println(str2 == str3);
    System.out.println(str3 == str4);
    System.out.println(str4 == str5);
    System.out.println(str1 == str5);
    System.out.println(Arrays.asList(alias));
}