|
| 1 | +# `scope` documentation |
| 2 | + |
| 3 | +`scope` is a small JVM library that treats **scopes as first-class runtime |
| 4 | +objects**. A scope is a lexical block you can build, nest, shadow and dispose |
| 5 | +_while the program runs_ — and a thin dependency injection layer wires objects |
| 6 | +together by walking the scope graph. |
| 7 | + |
| 8 | +If you have five minutes, read **[Mental model](mental-model.md)** first: every |
| 9 | +other page builds on it. |
| 10 | + |
| 11 | +```java |
| 12 | +import be.theking90000.scope.Scope; |
| 13 | + |
| 14 | +record RootScope() {} |
| 15 | +record Config(String value) {} |
| 16 | +record Service(Config config) {} |
| 17 | + |
| 18 | +Scope<RootScope> root = new Scope<>(new RootScope()); |
| 19 | +root.seed(Config.class, new Config("prod")); |
| 20 | + |
| 21 | +Service service = root.get(Service.class); // built and cached as a scope singleton |
| 22 | +``` |
| 23 | + |
| 24 | +## Table of contents |
| 25 | + |
| 26 | +| Page | What it covers | |
| 27 | +| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | |
| 28 | +| [Mental model](mental-model.md) | Scopes as language blocks, the lifetime model, the visibility/ownership asymmetry. | |
| 29 | +| [Getting started](getting-started.md) | First example, step by step, and how `get()` resolves. | |
| 30 | +| [Injection](injection.md) | Constructor injection rules, supported parameter shapes, lazy `Provider<T>`, cycles. | |
| 31 | +| [Qualifiers & collections](qualifiers-and-collections.md) | `Key<T>`, `@Named`, and injecting all providers of a type. | |
| 32 | +| [Scopes & lifecycle](scopes-and-lifecycle.md) | Parents, shadowing, ownership vs visibility, `close()`, `@PostConstruct` / `@PreDestroy` / `AutoCloseable`. | |
| 33 | +| [Multi-parent scopes](multi-parent.md) | DAG scopes, ambiguity, `NEAREST` vs `DEEP` resolution. | |
| 34 | +| [Extension hooks](extension-hooks.md) | `OnCreatedHook`, `BeanCreated`, `Disposer`, hook shadowing, batch initialization. | |
| 35 | +| [API reference](api-reference.md) | Every public member of `Scope`, `Key`, `Provider`, `MultiProvider`. | |
| 36 | +| [Exceptions](exceptions.md) | The `DiException` hierarchy and when each is thrown. | |
| 37 | +| [Recipes](recipes.md) | Common patterns and a best-practices checklist. | |
| 38 | + |
| 39 | +## Installation |
| 40 | + |
| 41 | +See the [main README](https://github.com/theking90000/scope#quick-start) for |
| 42 | +Gradle / Maven coordinates. The library targets **Java 21**. The base package is: |
| 43 | + |
| 44 | +```java |
| 45 | +package be.theking90000.scope; |
| 46 | +``` |
| 47 | + |
| 48 | +## JavaDoc |
| 49 | + |
| 50 | +Every public type and method ships with thorough JavaDoc — it is the most precise |
| 51 | +reference for exact signatures, edge cases and behavior. Browse it online: |
| 52 | + |
| 53 | +**<https://theking90000.github.io/scope/javadoc/>** |
| 54 | + |
| 55 | +_(Published from the `javadoc` jar produced by the build; if the hosted site is not |
| 56 | +up yet, the same JavaDoc is attached to every release on GitHub Packages.)_ |
| 57 | + |
| 58 | +## Other references |
| 59 | + |
| 60 | +- [Main README](https://github.com/theking90000/scope) — the project landing page |
| 61 | + (pitch and comparison). |
| 62 | +- [`scope/README.md`](https://github.com/theking90000/scope/blob/main/scope/README.md) |
| 63 | + — the original, in-depth **French** reference for the same module. |
0 commit comments