AbstractPodFactory class abstract

Abstract base implementation of PodFactory that provides core functionality for pod creation, management, and lifecycle handling in the Jetleaf framework.

This class serves as the foundation for concrete pod factories, implementing the core algorithm for pod retrieval, scope management, dependency resolution, and lifecycle callbacks. It handles singleton caching, prototype creation, circular dependency detection, and PodProvider unwrapping.

Key Features:

  • Hierarchical pod provider support with parent-child relationships
  • Singleton and prototype scope management
  • Custom scope registration and handling
  • Pod post-processing with PodProcessor
  • Expression resolution for dynamic value injection
  • Lifecycle management with destruction callbacks
  • Circular dependency detection and prevention

Usage Example:

class MyPodFactory extends AbstractPodFactory {
  @override
  PodDefinition getDefinition(String name) {
    // Implementation to return pod definition by name
  }

  @override
  FutureOr<Object> doCreate(String name, RootPodDefinition definition, List<ArgumentValue>? args) {
    // Implementation to create pod instance
  }
}

final factory = MyPodFactory();
final pod = await factory.getPod<MyService>('myService');

See also:

Inheritance
Implemented types
Implementers

Constructors

AbstractPodFactory([PodFactory? parent])
Abstract base implementation of PodFactory that provides core functionality for pod creation, management, and lifecycle handling in the Jetleaf framework.

Properties

aliasCount → int
Returns the number of registered aliases for the current thread.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Returns true if no aliases are registered for the current thread.
no setterinherited
isNotEmpty → bool
Returns true if aliases are registered for the current thread.
no setterinherited
logger → Log
Logger instance for tracking pod factory operations, errors, and diagnostic information.
no setterinherited
POD_PROVIDER_CLASS → Class<PodProvider>
The PodProvider class reference for internal usage.
finalinherited
podProviderInstanceCache → Map<String, ObjectHolder<Object>>
Retrieves the PodProvider backing a pod.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
singletonCallbacks → Map<String, Consumer<Object>>
Map of singleton callbacks: pod name to Consumer.
finalinherited
threadLocalAliasMap → Map<String, String>
Gets the thread-local alias map for testing or advanced use cases.
no setterinherited
threadLocalAliasNames → List<String>
Gets the thread-local alias names list for testing or advanced use cases.
no setterinherited

Methods

