Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jaeyeon.seo
committed
Nov 6, 2020
1 parent
ec07662
commit d248362
Showing
5 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...g-toby/java-project/src/main/java/com/javabom/toby/chapter1/term/제어의_역전/IoCContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.javabom.toby.chapter1.term.제어의_역전; | ||
|
||
public class IoCContainer { | ||
|
||
/** | ||
* IoC: 제어의 역전 | ||
* UserService의 UserRepository 구현체에 대한 생성의 책임을 IoCContainer에 위임한다. | ||
* | ||
* @return | ||
*/ | ||
public UserService javabomUserService() { | ||
return new UserService(new JavabomUserRepository()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...va-project/src/main/java/com/javabom/toby/chapter1/term/제어의_역전/JavabomUserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.javabom.toby.chapter1.term.제어의_역전; | ||
|
||
public class JavabomUserRepository implements UserRepository { | ||
} |
4 changes: 4 additions & 0 deletions
4
...toby/java-project/src/main/java/com/javabom/toby/chapter1/term/제어의_역전/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.javabom.toby.chapter1.term.제어의_역전; | ||
|
||
public interface UserRepository { | ||
} |
9 changes: 9 additions & 0 deletions
9
...ng-toby/java-project/src/main/java/com/javabom/toby/chapter1/term/제어의_역전/UserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.javabom.toby.chapter1.term.제어의_역전; | ||
|
||
public class UserService { | ||
private final UserRepository userRepository; | ||
|
||
public UserService(UserRepository userRepository) { | ||
this.userRepository = userRepository; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...by/java-project/src/test/java/com/javabom/toby/chapter1/term/제어의_역전/IoCContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.javabom.toby.chapter1.term.제어의_역전; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class IoCContainerTest { | ||
|
||
@DisplayName("클라이언트는 IoCContainer를 통해 UserService를 얻는다") | ||
@Test | ||
void ioc() { | ||
IoCContainer container = new IoCContainer(); | ||
UserService userService = container.javabomUserService(); | ||
} | ||
|
||
|
||
} |