package com.javahonk;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.javahonk.bean.Person;

public class BeanAnnotationTest {

	public static void main(String[] args) {

		
		System.out.println("Load application context through annotation");
		ApplicationContext context = new 
				AnnotationConfigApplicationContext(
						ApplicationConfiguration.class);
		Person person = (Person) context.getBean("personBean");
		System.out.println("Name: "+person.getName());
		((ConfigurableApplicationContext)context).close();
		
				
		System.out.println("Load application context through XML file");		
		ClassPathXmlApplicationContext applilcationContext = 
		        new ClassPathXmlApplicationContext(
		            "application-config.xml");
		Person person2 = (Person) applilcationContext.getBean("personBean");

		System.out.println("Name: "+person2.getName());
		((ConfigurableApplicationContext)applilcationContext).close();

	}

}
