Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
@@ -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)

2 changes: 1 addition & 1 deletion mvnw

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mvnw.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/main/java/aine/springframework/sfgdi/SfgDiApplication.java
Original file line number Diff line number Diff line change
@@ -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());

}

}
Original file line number Diff line number Diff line change
@@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package aine.springframework.sfgdi.services;

public interface GreetingService {

String sayGreeting();
}
Loading