-
2021.07.18 기록장TIL 2021. 7. 17. 23:16
ToDo
- 알고리즘 2문제
- 책 읽기
- 토비의 스프링
- 북마크 보기
- 컨트리뷰어 지원
Done
- 알고리즘 2문제
- 책 읽기
- 토비의 스프링
Weekly goal
- 책 읽기
- 토비 스프링 코딩
- 플젝?
토비의 스프링
369p.
스프링의 트랜잭션 서비스 추상화
스프링이 제공하는 트랜잭션 추상화 계층 구조 최상위는 PlatformTransactionManager이 존재한다.
jpa나 jdbc등은 트랜잭션 경계설정 방법이 다르기에 스프링에서 추상화 방법을 제공한다.
구현체를 만들고 DI를 하면 OCP를 만족할 수 있다.
PlatformTransactionManager (Spring Framework 5.3.9 API)
This is the central interface in Spring's imperative transaction infrastructure. Applications can use this directly, but it is not primarily meant as an API: Typically, applications will work with either TransactionTemplate or declarative transaction demar
docs.spring.io
389p.
테스트와 서비스 추상화
JavaMail은 확장이 불가능하다. 팩토리 메서드를 통해서만 생성이 가능하고 그렇기에 상속이 불가능하다.
이렇게 되면 메일이 보내졌는지 test를 어찌할까? 매번 메일서버에 메일을 보내야 하나?
spring에서 해법을 제시해 주었다. 확장이 불가능하기에 한 번 감싸는 추상화 계층 MailSender를 제공해준다.
javaMailServiceImpl은 javaMail을 사용하는데 우리는 MailSender를 구현하고 사용하면 된다.
MailSender (Spring Framework 5.3.9 API)
This interface defines a strategy for sending simple mails. Can be implemented for a variety of mailing systems due to the simple requirements. For richer functionality like MIME messages, consider JavaMailSender. Allows for easy testing of clients, as it
docs.spring.io
'TIL' 카테고리의 다른 글
2021.07.20 기록장 (0) 2021.07.19 2021.07.19 기록장 (0) 2021.07.18 2021.07.17 기록장 (0) 2021.07.16 2021.07.16 기록장 (0) 2021.07.15 2021.07.15 기록장 (0) 2021.07.14