-
6. Spring에서 바이트 코드 조작 활용 예프로그래밍언어/Java(중급) 2020. 3. 26. 19:36
ComponentScan 어노테이션 프로그램분석
해당위치 부터 모든 패키지를 탐색하면서(하위포함) 모든 어노테이션을 찾아서 bin으로 등록한다 (@Service, @Repository, @Configuration...)
class 설명
- ASM사용 This implementation is based on Spring's - {@link org.springframework.core.type.classreading.MetadataReader MetadataReader} - facility, backed by an ASM {@link org.springframework.asm.ClassReader ClassReader}. - @author Mark Fisher - @author Juergen Hoeller - @author Ramnivas Laddad - @author Chris Beams - @author Stephane Nicoll - @since 2.5 - @see org.springframework.core.type.classreading.MetadataReaderFactory - @see org.springframework.core.type.AnnotationMetadata - @see ScannedGenericBeanDefinition
- Set addCandidateComponentsFromIndex method
simplemetaDataReader.cava
이 외 프로파일러, 최적화, 로깅, 프록시 등에서 많이 사용된다.
프로파일러 bytecode 조작발표 (New Relic)
https://www.youtube.com/watch?v=39kdr1mNZ_s
- ASM, ByteBody, Javaassist, CGlib
'프로그래밍언어 > Java(중급)' 카테고리의 다른 글
프록시 패턴 (0) 2020.04.24 5. 바이트코드 조작마술 (0) 2020.03.26 4. 바이트코드 조작 (0) 2020.03.26 3. 클래스 로더 (0) 2020.03.26 2. JVM 구조 (0) 2020.03.26