728x90
반응형
프록시란?
- 프록시의 사전 의미는 대리자 이다.
- 실제 객체를 직접 호출 하는 방식이 아닌 대리자를 통해 호출 하는 방식이다.
- 프록시 패턴과는 다르다.
좀 더 자세히 분석해보자
- 프록시 객체는 실제 호출할 객체를 참조하고있다.
- 즉 감싸고 있다고 생각하면 된다.
어떤 이점이 있을까?
- 참조를 할수 있다는 것은 다른 객체도 참조를 할수 있다는 말이다.
- 그렇다면 프록시 안에 공통적인 로직을 넣는다면? 어디든 적용할수 있다는 말이다. - 아래와 같이 시간측정 공통로직을 넣을수 있다.
- 이렇게 부가적, 공통적, 관점들을 모듈로 만들수 있다.
- 이게 바로 AOP 이다.
스프링에서 제공하는 프록시 종류
CGLIB Proxy
- 클래스 기반
- extends 구현
JDK Dynamic Proxy
- 인터페이스 기반
- implements 구현
- AOP 에서 기본적으로 사용하는 프록시다.
다음으로
CGLIB 동작방식, JDK 동작 방식을 정리해볼 예정이다.
참고:
https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#aop-introduction
Core Technologies
In the preceding scenario, using @Autowired works well and provides the desired modularity, but determining exactly where the autowired bean definitions are declared is still somewhat ambiguous. For example, as a developer looking at ServiceConfig, how do
docs.spring.io
728x90
반응형
'Spring > Spring 고급' 카테고리의 다른 글
[Spring] Spring AOP 개념 (0) | 2023.06.27 |
---|---|
[Spring] AOP 개념 (0) | 2023.06.15 |
[Spring] CGLIB (0) | 2023.04.18 |
[Spring] JDK Proxy (0) | 2023.04.18 |
댓글