Skip to content

P1-3: 手動DIとSpring DIの混在を解消し composition root を明確化する#90

Merged
sasasin merged 9 commits into
masterfrom
sasasin/20260720/2246
Jul 20, 2026
Merged

P1-3: 手動DIとSpring DIの混在を解消し composition root を明確化する#90
sasasin merged 9 commits into
masterfrom
sasasin/20260720/2246

Conversation

@sasasin

@sasasin sasasin commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

P1-3 として、Spring-managed service 内で collaborator を
ew する手動 DI と、Spring constructor injection の混在を解消する。

  • feature 単位の composition root(@configuration(proxyBeanMethods = false))を追加し、長寿命 collaborator の組み立てを明示する
  • Clock / HttpClient / Playwright factory を infrastructure bean 化する
  • production constructor と test 専用 constructor を統一し、不要な @Autowired を削除する
  • Spring bean として存在する型を、別 bean 内部で二重生成しない(特に FeedDocumentService)
  • wiring test で bean 同一性・bean 数を検証し、手動 DI 再導入を architecture test で防ぐ

業務挙動、transaction、Playwright resource lifecycle / stop 順、CLI、DB、TOML semantics は変更しない。

Commits

  1. Clock / HttpClient infrastructure bean
  2. Readability parser bean と HtmlTextExtractor DI 統一
  3. Feed TOML composition root
  4. Canonicalization composition root
  5. Feed ingestion の重複 bean 解消
  6. ProbeDocumentFetcher inject と facade 依存整理
  7. Playwright browser graph の Spring singleton composition
  8. DI 規約 / 手動生成の回帰防止 test

Test plan

  • docker compose run --rm maven mvn -pl app -am clean verify(Spotless / Checkstyle / tests / JaCoCo)
  • feature wiring tests(bean count / identity / transaction proxy / SmartLifecycle)
  • unit tests が production constructor を使用
  • docker compose build app / docker compose up -d app で起動成功
  • app logs: PostgreSQL 接続・Flyway 適用・致命的例外なし
  • context 起動だけでは Playwright process が start しないこと

sasasin added 9 commits July 20, 2026 23:06
service constructor 内で Clock.systemDefaultZone() や HttpClient を生成していた
混在 DI を解消する。application lifetime の環境依存を composition root で
1 bean に固定し、HttpFetchService は production/test 同一 constructor に統一する。
…の DI を統一する

constructor 内 lambda で Readability4J を生成していた経路を、
ReadabilityParser / ReadabilityArticleParser に分離する。production/test で
同一 constructor を使い、短命の Readability4J オブジェクトは adapter 内に残す。
FeedTomlService が reader/writer/planner/executor と Clock を内部生成していた
構造を、feature 単位の FeedTomlConfiguration へ移す。@transactional 境界と
Counters の operation local 生成は維持し、test も同一 constructor を使う。
…ition へ移す

facade constructor が scanner/planner/executor/cleaner を new していた
composition root を ContentCanonicalizationConfiguration に移す。
accumulator や Session など invocation 単位の状態は bean 化しない。
FeedEntryImportService が @service の FeedDocumentService を別途 new し、
FeedEntryImporter も内部生成していた。managed instance を inject し、
Spring 上の bean と実行時 graph を一致させる。
FullTextProbeService が fetcher を new し、Playwright/properties を
不要に受け取っていた。fetcher だけが必要とする依存は ProbeConfiguration へ
閉じ込め、facade は実際に使う collaborator のみを受け取る。
…position にする

PR #89 で分割した runtime/navigator/driver/renderer/lifecycle の組み立てを
PlaywrightBrowserConfiguration へ移す。facade から buildCollaborators を除去し、
identity 共有と lazy start、SmartLifecycle は facade のみという設計を維持する。
対象 facade の single constructor / @Autowired 禁止と、
service 内での managed collaborator の new 再導入を source scan で固定する。
@sasasin
sasasin merged commit 1f384f2 into master Jul 20, 2026
3 checks passed
@sasasin
sasasin deleted the sasasin/20260720/2246 branch July 20, 2026 14:21
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