diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000..26d33521af
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000000..a76eda7cae
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000000..63e9001932
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000000..712ab9d985
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000..d31b37ac7b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000000..e96534fb27
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000..35eb1ddfbb
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HELP.md b/HELP.md
new file mode 100644
index 0000000000..1c4027ce63
--- /dev/null
+++ b/HELP.md
@@ -0,0 +1,14 @@
+# Read Me First
+The following was discovered as part of building this project:
+
+* The original package name 'aine.springframework.sfg-di' is invalid and this project uses 'aine.springframework.sfgdi' instead.
+
+# Getting Started
+
+### Reference Documentation
+For further reference, please consider the following sections:
+
+* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
+* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.6.4/maven-plugin/reference/html/)
+* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.6.4/maven-plugin/reference/html/#build-image)
+
diff --git a/mvnw b/mvnw
index 21d3ee8456..5938ce58b1 100755
--- a/mvnw
+++ b/mvnw
@@ -246,7 +246,7 @@ else
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
-
+
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
diff --git a/mvnw.cmd b/mvnw.cmd
index 84d60abc33..ef6fe160c7 100644
--- a/mvnw.cmd
+++ b/mvnw.cmd
@@ -180,3 +180,4 @@ if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
+
diff --git a/src/main/java/aine/springframework/sfgdi/SfgDiApplication.java b/src/main/java/aine/springframework/sfgdi/SfgDiApplication.java
new file mode 100644
index 0000000000..253a6a86ee
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/SfgDiApplication.java
@@ -0,0 +1,43 @@
+package aine.springframework.sfgdi;
+
+import aine.springframework.sfgdi.controllers.*;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+
+@SpringBootApplication
+public class SfgDiApplication {
+
+ public static void main(String[] args) {
+ ApplicationContext ctx = SpringApplication.run(SfgDiApplication.class, args);
+
+ I18nController i18nController = (I18nController) ctx.getBean("i18nController");
+ System.out.println(i18nController.sayHello());
+
+ MyController myController = (MyController) ctx.getBean("myController");
+
+ System.out.println("-------- Primary Bean");
+
+ System.out.println(myController.sayHello());
+
+ System.out.println("-------- Property");
+
+ PropertyInjectedController propertyInjectedController = (PropertyInjectedController) ctx.getBean("propertyInjectedController");
+
+ System.out.println(propertyInjectedController.getGreeting());
+
+ System.out.println("-------- Setter");
+
+ SetterBasedController setterBasedController = (SetterBasedController) ctx.getBean("setterBasedController");
+
+ System.out.println(setterBasedController.getGreeting());
+
+ System.out.println("-------- Constructor");
+
+ ConstructorInjectedController constructorInjectedController = (ConstructorInjectedController) ctx.getBean("constructorInjectedController");
+
+ System.out.println(constructorInjectedController.getGreeting());
+
+ }
+
+}
diff --git a/src/main/java/aine/springframework/sfgdi/controllers/ConstructorInjectedController.java b/src/main/java/aine/springframework/sfgdi/controllers/ConstructorInjectedController.java
new file mode 100644
index 0000000000..41bece3ac7
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/controllers/ConstructorInjectedController.java
@@ -0,0 +1,20 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.GreetingService;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class ConstructorInjectedController {
+
+ private final GreetingService greetingService;
+
+ public ConstructorInjectedController(@Qualifier("constructorGreetingService") GreetingService greetingService) {
+ this.greetingService = greetingService;
+ }
+
+ public String getGreeting() {
+ return greetingService.sayGreeting();
+ }
+
+}
diff --git a/src/main/java/aine/springframework/sfgdi/controllers/I18nController.java b/src/main/java/aine/springframework/sfgdi/controllers/I18nController.java
new file mode 100644
index 0000000000..403cec84bf
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/controllers/I18nController.java
@@ -0,0 +1,18 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.GreetingService;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class I18nController {
+ private final GreetingService greetingService;
+
+ public I18nController(@Qualifier("i18nService") GreetingService greetingService) {
+ this.greetingService = greetingService;
+ }
+
+ public String sayHello(){
+ return greetingService.sayGreeting();
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/controllers/MyController.java b/src/main/java/aine/springframework/sfgdi/controllers/MyController.java
new file mode 100644
index 0000000000..7565fd2d58
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/controllers/MyController.java
@@ -0,0 +1,18 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.GreetingService;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class MyController {
+
+ private final GreetingService greetingService;
+
+ public MyController(GreetingService greetingService) {
+ this.greetingService = greetingService;
+ }
+
+ public String sayHello() {
+ return greetingService.sayGreeting();
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/controllers/PropertyInjectedController.java b/src/main/java/aine/springframework/sfgdi/controllers/PropertyInjectedController.java
new file mode 100644
index 0000000000..1134c7d03e
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/controllers/PropertyInjectedController.java
@@ -0,0 +1,18 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.GreetingService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class PropertyInjectedController {
+
+ @Qualifier("propertyInjectedGreetingService")
+ @Autowired
+ public GreetingService greetingService;
+
+ public String getGreeting() {
+ return greetingService.sayGreeting();
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/controllers/SetterBasedController.java b/src/main/java/aine/springframework/sfgdi/controllers/SetterBasedController.java
new file mode 100644
index 0000000000..c571f32dd4
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/controllers/SetterBasedController.java
@@ -0,0 +1,21 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.GreetingService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class SetterBasedController {
+ private GreetingService greetingService;
+
+ @Autowired
+ @Qualifier("setterGreetingService")
+ public void setGreetingService(GreetingService greetingService) {
+ this.greetingService = greetingService;
+ }
+
+ public String getGreeting() {
+ return greetingService.sayGreeting();
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/ConstructorGreetingService.java b/src/main/java/aine/springframework/sfgdi/services/ConstructorGreetingService.java
new file mode 100644
index 0000000000..026b18cccf
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/ConstructorGreetingService.java
@@ -0,0 +1,11 @@
+package aine.springframework.sfgdi.services;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ConstructorGreetingService implements GreetingService{
+ @Override
+ public String sayGreeting() {
+ return "Hello World - Constructor";
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/GreetingService.java b/src/main/java/aine/springframework/sfgdi/services/GreetingService.java
new file mode 100644
index 0000000000..63ef49cd29
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/GreetingService.java
@@ -0,0 +1,6 @@
+package aine.springframework.sfgdi.services;
+
+public interface GreetingService {
+
+ String sayGreeting();
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/I18nEnglishGreetingService.java b/src/main/java/aine/springframework/sfgdi/services/I18nEnglishGreetingService.java
new file mode 100644
index 0000000000..d589d2af29
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/I18nEnglishGreetingService.java
@@ -0,0 +1,13 @@
+package aine.springframework.sfgdi.services;
+
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Service;
+
+@Profile("EN")
+@Service("i18nService")
+public class I18nEnglishGreetingService implements GreetingService{
+ @Override
+ public String sayGreeting() {
+ return "Hello World - EN";
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/I18nFrenchGreetingService.java b/src/main/java/aine/springframework/sfgdi/services/I18nFrenchGreetingService.java
new file mode 100644
index 0000000000..317cecf678
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/I18nFrenchGreetingService.java
@@ -0,0 +1,13 @@
+package aine.springframework.sfgdi.services;
+
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Service;
+
+@Profile({"FR", "default"})
+@Service("i18nService")
+public class I18nFrenchGreetingService implements GreetingService{
+ @Override
+ public String sayGreeting() {
+ return "Bienvenue au Monde - FR";
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/PrimaryGreetingService.java b/src/main/java/aine/springframework/sfgdi/services/PrimaryGreetingService.java
new file mode 100644
index 0000000000..4642c0916f
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/PrimaryGreetingService.java
@@ -0,0 +1,14 @@
+package aine.springframework.sfgdi.services;
+
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+
+@Primary
+@Service
+public class PrimaryGreetingService implements GreetingService{
+
+ @Override
+ public String sayGreeting() {
+ return "Hello World - From the Primary Bean";
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/PropertyInjectedGreetingService.java b/src/main/java/aine/springframework/sfgdi/services/PropertyInjectedGreetingService.java
new file mode 100644
index 0000000000..56a2cc3c17
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/PropertyInjectedGreetingService.java
@@ -0,0 +1,11 @@
+package aine.springframework.sfgdi.services;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class PropertyInjectedGreetingService implements GreetingService {
+ @Override
+ public String sayGreeting() {
+ return "Hello World - Property";
+ }
+}
diff --git a/src/main/java/aine/springframework/sfgdi/services/SetterGreetingService.java b/src/main/java/aine/springframework/sfgdi/services/SetterGreetingService.java
new file mode 100644
index 0000000000..cf275527d5
--- /dev/null
+++ b/src/main/java/aine/springframework/sfgdi/services/SetterGreetingService.java
@@ -0,0 +1,12 @@
+package aine.springframework.sfgdi.services;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class SetterGreetingService implements GreetingService {
+
+ @Override
+ public String sayGreeting() {
+ return "Hello World - Setter";
+ }
+}
diff --git a/src/main/java/com/springframework/pets/controllers/PetController.java b/src/main/java/com/springframework/pets/controllers/PetController.java
new file mode 100644
index 0000000000..3d4ed4a136
--- /dev/null
+++ b/src/main/java/com/springframework/pets/controllers/PetController.java
@@ -0,0 +1,21 @@
+package com.springframework.pets.controllers;
+
+import com.springframework.pets.services.PetService;
+import org.springframework.stereotype.Controller;
+
+/**
+ * Created by jt on 12/28/19.
+ */
+@Controller
+public class PetController {
+
+ private final PetService petService;
+
+ public PetController(PetService petService) {
+ this.petService = petService;
+ }
+
+ public String whichPetIsTheBest(){
+ return petService.getPetType();
+ }
+}
diff --git a/src/main/java/com/springframework/pets/services/CatPetService.java b/src/main/java/com/springframework/pets/services/CatPetService.java
new file mode 100644
index 0000000000..fc39ca61ab
--- /dev/null
+++ b/src/main/java/com/springframework/pets/services/CatPetService.java
@@ -0,0 +1,16 @@
+package com.springframework.pets.services;
+
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by jt on 12/28/19.
+ */
+@Service
+@Profile("cat")
+public class CatPetService implements PetService {
+ @Override
+ public String getPetType() {
+ return "Cats Are the Best!";
+ }
+}
diff --git a/src/main/java/com/springframework/pets/services/DogPetService.java b/src/main/java/com/springframework/pets/services/DogPetService.java
new file mode 100644
index 0000000000..af9ac73d76
--- /dev/null
+++ b/src/main/java/com/springframework/pets/services/DogPetService.java
@@ -0,0 +1,15 @@
+package com.springframework.pets.services;
+
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by jt on 12/28/19.
+ */
+@Profile({"dog", "default"})
+@Service
+public class DogPetService implements PetService {
+ public String getPetType(){
+ return "Dogs are the best!";
+ }
+}
diff --git a/src/main/java/com/springframework/pets/services/PetService.java b/src/main/java/com/springframework/pets/services/PetService.java
new file mode 100644
index 0000000000..e79eebebc8
--- /dev/null
+++ b/src/main/java/com/springframework/pets/services/PetService.java
@@ -0,0 +1,9 @@
+package com.springframework.pets.services;
+
+/**
+ * Created by jt on 12/28/19.
+ */
+public interface PetService {
+
+ String getPetType();
+}
diff --git a/src/main/java/guru/springframework/sfgdi/SfgDiApplication.java b/src/main/java/guru/springframework/sfgdi/SfgDiApplication.java
index 4bf4a4938d..fb96c2b193 100644
--- a/src/main/java/guru/springframework/sfgdi/SfgDiApplication.java
+++ b/src/main/java/guru/springframework/sfgdi/SfgDiApplication.java
@@ -1,16 +1,23 @@
package guru.springframework.sfgdi;
+import com.springframework.pets.controllers.PetController;
import guru.springframework.sfgdi.controllers.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+@ComponentScan(basePackages = {"guru.springframework.sfgdi", "com.springframework.pets"})
@SpringBootApplication
public class SfgDiApplication {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(SfgDiApplication.class, args);
+ PetController petController = ctx.getBean("petController", PetController.class);
+ System.out.println("--- The Best Pet is ---");
+ System.out.println(petController.whichPetIsTheBest());
+
I18nController i18nController = (I18nController) ctx.getBean("i18nController");
System.out.println(i18nController.sayHello());
diff --git a/src/main/java/guru/springframework/sfgdi/config/GreetingServiceConfig.java b/src/main/java/guru/springframework/sfgdi/config/GreetingServiceConfig.java
new file mode 100644
index 0000000000..15e1bfbd08
--- /dev/null
+++ b/src/main/java/guru/springframework/sfgdi/config/GreetingServiceConfig.java
@@ -0,0 +1,51 @@
+package guru.springframework.sfgdi.config;
+
+import guru.springframework.sfgdi.repositories.EnglishGreetingRepository;
+import guru.springframework.sfgdi.repositories.EnglishGreetingRepositoryImpl;
+import guru.springframework.sfgdi.services.*;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+
+@Configuration
+public class GreetingServiceConfig {
+
+ @Profile({"ES"})
+ @Bean("i18nService")
+ I18NSpanishService i18NSpanishService(){
+ return new I18NSpanishService();
+ }
+
+ @Bean
+ EnglishGreetingRepository englishGreetingRepository(){
+ return new EnglishGreetingRepositoryImpl();
+ }
+
+ @Profile({"EN", "default"})
+ @Bean("i18nService")
+ I18nEnglishGreetingService i18nService(EnglishGreetingRepository englishGreetingRepository){
+ return new I18nEnglishGreetingService(englishGreetingRepository);
+ }
+
+ @Primary
+ @Bean
+ PrimaryGreetingService primaryGreetingService(){
+ return new PrimaryGreetingService();
+ }
+
+ @Bean
+ ConstructorGreetingService constructorGreetingService(){
+ return new ConstructorGreetingService();
+ }
+
+ @Bean
+ SetterInjectedGreetingService setterInjectedGreetingService() {
+ return new SetterInjectedGreetingService();
+ }
+
+ @Bean
+ PropertyInjectedGreetingService propertyInjectedGreetingService(){
+ return new PropertyInjectedGreetingService();
+ }
+}
diff --git a/src/main/java/guru/springframework/sfgdi/repositories/EnglishGreetingRepository.java b/src/main/java/guru/springframework/sfgdi/repositories/EnglishGreetingRepository.java
new file mode 100644
index 0000000000..a021ccb128
--- /dev/null
+++ b/src/main/java/guru/springframework/sfgdi/repositories/EnglishGreetingRepository.java
@@ -0,0 +1,6 @@
+package guru.springframework.sfgdi.repositories;
+
+public interface EnglishGreetingRepository {
+
+ String getGreeting();
+}
diff --git a/src/main/java/guru/springframework/sfgdi/repositories/EnglishGreetingRepositoryImpl.java b/src/main/java/guru/springframework/sfgdi/repositories/EnglishGreetingRepositoryImpl.java
new file mode 100644
index 0000000000..9ed185375e
--- /dev/null
+++ b/src/main/java/guru/springframework/sfgdi/repositories/EnglishGreetingRepositoryImpl.java
@@ -0,0 +1,9 @@
+package guru.springframework.sfgdi.repositories;
+
+public class EnglishGreetingRepositoryImpl implements EnglishGreetingRepository{
+
+ @Override
+ public String getGreeting(){
+ return "Hello World - EN";
+ }
+}
diff --git a/src/main/java/guru/springframework/sfgdi/services/ConstructorGreetingService.java b/src/main/java/guru/springframework/sfgdi/services/ConstructorGreetingService.java
index a546a690be..28c01acf8b 100644
--- a/src/main/java/guru/springframework/sfgdi/services/ConstructorGreetingService.java
+++ b/src/main/java/guru/springframework/sfgdi/services/ConstructorGreetingService.java
@@ -5,7 +5,6 @@
/**
* Created by jt on 12/26/19.
*/
-@Service
public class ConstructorGreetingService implements GreetingService {
@Override
public String sayGreeting() {
diff --git a/src/main/java/guru/springframework/sfgdi/services/CustomBeanPostProcessor.java b/src/main/java/guru/springframework/sfgdi/services/CustomBeanPostProcessor.java
new file mode 100644
index 0000000000..29a71f9124
--- /dev/null
+++ b/src/main/java/guru/springframework/sfgdi/services/CustomBeanPostProcessor.java
@@ -0,0 +1,28 @@
+package guru.springframework.sfgdi.services;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CustomBeanPostProcessor implements BeanPostProcessor {
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+
+ if(bean instanceof LifeCycleDemoBean){
+ ((LifeCycleDemoBean) bean).beforeInit();
+ }
+
+ return bean;
+ }
+
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ if(bean instanceof LifeCycleDemoBean){
+ ((LifeCycleDemoBean) bean).afterInit();
+ }
+
+ return bean;
+ }
+}
diff --git a/src/main/java/guru/springframework/sfgdi/services/I18NSpanishService.java b/src/main/java/guru/springframework/sfgdi/services/I18NSpanishService.java
index 1ab3570f5e..c5891e1279 100644
--- a/src/main/java/guru/springframework/sfgdi/services/I18NSpanishService.java
+++ b/src/main/java/guru/springframework/sfgdi/services/I18NSpanishService.java
@@ -6,11 +6,9 @@
/**
* Created by jt on 12/27/19.
*/
-@Profile({"ES", "default"})
-@Service("i18nService")
public class I18NSpanishService implements GreetingService {
@Override
public String sayGreeting() {
- return "Hola Mundo - ES";
+ return "Hola chika - ES";
}
}
diff --git a/src/main/java/guru/springframework/sfgdi/services/I18nEnglishGreetingService.java b/src/main/java/guru/springframework/sfgdi/services/I18nEnglishGreetingService.java
index 0b56d78eb5..eaaaf9eb3d 100644
--- a/src/main/java/guru/springframework/sfgdi/services/I18nEnglishGreetingService.java
+++ b/src/main/java/guru/springframework/sfgdi/services/I18nEnglishGreetingService.java
@@ -1,16 +1,22 @@
package guru.springframework.sfgdi.services;
+import guru.springframework.sfgdi.repositories.EnglishGreetingRepository;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
/**
* Created by jt on 12/27/19.
*/
-@Profile("EN")
-@Service("i18nService")
public class I18nEnglishGreetingService implements GreetingService {
+
+ private final EnglishGreetingRepository englishGreetingRepository;
+
+ public I18nEnglishGreetingService(EnglishGreetingRepository englishGreetingRepository) {
+ this.englishGreetingRepository = englishGreetingRepository;
+ }
+
@Override
public String sayGreeting() {
- return "Hello World - EN";
+ return "goodbye world";
}
}
diff --git a/src/main/java/guru/springframework/sfgdi/services/LifeCycleDemoBean.java b/src/main/java/guru/springframework/sfgdi/services/LifeCycleDemoBean.java
new file mode 100644
index 0000000000..f224398deb
--- /dev/null
+++ b/src/main/java/guru/springframework/sfgdi/services/LifeCycleDemoBean.java
@@ -0,0 +1,66 @@
+package guru.springframework.sfgdi.services;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.*;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@Component
+public class LifeCycleDemoBean implements InitializingBean, DisposableBean, BeanNameAware,
+ BeanFactoryAware, ApplicationContextAware {
+
+
+ public LifeCycleDemoBean() {
+ System.out.println("## I'm in the LifeCycleBean Constructor");
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ System.out.println("## The Lifecycle bean has been terminated");
+
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ System.out.println("## The LifeCycleBean has its properties set!");
+
+ }
+
+ @Override
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ System.out.println("## Bean Factory has been set");
+ }
+
+ @Override
+ public void setBeanName(String name) {
+ System.out.println("## My Bean Name is: " + name);
+
+ }
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ System.out.println("## Application context has been set");
+ }
+
+ @PostConstruct
+ public void postConstruct(){
+ System.out.println("## The Post Construct annotated method has been called");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ System.out.println("## The Predestroy annotated method has been called");
+ }
+
+ public void beforeInit(){
+ System.out.println("## - Before Init - Called by Bean Post Processor");
+ }
+
+ public void afterInit(){
+ System.out.println("## - After init called by Bean Post Processor");
+ }
+}
diff --git a/src/main/java/guru/springframework/sfgdi/services/PrimaryGreetingService.java b/src/main/java/guru/springframework/sfgdi/services/PrimaryGreetingService.java
index f47f65b81a..7ff4eef9a4 100644
--- a/src/main/java/guru/springframework/sfgdi/services/PrimaryGreetingService.java
+++ b/src/main/java/guru/springframework/sfgdi/services/PrimaryGreetingService.java
@@ -6,8 +6,6 @@
/**
* Created by jt on 12/27/19.
*/
-@Primary
-@Service
public class PrimaryGreetingService implements GreetingService {
@Override
diff --git a/src/main/java/guru/springframework/sfgdi/services/PropertyInjectedGreetingService.java b/src/main/java/guru/springframework/sfgdi/services/PropertyInjectedGreetingService.java
index 7ff2a8b3a2..e244125328 100644
--- a/src/main/java/guru/springframework/sfgdi/services/PropertyInjectedGreetingService.java
+++ b/src/main/java/guru/springframework/sfgdi/services/PropertyInjectedGreetingService.java
@@ -5,7 +5,6 @@
/**
* Created by jt on 12/27/19.
*/
-@Service
public class PropertyInjectedGreetingService implements GreetingService {
@Override
public String sayGreeting() {
diff --git a/src/main/java/guru/springframework/sfgdi/services/SetterInjectedGreetingService.java b/src/main/java/guru/springframework/sfgdi/services/SetterInjectedGreetingService.java
index 40231dacac..8598eedec5 100644
--- a/src/main/java/guru/springframework/sfgdi/services/SetterInjectedGreetingService.java
+++ b/src/main/java/guru/springframework/sfgdi/services/SetterInjectedGreetingService.java
@@ -5,7 +5,6 @@
/**
* Created by jt on 12/27/19.
*/
-@Service
public class SetterInjectedGreetingService implements GreetingService{
@Override
public String sayGreeting() {
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index f925173f32..a5e97dc837 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1 +1 @@
-#spring.profiles.active=EN
+spring.profiles.active=cat,EN
diff --git a/src/test/java/aine/springframework/sfgdi/SfgDiApplicationTests.java b/src/test/java/aine/springframework/sfgdi/SfgDiApplicationTests.java
new file mode 100644
index 0000000000..19477879be
--- /dev/null
+++ b/src/test/java/aine/springframework/sfgdi/SfgDiApplicationTests.java
@@ -0,0 +1,13 @@
+package aine.springframework.sfgdi;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SfgDiApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/src/test/java/aine/springframework/sfgdi/controllers/ConstructorInjectedControllerTest.java b/src/test/java/aine/springframework/sfgdi/controllers/ConstructorInjectedControllerTest.java
new file mode 100644
index 0000000000..c4fc1eb961
--- /dev/null
+++ b/src/test/java/aine/springframework/sfgdi/controllers/ConstructorInjectedControllerTest.java
@@ -0,0 +1,21 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.ConstructorGreetingService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class ConstructorInjectedControllerTest {
+
+ ConstructorInjectedController controller;
+
+ @BeforeEach
+ void setUp() {
+
+ controller = new ConstructorInjectedController(new ConstructorGreetingService());
+ }
+
+ @Test
+ void getGreeting() {
+ System.out.println(controller.getGreeting());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/aine/springframework/sfgdi/controllers/PropertyInjectedControllerTest.java b/src/test/java/aine/springframework/sfgdi/controllers/PropertyInjectedControllerTest.java
new file mode 100644
index 0000000000..a162f1b4f0
--- /dev/null
+++ b/src/test/java/aine/springframework/sfgdi/controllers/PropertyInjectedControllerTest.java
@@ -0,0 +1,21 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.ConstructorGreetingService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class PropertyInjectedControllerTest {
+
+ PropertyInjectedController controller;
+
+ @BeforeEach
+ void setUp() {
+ controller = new PropertyInjectedController();
+ controller.greetingService = new ConstructorGreetingService();
+ }
+
+ @Test
+ void getGreeting() {
+ System.out.println(controller.getGreeting());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/aine/springframework/sfgdi/controllers/SetterBasedControllerTest.java b/src/test/java/aine/springframework/sfgdi/controllers/SetterBasedControllerTest.java
new file mode 100644
index 0000000000..c30dfb0b3e
--- /dev/null
+++ b/src/test/java/aine/springframework/sfgdi/controllers/SetterBasedControllerTest.java
@@ -0,0 +1,21 @@
+package aine.springframework.sfgdi.controllers;
+
+import aine.springframework.sfgdi.services.ConstructorGreetingService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class SetterBasedControllerTest {
+
+ SetterBasedController controller;
+
+ @BeforeEach
+ void setUp() {
+ controller = new SetterBasedController();
+ controller.setGreetingServiceng(new ConstructorGreetingService());
+ }
+
+ @Test
+ void getGreeting() {
+ System.out.println(controller.getGreeting());
+ }
+}
\ No newline at end of file
diff --git a/target/classes/aine/springframework/sfgdi/SfgDiApplication.class b/target/classes/aine/springframework/sfgdi/SfgDiApplication.class
new file mode 100644
index 0000000000..cd15a43687
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/SfgDiApplication.class differ
diff --git a/target/classes/aine/springframework/sfgdi/controllers/ConstructorInjectedController.class b/target/classes/aine/springframework/sfgdi/controllers/ConstructorInjectedController.class
new file mode 100644
index 0000000000..fb604daef1
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/controllers/ConstructorInjectedController.class differ
diff --git a/target/classes/aine/springframework/sfgdi/controllers/I18nController.class b/target/classes/aine/springframework/sfgdi/controllers/I18nController.class
new file mode 100644
index 0000000000..aace2af38d
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/controllers/I18nController.class differ
diff --git a/target/classes/aine/springframework/sfgdi/controllers/MyController.class b/target/classes/aine/springframework/sfgdi/controllers/MyController.class
new file mode 100644
index 0000000000..5a243de3f0
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/controllers/MyController.class differ
diff --git a/target/classes/aine/springframework/sfgdi/controllers/PropertyInjectedController.class b/target/classes/aine/springframework/sfgdi/controllers/PropertyInjectedController.class
new file mode 100644
index 0000000000..0cd2f26a9e
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/controllers/PropertyInjectedController.class differ
diff --git a/target/classes/aine/springframework/sfgdi/controllers/SetterBasedController.class b/target/classes/aine/springframework/sfgdi/controllers/SetterBasedController.class
new file mode 100644
index 0000000000..774177edf3
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/controllers/SetterBasedController.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/ConstructorGreetingService.class b/target/classes/aine/springframework/sfgdi/services/ConstructorGreetingService.class
new file mode 100644
index 0000000000..236b761cc6
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/ConstructorGreetingService.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/GreetingService.class b/target/classes/aine/springframework/sfgdi/services/GreetingService.class
new file mode 100644
index 0000000000..68751c8d65
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/GreetingService.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/I18nEnglishGreetingService.class b/target/classes/aine/springframework/sfgdi/services/I18nEnglishGreetingService.class
new file mode 100644
index 0000000000..0785bb9d06
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/I18nEnglishGreetingService.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/I18nFrenchGreetingService.class b/target/classes/aine/springframework/sfgdi/services/I18nFrenchGreetingService.class
new file mode 100644
index 0000000000..dd8ee9a521
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/I18nFrenchGreetingService.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/PrimaryGreetingService.class b/target/classes/aine/springframework/sfgdi/services/PrimaryGreetingService.class
new file mode 100644
index 0000000000..0700c42052
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/PrimaryGreetingService.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/PropertyInjectedGreetingService.class b/target/classes/aine/springframework/sfgdi/services/PropertyInjectedGreetingService.class
new file mode 100644
index 0000000000..6ccc87e10e
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/PropertyInjectedGreetingService.class differ
diff --git a/target/classes/aine/springframework/sfgdi/services/SetterGreetingService.class b/target/classes/aine/springframework/sfgdi/services/SetterGreetingService.class
new file mode 100644
index 0000000000..10393d238d
Binary files /dev/null and b/target/classes/aine/springframework/sfgdi/services/SetterGreetingService.class differ
diff --git a/target/classes/application.properties b/target/classes/application.properties
new file mode 100644
index 0000000000..e00d7bd2ad
--- /dev/null
+++ b/target/classes/application.properties
@@ -0,0 +1 @@
+spring.profiles.active=FR
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
new file mode 100644
index 0000000000..26c2c492fd
--- /dev/null
+++ b/target/maven-archiver/pom.properties
@@ -0,0 +1,3 @@
+artifactId=sfg-di
+groupId=aine.springframework
+version=0.0.1-SNAPSHOT
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000000..2b1ff62a00
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+aine\springframework\sfgdi\SfgDiApplication.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000000..be5f0e5f3c
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+C:\Users\aine.kearns\Documents\Spring Projects\sfg-di\src\main\java\aine\springframework\sfgdi\SfgDiApplication.java
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
new file mode 100644
index 0000000000..9399fbc84f
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
@@ -0,0 +1 @@
+aine\springframework\sfgdi\SfgDiApplicationTests.class
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 0000000000..d97ae3f977
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1 @@
+C:\Users\aine.kearns\Documents\Spring Projects\sfg-di\src\test\java\aine\springframework\sfgdi\SfgDiApplicationTests.java
diff --git a/target/sfg-di-0.0.1-SNAPSHOT.jar b/target/sfg-di-0.0.1-SNAPSHOT.jar
new file mode 100644
index 0000000000..84f4ef54f9
Binary files /dev/null and b/target/sfg-di-0.0.1-SNAPSHOT.jar differ
diff --git a/target/sfg-di-0.0.1-SNAPSHOT.jar.original b/target/sfg-di-0.0.1-SNAPSHOT.jar.original
new file mode 100644
index 0000000000..96bdd59d91
Binary files /dev/null and b/target/sfg-di-0.0.1-SNAPSHOT.jar.original differ
diff --git a/target/surefire-reports/TEST-aine.springframework.sfgdi.SfgDiApplicationTests.xml b/target/surefire-reports/TEST-aine.springframework.sfgdi.SfgDiApplicationTests.xml
new file mode 100644
index 0000000000..0a6bda9971
--- /dev/null
+++ b/target/surefire-reports/TEST-aine.springframework.sfgdi.SfgDiApplicationTests.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/surefire-reports/aine.springframework.sfgdi.SfgDiApplicationTests.txt b/target/surefire-reports/aine.springframework.sfgdi.SfgDiApplicationTests.txt
new file mode 100644
index 0000000000..5274059dd6
--- /dev/null
+++ b/target/surefire-reports/aine.springframework.sfgdi.SfgDiApplicationTests.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: aine.springframework.sfgdi.SfgDiApplicationTests
+-------------------------------------------------------------------------------
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.78 s - in aine.springframework.sfgdi.SfgDiApplicationTests
diff --git a/target/test-classes/aine/springframework/sfgdi/SfgDiApplicationTests.class b/target/test-classes/aine/springframework/sfgdi/SfgDiApplicationTests.class
new file mode 100644
index 0000000000..78a79014cf
Binary files /dev/null and b/target/test-classes/aine/springframework/sfgdi/SfgDiApplicationTests.class differ
diff --git a/target/test-classes/aine/springframework/sfgdi/controllers/ConstructorInjectedControllerTest.class b/target/test-classes/aine/springframework/sfgdi/controllers/ConstructorInjectedControllerTest.class
new file mode 100644
index 0000000000..337066f841
Binary files /dev/null and b/target/test-classes/aine/springframework/sfgdi/controllers/ConstructorInjectedControllerTest.class differ
diff --git a/target/test-classes/aine/springframework/sfgdi/controllers/PropertyInjectedControllerTest.class b/target/test-classes/aine/springframework/sfgdi/controllers/PropertyInjectedControllerTest.class
new file mode 100644
index 0000000000..aefbf1916a
Binary files /dev/null and b/target/test-classes/aine/springframework/sfgdi/controllers/PropertyInjectedControllerTest.class differ
diff --git a/target/test-classes/aine/springframework/sfgdi/controllers/SetterBasedControllerTest.class b/target/test-classes/aine/springframework/sfgdi/controllers/SetterBasedControllerTest.class
new file mode 100644
index 0000000000..44669c7fa3
Binary files /dev/null and b/target/test-classes/aine/springframework/sfgdi/controllers/SetterBasedControllerTest.class differ