PodRegistry class abstract interface

A contract in JetLeaf that provides methods for managing pods in the container.

The PodRegistry allows registration of pod definitions either directly or through `PodRegistrar`.

Workflow

  1. Registrar Registration

    • A PodRegistrar is registered with the registry using register.
    • Its register method declares one or more pods.
  2. Direct Pod Registration

    • Use registerPod<T> to register a pod of type T.
    • Customize its metadata via the optional customizer.
    • Optionally assign a unique name.
  3. Pod Resolution

    • The pod registry maintains a mapping of pod names and types to instances.
    • Pods are initialized based on scope and lifecycle rules:
      • Singleton: a single shared instance.
      • Prototype: a new instance per request.
      • Lazy: created only when first requested.
  4. Dependency Injection

    • Once pods are registered, other pods can depend on them.
    • The registry ensures correct instantiation order respecting Ordered registrars.

Example

final registry = DefaultPodRegistry();

// Register a registrar
registry.register(MyServiceRegistrar());

// Direct pod registration
registry.registerPod(Class<MyService>(), customizer: (spec) {
  spec.namedAs('myService').withScope(ScopeType.singleton);
});

// Retrieve a pod
final myService = registry.getPod<MyService>('myService');

Notes

  • Pod registration should be performed at startup before any dependent pods are used.
  • Registrars and pods can be conditionally registered based on runtime properties.
  • The registry supports ordering via Ordered interfaces to guarantee deterministic initialization.
Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(PodRegistrar registrar) Future<void>
Registers a registrar that declares pods into this registry.
registerPod<T>(Class<T> podClass, {Consumer<Spec<T>>? customizer, String? name}) Future<void>
Registers a pod of type T in the registry.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited