Skip to content

feat: EgovPropertyService 를 Spring Environment 에 편입하는 EgovServicePropertySource 추가 - #421

Open
comghost wants to merge 1 commit into
eGovFramework:mainfrom
comghost:feat/fdl-property-service-property-source
Open

feat: EgovPropertyService 를 Spring Environment 에 편입하는 EgovServicePropertySource 추가#421
comghost wants to merge 1 commit into
eGovFramework:mainfrom
comghost:feat/fdl-property-service-property-source

Conversation

@comghost

Copy link
Copy Markdown

수정 사유 Reason for modification

  • 버그수정 Bug fixes
  • 기능개선 Enhancements
  • 기능추가 Adding features
  • 기타 Others

수정된 소스 내용 Modified source

배경

EgovPropertyService 로 읽는 프로퍼티는 Spring Environment 와 연결되어 있지 않습니다. 그래서 같은 값을 @Value
플레이스홀더에서 쓰려면 properties 를 두 곳에 두거나, 서비스를 주입받아 getString() 을 직접 호출해야 합니다.
DB 프로퍼티(DbPropertySourceDelegate)는 Environment 에 편입되는데 파일 기반 서비스 값만 빠져 있는 셈입니다.

추가한 것

EgovServicePropertySourceEnumerablePropertySource<EgovPropertyService> 구현

  • 조회는 EgovPropertyService.getString(name, null) 로 위임합니다. 없는 키는 예외 대신 null 을 돌려줘 다음
    PropertySource 로 넘어가게 합니다(PropertySource 계약).
  • 키 목록은 getKeys() 로 만들어 열거형 PropertySource 로 동작합니다.
  • Environment 의 PropertySources 에 등록하면 @Value("${Globals.DbType}")resolvePlaceholders 에서 서비스 값을
    쓸 수 있고, Environment 의 타입 변환(getProperty(name, Integer.class))도 그대로 적용됩니다.
ConfigurableEnvironment env = context.getEnvironment();
env.getPropertySources().addLast(new EgovServicePropertySource("egovPropertyService", egovPropertyService));

설계 메모

  • 기존 클래스는 수정하지 않았습니다. 신규 파일만 추가하며 외부 의존도 없습니다.
  • 같은 서비스 인스턴스를 위임 조회하므로 refreshPropertyFiles() 로 다시 읽은 값이 재기동 없이 보입니다. 단 @Value
    주입된 필드는 주입 시점 값이 고정되며, 갱신 반영은 Environment 를 직접 조회할 때 기준입니다(javadoc 에 명시).
  • 등록 위치(addLast/addFirst)는 사업이 정합니다. 시스템 프로퍼티나 다른 소스와 키가 겹칠 때의 우선순위를 그 순서로 조정할 수 있습니다.

JUnit 테스트 JUnit tests

  • JUnit 테스트 JUnit tests
  • 수동 테스트 Manual testing

EgovServicePropertySourceTest 4건 신규, fdl.property 모듈 전건 통과.

환경 기본 로케일(Locale) 모듈 실행 건수 결과
Windows ko_KR 18 Tests run: 18, Failures: 0, Errors: 0, Skipped: 0
Linux (Ubuntu 22.04 / OpenJDK 17) C.UTF-8 18 Tests run: 18, Failures: 0, Errors: 0, Skipped: 0
구분 건수 내용
PropertySource 계약 1 서비스 값 조회, 없는 키는 null, 키 목록 열거
Environment 편입 2 getProperty·resolvePlaceholders 해석과 기본값 구문 · Integer 타입 변환
갱신 반영 1 refreshPropertyFiles() 뒤 바뀐 값이 보이고 사라진 키는 보이지 않는다

수동 확인: 현재 main(cc2b332) 위에서 fdl.property 모듈 빌드·테스트가 통과함을 Windows 와 Linux 에서 확인했습니다.

테스트 브라우저 Test Browser

  • Chrome
  • Firefox
  • Edge
  • Safari
  • Opera
  • Internet Explorer
  • 기타 Others

해당 없음 — 라이브러리 클래스 추가입니다.

테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video

해당 없음 — 위 JUnit 테스트 결과로 갈음합니다.


base: eGovFramework:main @ cc2b332 (2026-09-10 fetch 기준, #366~#379 머지 후) · 단일 커밋

…ertySource 추가

EgovPropertyService 로 읽는 프로퍼티는 Spring Environment 와 연결되어 있지 않아
@value 나 플레이스홀더에서 보이지 않는다. 같은 값을 두 곳에서 따로 관리하거나,
서비스를 주입받아 직접 getString() 을 호출해야 한다.

- EgovServicePropertySource: EnumerablePropertySource 구현. 조회는
  EgovPropertyService.getString(name, null) 로 위임해 없는 키는 null 을 돌려주고
  다음 PropertySource 로 넘어가게 한다. 키 목록은 getKeys() 로 만든다
- Environment 의 PropertySources 에 등록하면 @value("${...}") 와
  resolvePlaceholders 에서 EgovPropertyService 값을 쓸 수 있다. 같은 서비스
  인스턴스를 위임 조회하므로 refreshPropertyFiles() 로 다시 읽은 값이 그대로
  보인다

EgovServicePropertySourceTest 4건 추가 — 조회와 미존재 키의 null, 키 목록,
Environment 편입 후 플레이스홀더 해석, refresh 반영, 타입 변환.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant