-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
섹션4: 프록시 패턴과 데코레이터 패턴
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
스프링 로드맵5 고급편/proxy/src/test/java/hello/proxy/pureproxy/decorator/DecoratorPatternTest.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,20 @@ | ||
package hello.proxy.pureproxy.decorator; | ||
|
||
import hello.proxy.pureproxy.decorator.code.DecoratorPatternClient; | ||
import hello.proxy.pureproxy.decorator.code.RealComponent; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@Slf4j | ||
public class DecoratorPatternTest { | ||
|
||
@Test | ||
void noDecoration() { | ||
RealComponent realComponent = new RealComponent(); | ||
DecoratorPatternClient client = new DecoratorPatternClient(realComponent); | ||
|
||
client.execute(); | ||
client.execute(); | ||
client.execute(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
스프링 로드맵5 고급편/proxy/src/test/java/hello/proxy/pureproxy/decorator/code/Component.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,5 @@ | ||
package hello.proxy.pureproxy.decorator.code; | ||
|
||
public interface Component { | ||
String operation(); | ||
} |
18 changes: 18 additions & 0 deletions
18
... 고급편/proxy/src/test/java/hello/proxy/pureproxy/decorator/code/DecoratorPatternClient.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,18 @@ | ||
package hello.proxy.pureproxy.decorator.code; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class DecoratorPatternClient { | ||
|
||
private Component component; | ||
|
||
public DecoratorPatternClient(final Component component) { | ||
this.component = component; | ||
} | ||
|
||
public void execute() { | ||
String operation = component.operation(); | ||
log.info("result = {}", operation); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
스프링 로드맵5 고급편/proxy/src/test/java/hello/proxy/pureproxy/decorator/code/RealComponent.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,12 @@ | ||
package hello.proxy.pureproxy.decorator.code; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class RealComponent implements Component { | ||
@Override | ||
public String operation() { | ||
log.info("RealComponent 실행"); | ||
return "data"; | ||
} | ||
} |