[week4] 문자열 기반 Bean 생성 및 Controller 어노테이션 추가#107
Open
scv74502 wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[feat] 문자열 기반 Bean 생성 및 Controller 어노테이션 추가
작업 목적
DIY IoC 컨테이너가
@Component뿐 아니라@Bean으로 표시되고 문자열로 빈 이름을 지정한 객체도 스캔하고, 구동 시 실제 객체를 생성할 수 있도 작업했습니다. 또한 컨트롤러 계층을 명확히 표현하기 위해@Controller어노테이션을 추가했습니다.(실제 구현은 TBD)추가 파일 목록 및 간단 설명
BeanScanner.java- 기존 @component 스캔에 @bean 어노테이션 스캔 코드 "scanBeansTypeAnnotatedWithName" 추가ApplicationContext.java- 기존 구현된 @component 스캔 실행후, 새로 작성한 @bean 어노테이션 스캔하여 등록.Bean.java- value() 값을 가지게 하고 없을 시 기본 값인 빈 값으로 두는 커스텀 어노테이션 추가Controller.java- @component 추가된 컨트롤러 어노테이션 추가, url 값을 가짐. TBD로 @controller에 Http Method별 동작 및 PutMapping, GetMapping 등 연관 어노테이션 구현할 예정. (@controller 하위에 있어야 함)구현 로직
@bean 어노테이션이 등록된 객체를 스캔하여 class 메타데이터를 획득
객체의 식별을 위해 이름을 문자열 파라미터로 사용
유일성 보장을 위해 객체명 통일 및 중복 제거
주요 변경 내용
@Bean기반 빈 후보 탐색 기능 추가@Controllerstereotype 어노테이션 추가검증
./gradlew test성공