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
-
Registrar Registration
- A
PodRegistraris registered with the registry usingregister. - Its
registermethod declares one or more pods.
- A
-
Direct Pod Registration
- Use
registerPod<T>to register a pod of typeT. - Customize its metadata via the optional
customizer. - Optionally assign a unique
name.
- Use
-
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.
-
Dependency Injection
- Once pods are registered, other pods can depend on them.
- The registry ensures correct instantiation order respecting
Orderedregistrars.
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
Orderedinterfaces 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
registrarthat declares pods into this registry. -
registerPod<
T> (Class< T> podClass, {Consumer<Spec< ? customizer, String? name}) → Future<T> >void> -
Registers a pod of type
Tin the registry. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited