From 416bd4a9d5b32585bb9f968f481a266ff0c97df4 Mon Sep 17 00:00:00 2001 From: gschambial Date: Mon, 13 Nov 2017 22:48:09 +0530 Subject: [PATCH] Removed evaluation article (Dependency Injection) from master branch. --- .../SpringAutowireConstructorContext.java | 10 ------ .../config/SpringBeanConstructorContext.java | 28 --------------- .../factory/ComputerAutowireFactory.java | 32 ----------------- .../factory/ComputerBeanFactory.java | 33 ------------------ .../factory/ComputerXmlFactory.java | 33 ------------------ .../constructor/model/autowire/Computer.java | 34 ------------------- .../di/constructor/model/autowire/Memory.java | 19 ----------- .../constructor/model/autowire/Processor.java | 19 ----------- .../di/constructor/model/bean/Computer.java | 29 ---------------- .../di/constructor/model/bean/Memory.java | 16 --------- .../di/constructor/model/bean/Processor.java | 16 --------- .../di/constructor/model/xml/Computer.java | 29 ---------------- .../di/constructor/model/xml/Memory.java | 20 ----------- .../di/constructor/model/xml/Processor.java | 16 --------- .../config/SpringAutowireSetterContext.java | 10 ------ .../config/SpringBeanSetterContext.java | 31 ----------------- .../factory/ComputerAutowireFactory.java | 32 ----------------- .../setter/factory/ComputerBeanFactory.java | 33 ------------------ .../di/setter/factory/ComputerXmlFactory.java | 32 ----------------- .../di/setter/model/autowire/Computer.java | 30 ---------------- .../di/setter/model/autowire/Memory.java | 19 ----------- .../di/setter/model/autowire/Processor.java | 19 ----------- .../di/setter/model/bean/Computer.java | 24 ------------- .../baeldung/di/setter/model/bean/Memory.java | 17 ---------- .../di/setter/model/bean/Processor.java | 16 --------- .../di/setter/model/xml/Computer.java | 24 ------------- .../baeldung/di/setter/model/xml/Memory.java | 20 ----------- .../di/setter/model/xml/Processor.java | 16 --------- .../application-di-constructor-context.xml | 23 ------------- .../application-di-setter-context.xml | 22 ------------ .../AutowireAnnotationInjectionUnitTest.java | 28 --------------- .../BeanAnnotationInjectionUnitTest.java | 28 --------------- .../di/constructor/XmlInjectionUnitTest.java | 27 --------------- .../AutowireAnnotationInjectionUnitTest.java | 28 --------------- .../BeanAnnotationInjectionUnitTest.java | 28 --------------- .../di/setter/XmlInjectionUnitTest.java | 27 --------------- 36 files changed, 868 deletions(-) delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/config/SpringAutowireConstructorContext.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/config/SpringBeanConstructorContext.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerAutowireFactory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerBeanFactory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerXmlFactory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Computer.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Memory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Processor.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Computer.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Memory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Processor.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Computer.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Memory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Processor.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/config/SpringAutowireSetterContext.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/config/SpringBeanSetterContext.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerAutowireFactory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerBeanFactory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerXmlFactory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Computer.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Memory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Processor.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/bean/Computer.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/bean/Memory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/bean/Processor.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/xml/Computer.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/xml/Memory.java delete mode 100644 spring-core/src/main/java/com/baeldung/di/setter/model/xml/Processor.java delete mode 100644 spring-core/src/main/resources/application-di-constructor-context.xml delete mode 100644 spring-core/src/main/resources/application-di-setter-context.xml delete mode 100644 spring-core/src/test/java/com/baeldung/di/constructor/AutowireAnnotationInjectionUnitTest.java delete mode 100644 spring-core/src/test/java/com/baeldung/di/constructor/BeanAnnotationInjectionUnitTest.java delete mode 100644 spring-core/src/test/java/com/baeldung/di/constructor/XmlInjectionUnitTest.java delete mode 100644 spring-core/src/test/java/com/baeldung/di/setter/AutowireAnnotationInjectionUnitTest.java delete mode 100644 spring-core/src/test/java/com/baeldung/di/setter/BeanAnnotationInjectionUnitTest.java delete mode 100644 spring-core/src/test/java/com/baeldung/di/setter/XmlInjectionUnitTest.java diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/config/SpringAutowireConstructorContext.java b/spring-core/src/main/java/com/baeldung/di/constructor/config/SpringAutowireConstructorContext.java deleted file mode 100644 index ae67bc7e5e..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/config/SpringAutowireConstructorContext.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.di.constructor.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan(basePackages = { "com.baeldung.di.constructor.model.autowire" }) -public class SpringAutowireConstructorContext { - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/config/SpringBeanConstructorContext.java b/spring-core/src/main/java/com/baeldung/di/constructor/config/SpringBeanConstructorContext.java deleted file mode 100644 index 670f18cb9c..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/config/SpringBeanConstructorContext.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.di.constructor.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.di.constructor.model.bean.Computer; -import com.baeldung.di.constructor.model.bean.Memory; -import com.baeldung.di.constructor.model.bean.Processor; - -@Configuration -public class SpringBeanConstructorContext { - - @Bean - public Computer computer() { - return new Computer(processor(), memory()); - } - - @Bean - public Processor processor() { - return new Processor(); - } - - @Bean - public Memory memory() { - return new Memory(); - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerAutowireFactory.java b/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerAutowireFactory.java deleted file mode 100644 index 2a13adf250..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerAutowireFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.di.constructor.factory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.constructor.config.SpringAutowireConstructorContext; -import com.baeldung.di.constructor.model.autowire.Computer; - -public class ComputerAutowireFactory { - - public static void main(String[] args) { - // Create Spring Application Context - ApplicationContext context = new AnnotationConfigApplicationContext(SpringAutowireConstructorContext.class); - - // Get Spring bean "computer" created - Computer computer = (Computer) context.getBean("computer"); - System.out.println("---------------- Constructor Injection via @Autowire------------------"); - System.out.println("Processor cores : " + computer.getProcessor() - .getCores()); - System.out.println("Processor frequency : " + computer.getProcessor() - .getFrequency()); - System.out.println("Memory Size in GB : " + computer.getMemory() - .getSizeInGb()); - System.out.println("Memory format : " + computer.getMemory() - .getFormat()); - System.out.println("---------------- Constructor Injection via @Autowire------------------"); - // Close Spring Application Context - ((ConfigurableApplicationContext) context).close(); - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerBeanFactory.java b/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerBeanFactory.java deleted file mode 100644 index 713ea82b00..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerBeanFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.di.constructor.factory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.constructor.config.SpringBeanConstructorContext; -import com.baeldung.di.constructor.model.bean.Computer; - -public class ComputerBeanFactory { - - public static void main(String[] args) { - // Create Spring Application Context - ApplicationContext context = new AnnotationConfigApplicationContext(SpringBeanConstructorContext.class); - - // Get Spring bean "computer" created - Computer computer = (Computer) context.getBean("computer"); - System.out.println("---------------- Constructor Injection via @Bean ------------------"); - System.out.println("Processor cores : " + computer.getProcessor() - .getCores()); - System.out.println("Processor frequency : " + computer.getProcessor() - .getFrequency()); - System.out.println("Memory Size in GB : " + computer.getMemory() - .getSizeInGb()); - System.out.println("Memory format : " + computer.getMemory() - .getFormat()); - System.out.println("---------------- Constructor Injection via @Bean ------------------"); - - // Close Spring Application Context - ((ConfigurableApplicationContext) context).close(); - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerXmlFactory.java b/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerXmlFactory.java deleted file mode 100644 index afe5fa281b..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/factory/ComputerXmlFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.di.constructor.factory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.di.constructor.model.xml.Computer; - -public class ComputerXmlFactory { - - public static void main(String[] args) { - // Create Spring Application Context - ApplicationContext context = new ClassPathXmlApplicationContext("application-di-constructor-context.xml"); - - // Get Spring bean "computer" created - Computer computer = (Computer) context.getBean("computer"); - System.out.println("---------------- Constructor Injection via XML ------------------"); - System.out.println("Processor cores : " + computer.getProcessor() - .getCores()); - System.out.println("Processor frequency : " + computer.getProcessor() - .getFrequency()); - System.out.println("Memory Size in GB : " + computer.getMemory() - .getSizeInGb()); - System.out.println("Memory format : " + computer.getMemory() - .getFormat()); - System.out.println("---------------- Constructor Injection via XML ------------------"); - - // Close Spring Application Context - ((ConfigurableApplicationContext) context).close(); - - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Computer.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Computer.java deleted file mode 100644 index 1dabfd287e..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Computer.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.di.constructor.model.autowire; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Computer { - - private Processor processor; - private Memory memory; - - @Autowired - public Computer(Processor processor, Memory memory) { - this.processor = processor; - this.memory = memory; - } - - public Processor getProcessor() { - return processor; - } - - public void setProcessor(Processor processor) { - this.processor = processor; - } - - public Memory getMemory() { - return memory; - } - - public void setMemory(Memory memory) { - this.memory = memory; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Memory.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Memory.java deleted file mode 100644 index d1faecc569..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Memory.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.di.constructor.model.autowire; - -import org.springframework.stereotype.Component; - -@Component -public class Memory { - - private Integer sizeInGb = 16; - private String format = "DDR3"; - - public Integer getSizeInGb() { - return sizeInGb; - } - - public String getFormat() { - return format; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Processor.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Processor.java deleted file mode 100644 index 7de9d2bf6a..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/autowire/Processor.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.di.constructor.model.autowire; - -import org.springframework.stereotype.Component; - -@Component -public class Processor { - - private Integer cores = 2; - private Double frequency = 1.4; - - public Integer getCores() { - return cores; - } - - public Double getFrequency() { - return frequency; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Computer.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Computer.java deleted file mode 100644 index 74ec89ce0c..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Computer.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.di.constructor.model.bean; - -public class Computer { - - private Processor processor; - private Memory memory; - - public Computer(Processor processor, Memory memory) { - this.processor = processor; - this.memory = memory; - } - - public Processor getProcessor() { - return processor; - } - - public void setProcessor(Processor processor) { - this.processor = processor; - } - - public Memory getMemory() { - return memory; - } - - public void setMemory(Memory memory) { - this.memory = memory; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Memory.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Memory.java deleted file mode 100644 index 18d4eaf948..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Memory.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.di.constructor.model.bean; - -public class Memory { - - private Integer sizeInGb = 16; - private String format = "DDR3"; - - public Integer getSizeInGb() { - return sizeInGb; - } - - public String getFormat() { - return format; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Processor.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Processor.java deleted file mode 100644 index 9dd719c872..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/bean/Processor.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.di.constructor.model.bean; - -public class Processor { - - private Integer cores = 2; - private Double frequency = 1.4; - - public Integer getCores() { - return cores; - } - - public Double getFrequency() { - return frequency; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Computer.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Computer.java deleted file mode 100644 index 66c39c66b7..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Computer.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.di.constructor.model.xml; - -public class Computer { - - private Processor processor; - private Memory memory; - - public Computer(Processor processor, Memory memory) { - this.processor = processor; - this.memory = memory; - } - - public Processor getProcessor() { - return processor; - } - - public void setProcessor(Processor processor) { - this.processor = processor; - } - - public Memory getMemory() { - return memory; - } - - public void setMemory(Memory memory) { - this.memory = memory; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Memory.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Memory.java deleted file mode 100644 index 7b4f4fb697..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Memory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.di.constructor.model.xml; - -public class Memory { - - private Integer sizeInGb = 16; - private String format = "DDR3"; - - public Memory() { - - } - - public Integer getSizeInGb() { - return sizeInGb; - } - - public String getFormat() { - return format; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Processor.java b/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Processor.java deleted file mode 100644 index 4e783042fe..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/constructor/model/xml/Processor.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.di.constructor.model.xml; - -public class Processor { - - private Integer cores = 2; - private Double frequency = 1.4; - - public Integer getCores() { - return cores; - } - - public Double getFrequency() { - return frequency; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/config/SpringAutowireSetterContext.java b/spring-core/src/main/java/com/baeldung/di/setter/config/SpringAutowireSetterContext.java deleted file mode 100644 index 9e1d24fc61..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/config/SpringAutowireSetterContext.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.di.setter.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan(basePackages = { "com.baeldung.di.setter.model.autowire" }) -public class SpringAutowireSetterContext { - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/config/SpringBeanSetterContext.java b/spring-core/src/main/java/com/baeldung/di/setter/config/SpringBeanSetterContext.java deleted file mode 100644 index 14767fb0ca..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/config/SpringBeanSetterContext.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.di.setter.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.di.setter.model.bean.Computer; -import com.baeldung.di.setter.model.bean.Memory; -import com.baeldung.di.setter.model.bean.Processor; - -@Configuration -public class SpringBeanSetterContext { - - @Bean - public Computer computer() { - Computer computer = new Computer(); - computer.setProcessor(processor()); - computer.setMemory(memory()); - return computer; - } - - @Bean - public Processor processor() { - return new Processor(); - } - - @Bean - public Memory memory() { - return new Memory(); - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerAutowireFactory.java b/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerAutowireFactory.java deleted file mode 100644 index ef1ac83530..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerAutowireFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.di.setter.factory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.setter.config.SpringAutowireSetterContext; -import com.baeldung.di.setter.model.autowire.Computer; - -public class ComputerAutowireFactory { - - public static void main(String[] args) { - // Create Spring Application Context - ApplicationContext context = new AnnotationConfigApplicationContext(SpringAutowireSetterContext.class); - - // Get Spring bean "computer" created - Computer computer = (Computer) context.getBean("computer"); - System.out.println("---------------- Setter Injection via @Autowire ------------------"); - System.out.println("Processor cores : " + computer.getProcessor() - .getCores()); - System.out.println("Processor frequency : " + computer.getProcessor() - .getFrequency()); - System.out.println("Memory Size in GB : " + computer.getMemory() - .getSizeInGb()); - System.out.println("Memory format : " + computer.getMemory() - .getFormat()); - System.out.println("---------------- Setter Injection via @Autowire ------------------"); - // Close Spring Application Context - ((ConfigurableApplicationContext) context).close(); - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerBeanFactory.java b/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerBeanFactory.java deleted file mode 100644 index 87f49bf4cf..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerBeanFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.di.setter.factory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.setter.config.SpringBeanSetterContext; -import com.baeldung.di.setter.model.bean.Computer; - -public class ComputerBeanFactory { - - public static void main(String[] args) { - // Create Spring Application Context - ApplicationContext context = new AnnotationConfigApplicationContext(SpringBeanSetterContext.class); - - // Get Spring bean "computer" created - Computer computer = (Computer) context.getBean("computer"); - System.out.println("---------------- Setter Injection via @Bean ------------------"); - System.out.println("Processor cores : " + computer.getProcessor() - .getCores()); - System.out.println("Processor frequency : " + computer.getProcessor() - .getFrequency()); - System.out.println("Memory Size in GB : " + computer.getMemory() - .getSizeInGb()); - System.out.println("Memory format : " + computer.getMemory() - .getFormat()); - System.out.println("---------------- Setter Injection via @Bean ------------------"); - - // Close Spring Application Context - ((ConfigurableApplicationContext) context).close(); - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerXmlFactory.java b/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerXmlFactory.java deleted file mode 100644 index 01af29905c..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/factory/ComputerXmlFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.di.setter.factory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.di.setter.model.xml.Computer; - -public class ComputerXmlFactory { - - public static void main(String[] args) { - // Create Spring Application Context - ApplicationContext context = new ClassPathXmlApplicationContext("application-setter-context.xml"); - - // Get Spring bean "computer" created - Computer computer = (Computer) context.getBean("computer"); - System.out.println("---------------- Setter Injection via XML ------------------"); - System.out.println("Processor cores : " + computer.getProcessor() - .getCores()); - System.out.println("Processor frequency : " + computer.getProcessor() - .getFrequency()); - System.out.println("Memory Size in GB : " + computer.getMemory() - .getSizeInGb()); - System.out.println("Memory format : " + computer.getMemory() - .getFormat()); - System.out.println("---------------- Setter Injection via XML ------------------"); - // Close Spring Application Context - ((ConfigurableApplicationContext) context).close(); - - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Computer.java b/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Computer.java deleted file mode 100644 index ed32b34729..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Computer.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.di.setter.model.autowire; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Computer { - - private Processor processor; - private Memory memory; - - public Processor getProcessor() { - return processor; - } - - @Autowired - public void setProcessor(Processor processor) { - this.processor = processor; - } - - public Memory getMemory() { - return memory; - } - - @Autowired - public void setMemory(Memory memory) { - this.memory = memory; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Memory.java b/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Memory.java deleted file mode 100644 index ffdd63d389..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Memory.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.di.setter.model.autowire; - -import org.springframework.stereotype.Component; - -@Component -public class Memory { - - private Integer sizeInGb = 16; - private String format = "DDR3"; - - public Integer getSizeInGb() { - return sizeInGb; - } - - public String getFormat() { - return format; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Processor.java b/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Processor.java deleted file mode 100644 index 9b01143bd2..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/autowire/Processor.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.di.setter.model.autowire; - -import org.springframework.stereotype.Component; - -@Component -public class Processor { - - private Integer cores = 2; - private Double frequency = 1.4; - - public Integer getCores() { - return cores; - } - - public Double getFrequency() { - return frequency; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Computer.java b/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Computer.java deleted file mode 100644 index e350cddee8..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Computer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.di.setter.model.bean; - -public class Computer { - - private Processor processor; - private Memory memory; - - public Processor getProcessor() { - return processor; - } - - public void setProcessor(Processor processor) { - this.processor = processor; - } - - public Memory getMemory() { - return memory; - } - - public void setMemory(Memory memory) { - this.memory = memory; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Memory.java b/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Memory.java deleted file mode 100644 index b34052e066..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Memory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.di.setter.model.bean; - -public class Memory { - - private Integer sizeInGb = 16; - private String format = "DDR3"; - - // - public Integer getSizeInGb() { - return sizeInGb; - } - - public String getFormat() { - return format; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Processor.java b/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Processor.java deleted file mode 100644 index 2c9f050232..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/bean/Processor.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.di.setter.model.bean; - -public class Processor { - - private Integer cores = 2; - private Double frequency = 1.4; - - public Integer getCores() { - return cores; - } - - public Double getFrequency() { - return frequency; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Computer.java b/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Computer.java deleted file mode 100644 index a88dc34d07..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Computer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.di.setter.model.xml; - -public class Computer { - - private Processor processor; - private Memory memory; - - public Processor getProcessor() { - return processor; - } - - public void setProcessor(Processor processor) { - this.processor = processor; - } - - public Memory getMemory() { - return memory; - } - - public void setMemory(Memory memory) { - this.memory = memory; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Memory.java b/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Memory.java deleted file mode 100644 index 93667ff225..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Memory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.di.setter.model.xml; - -public class Memory { - - private Integer sizeInGb = 16; - private String format = "DDR3"; - - public Memory() { - - } - - public Integer getSizeInGb() { - return sizeInGb; - } - - public String getFormat() { - return format; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Processor.java b/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Processor.java deleted file mode 100644 index 1845983338..0000000000 --- a/spring-core/src/main/java/com/baeldung/di/setter/model/xml/Processor.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.di.setter.model.xml; - -public class Processor { - - private Integer cores = 2; - private Double frequency = 1.4; - - public Integer getCores() { - return cores; - } - - public Double getFrequency() { - return frequency; - } - -} diff --git a/spring-core/src/main/resources/application-di-constructor-context.xml b/spring-core/src/main/resources/application-di-constructor-context.xml deleted file mode 100644 index c1f2d4cdfd..0000000000 --- a/spring-core/src/main/resources/application-di-constructor-context.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-core/src/main/resources/application-di-setter-context.xml b/spring-core/src/main/resources/application-di-setter-context.xml deleted file mode 100644 index 658f28b3f3..0000000000 --- a/spring-core/src/main/resources/application-di-setter-context.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-core/src/test/java/com/baeldung/di/constructor/AutowireAnnotationInjectionUnitTest.java b/spring-core/src/test/java/com/baeldung/di/constructor/AutowireAnnotationInjectionUnitTest.java deleted file mode 100644 index 348ac1428b..0000000000 --- a/spring-core/src/test/java/com/baeldung/di/constructor/AutowireAnnotationInjectionUnitTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.di.constructor; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.constructor.config.SpringAutowireConstructorContext; -import com.baeldung.di.constructor.model.autowire.Computer; - -public class AutowireAnnotationInjectionUnitTest { - - private ApplicationContext applicationContext; - - @Before - public void setUp() throws Exception { - applicationContext = new AnnotationConfigApplicationContext(SpringAutowireConstructorContext.class); - } - - @Test - public void getComputer_() { - final Computer computer = applicationContext.getBean("computer", Computer.class); - assertNotNull(computer); - } - -} diff --git a/spring-core/src/test/java/com/baeldung/di/constructor/BeanAnnotationInjectionUnitTest.java b/spring-core/src/test/java/com/baeldung/di/constructor/BeanAnnotationInjectionUnitTest.java deleted file mode 100644 index 3eb276428c..0000000000 --- a/spring-core/src/test/java/com/baeldung/di/constructor/BeanAnnotationInjectionUnitTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.di.constructor; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.constructor.config.SpringBeanConstructorContext; -import com.baeldung.di.constructor.model.bean.Computer; - -public class BeanAnnotationInjectionUnitTest { - - private ApplicationContext applicationContext; - - @Before - public void setUp() throws Exception { - applicationContext = new AnnotationConfigApplicationContext(SpringBeanConstructorContext.class); - } - - @Test - public void getComputer_() { - final Computer computer = applicationContext.getBean("computer", Computer.class); - assertNotNull(computer); - } - -} diff --git a/spring-core/src/test/java/com/baeldung/di/constructor/XmlInjectionUnitTest.java b/spring-core/src/test/java/com/baeldung/di/constructor/XmlInjectionUnitTest.java deleted file mode 100644 index cfcc7ed56e..0000000000 --- a/spring-core/src/test/java/com/baeldung/di/constructor/XmlInjectionUnitTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.di.constructor; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.di.constructor.model.xml.Computer; - -public class XmlInjectionUnitTest { - - private ApplicationContext applicationContext; - - @Before - public void setUp() throws Exception { - applicationContext = new ClassPathXmlApplicationContext("application-di-constructor-context.xml"); - } - - @Test - public void getComputer_() { - final Computer computer = applicationContext.getBean("computer", Computer.class); - assertNotNull(computer); - } - -} diff --git a/spring-core/src/test/java/com/baeldung/di/setter/AutowireAnnotationInjectionUnitTest.java b/spring-core/src/test/java/com/baeldung/di/setter/AutowireAnnotationInjectionUnitTest.java deleted file mode 100644 index fc8e58f08b..0000000000 --- a/spring-core/src/test/java/com/baeldung/di/setter/AutowireAnnotationInjectionUnitTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.di.setter; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.setter.config.SpringAutowireSetterContext; -import com.baeldung.di.setter.model.autowire.Computer; - -public class AutowireAnnotationInjectionUnitTest { - - private ApplicationContext applicationContext; - - @Before - public void setUp() throws Exception { - applicationContext = new AnnotationConfigApplicationContext(SpringAutowireSetterContext.class); - } - - @Test - public void getComputer_() { - final Computer computer = applicationContext.getBean("computer", Computer.class); - assertNotNull(computer); - } - -} diff --git a/spring-core/src/test/java/com/baeldung/di/setter/BeanAnnotationInjectionUnitTest.java b/spring-core/src/test/java/com/baeldung/di/setter/BeanAnnotationInjectionUnitTest.java deleted file mode 100644 index c89c1239ba..0000000000 --- a/spring-core/src/test/java/com/baeldung/di/setter/BeanAnnotationInjectionUnitTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.di.setter; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.di.setter.config.SpringBeanSetterContext; -import com.baeldung.di.setter.model.bean.Computer; - -public class BeanAnnotationInjectionUnitTest { - - private ApplicationContext applicationContext; - - @Before - public void setUp() throws Exception { - applicationContext = new AnnotationConfigApplicationContext(SpringBeanSetterContext.class); - } - - @Test - public void getComputer_() { - final Computer computer = applicationContext.getBean("computer", Computer.class); - assertNotNull(computer); - } - -} diff --git a/spring-core/src/test/java/com/baeldung/di/setter/XmlInjectionUnitTest.java b/spring-core/src/test/java/com/baeldung/di/setter/XmlInjectionUnitTest.java deleted file mode 100644 index 0f38b46194..0000000000 --- a/spring-core/src/test/java/com/baeldung/di/setter/XmlInjectionUnitTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.di.setter; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.di.setter.model.xml.Computer; - -public class XmlInjectionUnitTest { - - private ApplicationContext applicationContext; - - @Before - public void setUp() throws Exception { - applicationContext = new ClassPathXmlApplicationContext("application-di-setter-context.xml"); - } - - @Test - public void getComputer_() { - final Computer computer = applicationContext.getBean("computer", Computer.class); - assertNotNull(computer); - } - -}