Skip to content

Commit b665c67

Browse files
authored
CGLIB 클래스 다이어그램 + 설명
1 parent 479f753 commit b665c67

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# Java-Framework
22
Toy Framework
3+
4+
---
5+
V1(CGLIB AOP)
6+
![java-framework-aop-1](https://github.com/leeseojune53/Java-Framework/assets/61784568/c33838a2-a5dd-4802-aa2e-84f098c0d756)
7+
8+
1. RootApplication에서 정의한 annotationCallBackMap을 이용해서 AnnotationAOPProcessor을 생성한다. 형식은 아래와 같다.
9+
```java
10+
Map.of(Component.class,
11+
(obj, method, args, proxy, chain) -> {
12+
System.out.println("Class: " + obj.getClass().getName() + " Method : " + method.getName()
13+
+ " Component Annotated Method");
14+
chain.next(obj, method, args, proxy);
15+
return null;
16+
})
17+
```
18+
2. AnnotationAOPProcessor의 getMethodAopFunction()을 이용해서 Map에 들어가있는 Annotation을 사용한 클래스 / 메소드 정보를 받는다.
19+
이를 통해 ProxyPart를 생성한다.
20+
3. 생성한 ProxyPartList를 ClassMetadata의 getProxy에 넘겨준다.
21+
4. getProxy에서 ProxyPart에 있는 List<MultiCallback>으로 각 메소드별 MethodChain을 생성하고, 이를 CGLIB Enhancer의 Callback에 넣는다.
22+
5. 위에서 설정한 정보로 Proxy객체를 생성한다, 생성할 때 생성자에서 받는 Object가 있으면, 생성된 Service(Spring에서는 Application Context / IoC Container의 역할, 이하 Application Context)를 가지고 있는 Map<Class, Object>에 해당하는 ClassType이 있으면 주입해주고, 없으면 retryList에 add하고 넘어간다.
23+
6. ProxyPart List의 size와 Application Context에 있는 Object의 개수가 같지 않으면 5번 과정을 반복한다. 이는 DI를 받을 때 아직 Argument로 받을 ProxyObject가 생성되지 않았을 때를 위함이다.

0 commit comments

Comments
 (0)