Spring Example: Wired Together


package packageA;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloApp2 
{
   public static void main(String[] args) 
   {
     ApplicationContext ctx = new ClassPathXmlApplicationContext("config.xml");
     GreetingService greetingService = (GreetingService) ctx.getBean("greetingService");
     greetingService.sayALotOfGreeting();
     greetingService.theWinnderOfOscar();
     greetingService.sayGreeting();

     Lime iLime = (Lime) ctx.getBean("lime");
     iLime.drink();
   }
}