[24기_김강민] spring tutorial 미션 제출합니다. - #5
Conversation
| public OrderServiceImpl(MemberRepository memberRepository, @Qualifier("mainDiscountPolicy") DiscountPolicy discountPolicy) | ||
| ``` | ||
|
|
||
| **Collection 주입** |
There was a problem hiding this comment.
여러 구현체를 주입받는 방법을 표로 비교하고, BacktestService에서 전략을 선택하는 사례까지 연결해주셔서 좋았습니다. 각 방식이 어떤 상황에 필요한지 구체적으로 이해할 수 있네요!
shinae1023
left a comment
There was a problem hiding this comment.
과제 수고 많으셨습니다!
생각해보실만한 부분 몇개 남겨두었으니 추가로 공부해보셔도 좋을거같아용
| @@ -1,2 +1,461 @@ | |||
| # spring-tutorial-24th | |||
| CEOS 백엔드 24기 스프링 튜토리얼 | |||
| ## AOP(Aspect-Oriented Programming) | |||
There was a problem hiding this comment.
AOP의 프록시 구조를 잘 정리해주셨네요! 같은 객체 내부에서 this.someMethod()로 @transactional이나 @around 대상 메서드를 호출해도 AOP가 적용될까요?
|
|
||
| ```java | ||
| @Aspect | ||
| public class TimeTraceAop { |
There was a problem hiding this comment.
현재 예시의 TimeTraceAop는 @aspect만 선언되어 있는데, 이 클래스는 어떤 과정을 통해 Spring Bean으로 등록되고 프록시 생성에 참여할까요?
Spring의 @AspectJ 활성화 문서 https://docs.spring.io/spring-framework/reference/6.2/core/aop/ataspectj/aspectj-support.html 를 참고해보세용
| public OrderServiceImpl(MemberRepository memberRepository, @Qualifier("mainDiscountPolicy") DiscountPolicy discountPolicy) | ||
| ``` | ||
|
|
||
| **Collection 주입** |
There was a problem hiding this comment.
Map<String, BacktestStrategy>의 key에는 @qualifier 값과 Bean 이름 중 무엇이 들어갈까요? @primary를 붙이면 Map에는 해당 구현체만 주입될까요?
https://docs.spring.io/spring-framework/reference/core/beans/annotation-config/autowired.html
| @Service | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class BacktestService { |
There was a problem hiding this comment.
strategyMap.get() 결과가 없는 경우뿐 아니라 strategy(series) 내부에서 발생한 NullPointerException도 모두 STRATEGY_NOT_FOUND로 변환될 수 있을 것 같습니다. 두 경우를 어떻게 구분하면 좋을까요?
| - 스프링은 `DispatcherServlet`이라는 단 1개의 거대한 대표 서블릿만 만들어 두고 모든 요청을 다 받는다. (`즉, 그림에서 파란색 Servlet이 하나만 존재`) | ||
| 1. `init()` 호출 시점 (스프링 컨테이너의 탄생) | ||
| - Tomcat이 켜지고 `DispatcherServlet`을 생성하면서 `init()` 메서드를 호출. | ||
| - 바로 이때 `DispatcherServlet`은 내부에 스프링 컨테이너(`ApplicationContext`)를 생성. |
There was a problem hiding this comment.
전통적인 WAR 배포 방식과 Spring Boot의 embedded Tomcat 방식에서 ApplicationContext와 DispatcherServlet은 각각 누가 생성할까요?
https://docs.spring.io/spring-boot/reference/web/servlet.html
적어주신 요방법은 전통적인 WAR 방식이긴합니다ㅎㅎ
There was a problem hiding this comment.
제가 오개념을 알고있었네요!
전통적인 WAR 방식에서는 톰캣이 DispatcherServlet을 생성하고, DispatcherServlet이 ApplicationContext를 생성하는데, 스프링 방식에서는 스프링이 직접 ApplicationContext를 생성하고 이 ApplicationContext가 DispatcherServlet 빈을 생성하여 ServletContext에 등록한다는 점을 알게되었습니다! 감사합니다!
| } | ||
| ``` | ||
|
|
||
| PSA는 SA뿐 아니라 동일한 코드를 **`다양한 환경 (로컬, 클라우드, 온프레미스)에서 재사용할 수 있도록`** 설계된 추상화이다. |
There was a problem hiding this comment.
PSA만 보고 트랜잭션 추상화 정도로만 이해하고 있었는데, SA 자체를 먼저 짚어주셔서 PSA가 왜 SA와 환경 이식성이 합쳐진 개념인지 이해가 훨씬 잘 됐습니다 !! 감사합니다 😀
|
|
||
| **@Primary** | ||
|
|
||
| ```java |
There was a problem hiding this comment.
하나의 인터페이스를 구현한 클래스가 여러 개일 때 해결방법을 표로 정리해주신 것도 도움이 많이 됐는데, 특히 밑에 각각에 대한 예시 코드까지 같이 작성해주셔서 언제 어떤 걸 써야 하는지 훨씬 감을 잡기 쉬웠던 것 같습니다 !! 감사합니당 😊
No description provided.