Skip to content

Support local scopes on injected dependencies - #77

Merged
GedMarc merged 3 commits into
masterfrom
feature/guice-local-dependency-scopes
Oct 3, 2026
Merged

GedMarc merged 3 commits into
masterfrom
feature/guice-local-dependency-scopes

Conversation

@GedMarc

@GedMarc GedMarc commented Sep 30, 2026

Copy link
Copy Markdown
Member

Consumers can now apply a scope to an injectable constructor parameter or field without changing the dependency's binding for other consumers. This ports the core behavior proposed in google/guice#1949 to GuicedEE's shaded Guice source.

The scoped provider is shared by the same consumer, scope annotation, and dependency key. Other consumers remain isolated, and a locally scoped dependency wraps any scope already configured on its binding. Scope recognition and binding continue through the existing ScopeAnnotationProvider and BindScopeProvider SPIs.

The README documents local scope semantics and walks through registering @RequestScoped, including a minimal synchronous scope implementation, service registration, and request entry/exit. No web runtime dependency is added to guice-core.

Validation: mvn -q test in Google/guice-core on this branch (8 tests, 0 failures).

Copilot AI balanced review requested due to automatic review settings October 3, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Core cache-separation and scope-wrapping guarantees are not conclusively tested.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds validation for consumer-local dependency scopes and test-time SPI registration.

Changes:

  • Tests constructor, field, custom, lifecycle, and error semantics.
  • Registers test scope SPIs through ServiceLoader.
File Description
LocalScopeTest.java Exercises local-scope behavior.
...ScopeAnnotationProvider Registers the test marker provider.
...BindScopeProvider Registers the test scope binder.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Google/guice-core/src/test/java/com/google/inject/LocalScopeTest.java Outdated
@GedMarc
GedMarc merged commit 4575908 into master Oct 3, 2026
3 checks passed
@GedMarc
GedMarc deleted the feature/guice-local-dependency-scopes branch October 3, 2026 21:56
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.

2 participants