ddi
Made in the European Union

Scopes

Lifecycle management in DDI — the built-in JVMSingletonInjectionScope and how to write your own scope.

Work in progress. This page is the canonical reference for the scope API. Full content lands alongside the Writing a custom scope tutorial (see the roadmap).

The built-in scope

Out of the box DDI ships a single scope:

  • JVMSingletonInjectionScope — one instance per class, for the lifetime of the JVM. The simplest possible model, and a good default for stateless services.

Register a class with the singleton scope explicitly:

DI.registerClassForScope(MyService.class, "jvm-singleton");

Writing your own scope

The scope interface (InjectionScope) lets you implement other lifetimes — per-request, per-tenant, per-session, per-virtual-thread. The mechanism is intentionally small. Documentation and a worked example are on the roadmap.

See also