PodDefinition class abstract

Defines the blueprint of a pod (component) in the dependency injection system.

A PodDefinition encapsulates all metadata required to configure a component:

  • Its name and type (Class)
  • How dependencies are checked ({@macro dependency_check})
  • Its scope ({@macro scope_type})
  • Its design role ({@macro design_role})
  • Lifecycle behavior ({@macro lifecycle_design})
  • Dependency relationships (DependencyDesign)
  • Property values (MutablePropertyValues)
  • Method overrides (MethodOverrides)
  • Factory methods (FactoryMethodDesign)
  • Autowiring configuration ({@macro autowire_mode})
  • Constructor arguments (ConstructorArgumentValues)

This abstraction allows the system to define, manage, and wire components consistently.

Example

final pod = MyPodDefinition(
  name: "userService",
  type: Class<OtherService>(),
  scope: ScopeDescriptor(
    type: ScopeType.SINGLETON,
    isSingleton: true,
    isPrototype: false,
  ),
  design: DesignDescriptor(
    role: DesignRole.APPLICATION,
    isPrimary: true,
    isInfrastructure: false,
  ),
  lifecycle: LifecycleDesign(
    isLazy: true,
    initMethods: ["initialize"],
    destroyMethods: ["dispose"],
  ),
  dependsOn: [DependencyDescriptor("databaseService")],
  factoryMethod: FactoryMethodDescriptor("UserServicePod", "create"),
  autowireCandidate: AutowireCandidateDescriptor(
    autowireCandidate: true,
    autowireMode: AutowireMode.BY_TYPE,
  ),
);

print(pod.name); // "userService"
print(pod.scope.type); // ScopeType.SINGLETON
Mixed-in types
Implementers

Constructors

PodDefinition({String name = "", required Class type, PodInstanceSupplier? instanceSupplier, PodLifecycleInvoker? initMethodInvoker, PodLifecycleInvoker? destroyMethodInvoker, bool isPodProvider = false, String? description, DependencyCheck dependencyCheck = DependencyCheck.NONE, ScopeDesign? scope, DesignDescriptor? design, LifecycleDesign? lifecycle, List<DependencyDesign> dependsOn = const [], MutablePropertyValues? propertyValues, FactoryMethodDesign? factoryMethod, AutowireCandidateDescriptor? autowireCandidate, ConstructorArgumentValues? constructorArgumentValues})
Creates a PodDefinition with the provided configuration.

Properties

annotatedClasses → List<Class>
The list of annotation classes which the type of this pod definition is annotated with.
final
annotations → List<Annotation>
The complete list of annotations discovered on the class and its meta-annotations.
final
autowireCandidate ↔ AutowireCandidateDescriptor
Defines whether this pod is eligible for autowiring.
getter/setter pair
canProxy ↔ bool
Whether this pod is eligible for proxying.
getter/setter pair
dependencyCheck ↔ DependencyCheck
Defines the dependency validation strategy.
getter/setter pair
dependsOn ↔ List<DependencyDesign>
Other dependencies that this pod depends on.
getter/setter pair
description ↔ String?
A description of the pod.
getter/setter pair
design ↔ DesignDescriptor
Defines the design role of the pod.
getter/setter pair
destroyMethodInvoker ↔ PodLifecycleInvoker?
Direct AOT compiled destruction method invoker (e.g. for @PreDestroy).
getter/setter pair
executableArgumentValues ↔ ConstructorArgumentValues
Arguments to be passed to the pod’s constructor.
getter/setter pair
factoryMethod ↔ FactoryMethodDesign
The factory method used to create this pod.
getter/setter pair
hasBeforeInstantiationResolved ↔ bool
Whether this pod has been resolved before instantiation.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
initMethodInvoker ↔ PodLifecycleInvoker?
Direct AOT compiled initialization method invoker (e.g. for @PostConstruct).
getter/setter pair
instanceSupplier ↔ PodInstanceSupplier?
Direct AOT compiled instance supplier function. When present, the container invokes this supplier directly, bypassing reflection.
getter/setter pair
isPodProvider ↔ bool
Whether this pod is a provider of other pods.
getter/setter pair
lifecycle ↔ LifecycleDesign
Defines the lifecycle behavior of the pod.
getter/setter pair
name ↔ String
The unique name of the pod (component).
getter/setter pair
preferredConstructors → List<Constructor>
List of preferred constructors for autowiring.
final
propertyValues ↔ MutablePropertyValues
Mutable property values assigned to this pod.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scope ↔ ScopeDesign
Defines the scope of the pod.
getter/setter pair
type ↔ Class
The Class type that this pod represents.
getter/setter pair

Methods

clone() → PodDefinition
Creates and returns a deep clone of this pod definition.
equalizedProperties() → List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
override
getAnnotation<A>() → A?
Returns the annotation of type A, if present.
getAnnotations<A>() → List<A>
Returns a list of annotations of type A.
hasAnnotation<A>() → bool
Returns true if this definition has an annotation of type A.
hasConstructorArgumentValues() → bool
Returns whether this pod definition contains any constructor argument values.
hasPreferredConstructors() → bool
Returns whether this pod definition has any preferred constructors.
hasPropertyValues() → bool
Returns whether this pod definition contains any property values.
isAbstractAndNoFactory() → bool
Returns true if this definition is non-instantiable.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
toStringOptions() → ToStringOptions
override

Operators

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