package com.javahonk;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.javahonk.di.bean.Address;
import com.javahonk.di.bean.Person;

public class TestDependencyInjection {

    public static void main(String[] args) {
	ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
		"spring\\application-config.xml");
	// Get person object
	Person person = applicationContext.getBean("person",
		Person.class);
	
	System.out.println("Constructor injection value of person:");
	System.out.println("First Name: " + person.getFirstName()
		+ "Last Name: " + person.getLastName());
	System.out.println("Setter injection value of Address:");
	System.out.println("Street: "
		+ person.getAddress().getStreeName() + "" + " City: "
		+ person.getAddress().getCity() + " State: "
		+ person.getAddress().getState() + " Zip: "
		+ person.getAddress().getZip());

	
	System.out
		.println("\nConstructor injection value of Address directly:");
	Address address = applicationContext.getBean(Address.class);
	System.out.println("Street: " + person.getAddress().getStreeName() + ""
		+ " City: " + address.getCity() + " State: "
		+ address.getState() + " Zip: " + address.getZip()
		+ "\n");

	applicationContext.close();
	
	
    }

}
