본문 바로가기
Spring 이해하기

Spring PSA(Portable Service Abstraction) 란 무엇인가?

by simplify-len 2020. 9. 1.

"잘 만든 인터페이스 하나가 열 클래스 부럽지 않다"

 

PSA = 잘 만든 인터페이스

Spring 에서 제공하는 대부분의 인터페이스는 PSA 입니다.

PSA가 적용된 코드라면 확장성이 좋고, 기술에 특화되어 있지 않는 코드를 의미합니다.

 

트랜잭션(Transaction)

대표적인 예시로 @Transactional > PlatformTransactionalManager 의 인터페이스가 중요하다.

PlatformTransactionalManager 의 구현체들이 바뀌더라도 그 PlatformTransactionalManager 의 코드는 변경되지 않습니다.

docs.spring.io/spring-framework/docs/current/spring-framework-reference/data-access.html#transaction-strategies

 

Data Access

The Data Access Object (DAO) support in Spring is aimed at making it easy to work with data access technologies (such as JDBC, Hibernate, or JPA) in a consistent way. This lets you switch between the aforementioned persistence technologies fairly easily, a

docs.spring.io

 예를 들어
JDBC를 사용하는 DatasourceTransactionManager,
JPA를 사용하는 JpaTransactionManager,
Hibernate를 사용하는 HibernateTransactionManager를

유연하게 바꿔서 사용할 수 있습니다.

즉, 기존 코드는 변경하지 않은 상태로, 트랜잭션을 실제로 처리하는 구현체를 사용 기술에 따라 바꿔 끼울 수 있는 것을 말합니다.

스프링 캐시 (CacheManager)

@EnableCaching 

애노테이션의 사용으로 캐시를 사용할 수 있습니다.

여기서는 JCache를 사용했지만, @EnableCaching 주석을 통해, EhCache 그 외 다른 캐시 매니저를 사용할 수 있게 해줍니다.

 

Spring Web MVC

 

Spring Web MVC에서 @ReqeustMapping 또한 PSA의 한 영역이라고 할 수 있다. Reactive 프로그래밍으로 변경시 간략하게 변경가능하다.

댓글