Spec<T> constructor
Spec<T> ({
- required Class type,
A Jetleaf definition describing how a pod should be instantiated, configured, and managed inside the container.
A Spec
acts as a fluent builder for pod registration. It allows chaining
configuration methods for scope, lifecycle, dependencies, naming, and
autowiring.
When to use
Use a Spec
whenever you register a pod inside a Registry
. It provides
a structured, declarative way to define pod behaviors and their container
interactions.
Example
registry.registerPod(MyService.classType, customizer: (spec) {
spec
.namedAs('myService')
.withScope(ScopeType.singleton)
.describedAs('Provides business logic services')
.suppliedBy((ctx) => MyService(ctx.get(Dependency.classType)));
});
Fluent Chaining
All methods return the same Spec<T>
instance, allowing chained invocations.
Implementation
Spec({required super.type});