package us.deans.pigs.client; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.springframework.context.*; import org.springframework.context.support.*; import us.deans.pigs.api.Pig; import us.deans.pigs.base.AbstractAnimal; public class Story { final static Logger logger = LogManager.getLogger(Story.class); static AbstractAnimal wolf = null; static Pig[] pigs = new Pig[3]; public static void main(String[] args) { // instantiating a class - direct variable assignment so... THIS class is DEPENDENT on the Chapters class. logger.info("The Story of the Three Little Pigs. (version 2.0)\n"); @SuppressWarnings("resource") ApplicationContext context = new ClassPathXmlApplicationContext("/beans.xml"); Chapters story = (Chapters)context.getBean("chapters"); story.chapter_01(); // factory method = wolf story.chapter_02(); // factory method = pig1 + house1 story.chapter_03(); // dependency injection = pig2 + house2 story.chapter_04(); story = null; } }