nevzheng opened a new issue, #14153:
URL: https://github.com/apache/gravitino/issues/14153

   ### Describe the proposal
   
   **Goal.** Build the Gravitino server from an explicit, compile-time 
dependency graph (Dagger 2) instead of the `GravitinoEnv` service locator, then 
delete `GravitinoEnv`.
   
   **Why.** `GravitinoEnv` is a process-wide singleton that builds every server 
component and hands it to whoever calls `GravitinoEnv.getInstance()` (about 170 
calls in `src/main`, 400 in `src/test`).
   
   - **Hidden dependencies.** A constructor does not show what a class uses.
   - **Late wiring errors.** A missing component is a `null` found at runtime, 
not a compile error.
   - **Shared test state.** Tests write private fields of the singleton 
(`FieldUtils.writeField`, `mockStatic`), so they cannot run in parallel and 
fail depending on order (for example #14148).
   - **No extension points.** Code built on Gravitino changes behaviour by 
subclassing the env and dispatchers, so every upstream change to those classes 
conflicts.
   
   **Approach.** Migrate step by step around the existing facade (strangler 
fig); each step leaves `./gradlew check` green.
   
   - One root `GravitinoComponent` built from modules, with `@Public` and 
`@Internal` qualifiers for the two dispatcher chains and no-op bindings instead 
of `null`.
   - One explicit `Lifecycle`: start order written once, stop in reverse, 
rollback when a start fails.
   - Plugins get a plain Java context (`CatalogContext`, `AuxiliaryContext`, 
`AuthorizerContext`) instead of the whole server through a static.
   - Declared extension seams (`DispatcherDecorator`, `ManagedService`) replace 
subclassing.
   - HK2 (Jersey) stays at the edge and binds from the component.
   - A count ratchet in `check` that can only go down; `getInstance()` 
restricted to `@LegacyEnvAccess` callers until it reaches zero.
   
   **Not in scope.** The `*MetaService` storage layer; REST API or behaviour 
changes.
   
   **Design.** SPIP "Dependency injection with Dagger" (M0).
   
   ### Task list
   
   TASKLIST
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to