addEmbeddedValueResolver(StringValueResolver valueResolver) → void
Appends a functional StringValueResolver algorithm step onto the active environment pipeline stack.
override
addPodProcessor(PodProcessor processor) → void
Registers a new pod-aware processor.
override
addSingleton(String name, {ObjectHolder<Object>? object, ObjectFactory<Object>? factory}) → Future<void>
Add the given singleton object to the singleton cache of this factory.
inherited
addSingletonCallback(String name, Class type, Consumer<Object> callback) → void
Add a callback to be executed when the singleton associated with name is initialized.
inherited
afterPrototypeCreation(String name) → void
Removes a prototype pod from the creation tracking after creation completes.
afterSingletonCreation(String name) → void
Callback after singleton creation.
inherited
allowAliasOverriding() → bool
Determine whether alias overriding is allowed.
inherited
beforePrototypeCreation(String name) → void
Marks a prototype pod as being created to detect circular dependencies.
beforeSingletonCreation(String name) → void
Callback before singleton creation.
inherited
cacheMergedPodDefinition(RootPodDefinition root, String name) → void
Caches a merged pod definition for a given pod name.
checkForAliasCircle(String name, String alias) → void
Check whether the given name points back to the given alias as an alias in the other direction already, catching a circular reference.
inherited
checkMergedPodDefinition(RootPodDefinition root, String name, Object? args) → void
Checks the merged pod definition for a given pod name.
cleanupAfterPodCreationFailure(String name) → void
Cleans up after a pod creation failure.
clear() → void
Clears all alias registrations for the current thread.
inherited
clearMergedPodDefinition(String name) → void
Clears the merged pod definition for a given pod name.
clearMetadataCache() → void
Clears the metadata cache for pods that are not eligible for caching.
clearSingletonCache() → void
Clear all cached singleton instances in this registry.
inherited
containsDefinition(String name) → bool
Check if pod definition exists locally.
containsLocalPod(String name) → Future<bool>
Checks if a pod with the given name is registered locally in this factory.
override
containsPod(String name) → Future<bool>
Checks if a pod with the given name is registered in the factory.
override
containsSingleton(String name) → bool
Returns true if this registry contains a pod with the given name.
inherited
containsSingletonObject(String name) → bool
Checks whether a singleton object has already been fully instantiated and stored.
inherited
containsType(Class type, [bool allowPodProviderInit = false]) → Future<bool>
Checks if the factory contains a pod of the specified type.
inherited
convertIfNecessary<T>(String name, Object pod, [Class? type, Class? source]) → T
Converts a pod instance to the required type if necessary.
copyConfigurationFrom(ConfigurablePodFactory other) → void
Copies configuration from another factory.
override
destroyDependentPods(String name) → Future<void>
Destroy all pods that depend on the specified pod.
inherited
destroyPod(String name, Object pod) → Future<void>
Destroy the given pod.
destroyScopedPod(String name) → void
Destroys all pods in the specified scope.
override
destroySingleton(String name) → Future<void>
Destroy the given pod. Delegates to destroyPod if a corresponding disposable pod instance is found.
inherited
destroySingletons() → Future<void>
Destroy all singleton pods in this registry.
inherited
doCreate(String name, RootPodDefinition definition, List<ArgumentValue>? args) → FutureOr<Object>
Abstract method for creating pod instances that must be implemented by subclasses.
doGet(String name, Class<Object>? type, List<ArgumentValue>? args, [bool prototypeInSingleton = false]) → Future<Object>
Main template method for pod retrieval that implements the core resolution algorithm.
doGetObject(Object instance, Class? type, String name, String transformed, PodDefinition? definition) → Future<Object>
Internal method to handle PodProvider unwrapping and instance retrieval.
doGetSingleton(String name, {bool allowEarlyReference = true, ObjectFactory<Object>? factory}) → Future<TypedInstance?>
Get the singleton instance for the given name.
inherited
evaluateExpression(Object? value, PodDefinition? podDefinition) → FutureOr<ObjectHolder<Object>?>
Evaluates a pod expression using the configured expression resolver.
get<T>(Class<T> type, [List<ArgumentValue>? args]) → Future<T>
Retrieves a pod instance by its type with optional arguments.
override
getAlias(String name) → String?
Retrieves the primary name associated with the given alias.
inherited
getAliases(String name) → List<String>
Retrieves all aliases registered for the given primary name.
override
getAliasNames() → List<String>
Returns all registered aliases as an unmodifiable view for the current thread.
inherited
getAllowCircularReferences() → bool
Retrieves the current circular reference setting.
inherited
getAllowDefinitionOverriding() → bool
Retrieves the current definition overriding setting.
inherited
getAllowRawInjection() → bool
Retrieves the current raw injection despite wrapping setting.
inherited
getApplicationStartup() → ApplicationStartup
Defines a contract for components that are aware of and can interact with an ApplicationStartup strategy.
override
getConversionService() → ConversionService
Retrieves the currently assigned ConversionService.
override
getDefinition(String name) → PodDefinition
Return the registered PodDefinition for the specified pod, allowing access to its property values and constructor argument value (which can be modified during pod factory post-processing).
getDefinitionByClass(Class type) → PodDefinition
Returns the pod definition for the specified class type.
getDependenciesForPod(String name) → List<String>
Return the names of all pods that the specified pod depends on, if any.
inherited
getDependentPods(String name) → List<String>
Return the names of all pods which depend on the specified pod, if any.
inherited
getLocalMergedPodDefinition(String name) → RootPodDefinition
Returns the locally cached merged pod definition if available and not stale.
getMergedPodDefinition(String name) → RootPodDefinition
Retrieves the merged pod definition for the specified pod name.
override
getNamedObject(String name, [List<ArgumentValue>? args]) → Future<Object>
Retrieves a pod as a generic Object by its name with optional arguments.
override
getNullableProviderObject(String name) → ObjectHolder<Object>?
Returns the cached raw object for a provider-managed pod, if present.
inherited
getObject(Class<Object> type, [List<ArgumentValue>? args]) → Future<Object>
Retrieves a pod as a generic Object by its type with optional arguments.
override
getPackageName() → String
Represents an abstraction for identifying the package that an object, resource, or service belongs to.
inherited
getParentFactory() → PodFactory?
Retrieves the parent factory in the hierarchy, if any.
override
getPod<T>(String name, [List<ArgumentValue>? args, Class<T>? type]) → Future<T>
Retrieves a pod instance by its name with optional arguments.
override
getPodClass(String podName) → Future<Class>
Retrieves the Class object for the specified pod name.
inherited
getPodDestructionProcessors() → List<PodDestructionProcessor>
Returns a copy of all registered destruction-aware pod processors.
getPodExpressionResolver() → PodExpressionResolver?
Retrieves the current expression resolver.
override
getPodInitializationProcessors() → List<PodInitializationProcessor>
Returns a copy of all registered initialization-aware pod processors.
getPodInstantiationProcessors() → List<PodInstantiationProcessor>
Returns a copy of all registered instantiation-aware pod processors.
getPodProcessorCount() → int
Gets the number of registered pod-aware processors.
override
getPodProcessors() → List<PodProcessor>
Retrieves all registered pod-aware processors.
override
getPodProvider(String podName, Object instance) → PodProvider
Retrieves the PodProvider backing a pod.
inherited
getPodProviderType(PodProvider provider, bool allowPodProviderInit) → Future<Class?>
getPodSmartInstantiationProcessors() → List<PodSmartInstantiationProcessor>
Returns a copy of all registered smart instantiation-aware pod processors.
getProvider<T>(Class<T> type, {String? podName, bool allowEagerInit = false}) → Future<ObjectProvider<T>>
Retrieves a provider for a pod, allowing for lazy or eager initialization.
inherited
getProviderObject(PodProvider provider, Class? type, String name, bool shouldPostProcess) → Future<ObjectHolder<Object>>
Retrieves the object managed by a PodProvider, applying caching and optional post-processing semantics.
inherited
getRegisteredScope(String scopeName) → PodScope?
Retrieves a registered scope by name.
override
getRegisteredScopeNames() → List<String>
Retrieves all registered scope names.
override
getSingleton(String name, {bool allowEarlyReference = true, ObjectFactory<Object>? factory}) → Future<Object?>
Retrieve the pod registered under name.
inherited
getSingletonCache(String name, [bool allowEarlyReference = true]) → Future<ObjectHolder<Object>?>
inherited
getSingletonClass(String name) → Class?
Return the class of the specified singleton pod, if any.
inherited
getSingletonCount() → int
Returns the total number of pods registered.
inherited
getSingletonNames() → List<String>
Returns a list of all pod names currently registered.
inherited
getUltimateNames() → List<String>
Returns all registered target names as an unmodifiable view for the current thread.
inherited
hasAlias(String name, String alias) → bool
Determine whether the given name has the given alias registered.
inherited
hasDependentPod(String name) → bool
Determine whether a dependent pod has been registered for the given name.
inherited
hasEmbeddedValueResolver() → bool
Diagnostic verification flag confirming whether at least one StringValueResolver processing step has been successfully registered to the runtime environment.
override
hasPodDestructionProcessors() → bool
Returns true if there are any destruction pod post-processors registered.
hasPodInitializationProcessors() → bool
Returns true if there are any initialization pod post-processors registered.
hasPodInstantiationProcessors() → bool
Returns true if there are any instantiation pod post-processors registered.
hasPodProcessors() → bool
Returns true if there are any pod post-processors registered.
hasPodSmartInstantiationProcessors() → bool
Returns true if there are any smart instantiation pod post-processors registered.
hasStartedCreatingPod() → bool
Checks if a pod has already been created.
isActuallyInCreation(String name) → bool
Check whether the specified singleton pod is actually in creation.
isAlias(String name) → bool
Checks whether the given name is registered as an alias.
inherited
isCachePodMetadata() → bool
Checks if pod metadata caching is enabled.
override
isCurrentlyCreatingPrototype(String name) → bool
Checks if a prototype pod is currently being created.
isCurrentlyCreatingSingleton(String name) → bool
Check whether the specified singleton pod is currently in creation.
inherited
isCurrentlyInCreation(String name) → bool
Check whether the specified singleton pod is currently in creation.
inherited
isDependent(String name, String dependentName) → bool
Determine whether the specified dependent pod has been registered as dependent on the given pod or on any of its transitive dependencies.
inherited
isNameInUse(String name) → Future<bool>
Checks if a pod name is already in use in this factory.
isPodEligibleForMetadataCaching(String name) → bool
Checks if a pod is eligible for metadata caching.
isPodProvider(String name, [RootPodDefinition? rpd]) → Future<bool>
Checks if the specified pod name refers to a pod provider.
override
isPrototype(String name) → Future<bool>
Checks if the specified pod is configured as a prototype.
override
isSingleton(String name) → Future<bool>
Checks if the specified pod is configured as a singleton.
override
isTypeMatch(String name, Class typeToMatch, [bool allowPodProviderInit = false]) → Future<bool>
Checks if the pod with the specified name matches the given type.
override
markPodAsCreated(String name) → void
Marks a pod as having been created at least once.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onSuppressedException(Exception ex) → void
Handle a suppressed exception.
inherited
originalPodName(String name) → String
Returns the original pod name by removing any prefix and suffix.
podProviderName(String name) → String
Gets the name of a pod with the appended pod provider prefix.
postProcessObjectFromPodProvider(ObjectHolder<Object> object, String name) → Future<ObjectHolder<Object>>
Retrieves the PodProvider backing a pod.
inherited
registerAlias(String name, String alias) → void
Registers an alias for an existing name in the registry.
inherited
registerContainedPod(String child, String parent) → void
Register a containment relationship between two pods.
inherited
registerDependentPod(String name, String dependentName) → void
Register a dependent pod for the given pod.
inherited
registerDisposableHandler(String name, Object pod, RootPodDefinition root) → Future<void>
Registers a disposable handler for a pod that requires destruction callbacks.
registerDisposablePod(String name, DisposablePod pod, [String? qualifiedName]) → void
Register a disposable pod for the given pod name.
inherited
registerScope(String scopeName, PodScope scope) → void
Registers a new scope with the given name.
override
registerSingleton(String name, Class type, {ObjectHolder<Object>? object, ObjectFactory<Object>? factory}) → Future<void>
Register a new pod under the given name.
inherited
removeAlias(String alias) → void
Removes an alias from the registry.
inherited
removeSingleton(String name) → void
Remove the pod associated with name.
inherited
removeSingletonIfCreated(String name) → bool
Removes a singleton pod if it has been created.
requiresDestruction(Object pod, RootPodDefinition root) → Future<bool>
Checks if a pod requires destruction.
resetPodProcessorCache() → void
Resets the pod processor cache, clearing all cached post-processors.
resolveAliases(String valueResolver(String name)) → void
Resolve all alias target names and aliases registered in this registry, applying the given StringValueResolver to them.
inherited
resolveDependency(DependencyDescriptor descriptor, [Set<String>? autowiredPods]) → Future<Object?>
Resolves a dependency based on the provided descriptor.
inherited
resolveEmbeddedValue(String? value) → FutureOr<String?>
Executes runtime evaluation across the pipeline stack to resolve embedded configuration placeholders.
override
setAllowCircularReferences(bool value) → void
Allows or disallows circular references between pods.
inherited
setAllowDefinitionOverriding(bool value) → void
Allows or disallows overriding of pod definitions.
inherited
setAllowRawInjection(bool value) → void
Allows or disallows raw injection despite wrapping.
inherited
setApplicationStartup(ApplicationStartup applicationStartup) → void
Defines a contract for components that are aware of and can interact with an ApplicationStartup strategy.
override
setCachePodMetadata(bool cacheMetadata) → void
Enables or disables caching of pod metadata for performance optimization.
override
setConversionService(ConversionService conversionService) → void
Sets an assigned ConversionService.
override
setCurrentlyInCreation(String name, bool inCreation) → void
Set the specified singleton pod as currently in creation.
inherited
setParentFactory(PodFactory? parent) → void
Sets the parent factory for this hierarchical factory.
override
setPodExpressionResolver(PodExpressionResolver? valueResolver) → void
Sets the expression resolver for resolving expressions in pod definitions.
override
targetName(String name) → String
Determine the target name, resolving aliases to their ultimate target.
inherited
toString() → String
A string representation of this object.
inherited
transformedPodName(String name) → String
Transforms a pod name by removing any prefix and suffix.

Operators

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

Constants

STARTUP_STEP_INSTANTIATE_POD → const String
Constant used to denote the startup step for pod instantiation in the abstract pod provider.