issue111: Factory初期化フロー制御をServlet init-param方式に統一#115
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #111 regarding incompatible factory loading order behavior introduced in version 1.3.0-a1. The implementation provides a servlet init-param mechanism to control factory initialization loading order, maintaining backward compatibility by default.
Changes:
- Adds servlet init-param support (
enableBackwardOrderLoading) to control factory/provider loading order - Default behavior (forward order): Built-in → META-INF → WEB-INF, with later sources overwriting earlier ones (backward compatible)
- New behavior (backward order, when enabled): WEB-INF → META-INF → Built-in, using first valid source found
- Refactors factory loading logic in both FactoryFactoryImpl and ProviderFactoryImpl with improved separation of concerns
- Adds comprehensive test coverage (9 new tests) for the new functionality
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src-api/org/seasar/mayaa/FactoryFactory.java | Adds static fields and methods to control backward/forward loading order via init-param override |
| src-impl/org/seasar/mayaa/impl/MayaaServlet.java | Implements applyInitParams() method to read and apply enableBackwardOrderLoading parameter |
| src-impl/org/seasar/mayaa/impl/FactoryFactoryImpl.java | Refactors factory loading into separate methods: collectSources(), loadFactoryBackward(), loadFactoryForward(), and adds validation |
| src-impl/org/seasar/mayaa/impl/provider/ProviderFactoryImpl.java | Similar refactoring as FactoryFactoryImpl for service provider loading |
| src/test/java/org/seasar/mayaa/impl/FactoryFactoryImplTest.java | Adds test methods for override mechanism and ensures proper cleanup |
| src/test/java/org/seasar/mayaa/impl/provider/LoadOrderTest.java | New comprehensive test class with 9 test cases covering forward/backward loading scenarios |
| src/test/java/org/seasar/mayaa/impl/cycle/web/MockServiceCycleForLoadOrderTest.java | Test marker class to verify which configuration file was loaded |
| src/test/java/org/seasar/mayaa/impl/provider/WEB-INF/org.seasar.mayaa.cycle.CycleFactory | Test resource file for load order verification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
概要
#111 の対応として対Factory初期化フロー制御をServlet init-param方式で実装してデフォルトでは互換動作としました。
enableBackwardOrderLoadingがtrue指定されたときは新しい読み込み順(WEB-INF → META-INF → Built-in の順)で探索し、最初に見つかった有効なものが採用されます。未指定あるいはfalseが指定された場合は、これまでと同じ動き(Built-in → META-INF → WEB-INF の順で探索し、全てを読み込みながら後のものが前のものを上書き)となります。変更内容
1. FactoryFactory.java
Servlet init-param対応の制御メソッドを追加:
isDisabledBackwardOrderLoading(): 読み込み順序の状態確認setEnableBackwardOrderLoadingOverride(): init-param値の反映2. MayaaServlet.java
applyInitParams()メソッドで Servlet init-param を読み込みenableBackwardOrderLoadingパラメータをサポート3. FactoryFactoryImpl.java
getFactory()メソッドをリファクタリング:collectSources(): ソース探索ロジック分離loadFactoryBackward(): 逆順読み込みloadFactoryForward(): 順順読み込み4. ProviderFactoryImpl.java
FactoryFactoryImpl と同様のリファクタリング
5. テスト整備
6. テスト用リソース
テスト結果
✅ 487/487 全テスト成功(478既存 + 9新規)