context library
π± JetLeaf Core Context
This library provides the core infrastructure for application context management in JetLeaf, including:
- Application context abstractions and implementations
- Lifecycle management
- Event publishing and listener support
- Pod (dependency) registration and post-processing
- Exit code handling for graceful shutdown
- Type filtering for conditional component registration
It serves as the foundation for dependency injection, component lifecycle, and event-driven communication within JetLeaf applications.
π Core Components
π Application Context
Core abstractions and implementations of application contexts:
abstract_application_context.dartβ base abstract class for application contextsgeneric_application_context.dartβ generic implementation of an application contextannotation_config_application_context.dartβ context supporting annotation-based configurationpod_post_processor_manager.dartβ manages lifecycle post- processing of podspod_spec.dartβ defines pod metadata and specifications
β‘ Event Infrastructure
Application event publishing and listener support:
application_event.dartβ base class for application eventsevent_listener.dartβ interface for event listenersapplication_event_method_adapter.dartβ adapts methods as event listenerssimple_application_event_bus.dartβ simple event bus implementation for publishing and dispatching events
π Exit Code Management
Tools for handling exit codes during application shutdown:
exit_code.dartβ represents exit codesexit_code_generator.dartβ generates exit codes based on application state or events
π Type Filtering
Conditional component registration using type filters:
type_filter.dartβ base type filter abstractionannotation_type_filter.dartβ filter based on annotationsassignable_type_filter.dartβ filter based on type assignabilityregex_pattern_type_filter.dartβ filter based on class name patterns
π Lifecycle Management
Supports bean/pod lifecycle and annotated lifecycle processing:
lifecycle.dartβ core lifecycle definitionsapplication_annotated_lifecycle_processor.dartβ processes annotated lifecycle hookslifecycle_processor.dartβ interface for lifecycle processors
β Application Base Utilities
Core utilities and interfaces for application context management:
keep_alive.dartβ ensures pods remain active as requiredhelpers.dartβ general-purpose context helpersapplication_context.dartβ interface for accessing the application contextapplication_type.dartβ type metadata for applicationsapplication_module.dartβ defines modules within the application contextpod_registrar.dartβ pod/component registration supportapplication_conversion_service.dartβ handles type conversion within the applicationapplication_environment.dartβ access to environment configurationpod_factory_customizer.dartβ customize pod factories during initialization
π― Intended Usage
Import this library to manage application context and dependency injection in JetLeaf projects:
import 'package:jetleaf_core/context.dart';
final context = GenericApplicationContext();
context.registerPod<MyService>();
Provides the foundation for dependency injection, lifecycle management, events, and environment awareness in JetLeaf.
Β© 2025 Hapnium & JetLeaf Contributors
Classes
- AbstractApplicationContext
- The base implementation of a configurable Jetleaf Application Context.
- AnnotationConfigApplicationContext
- ApplicationContext implementation that supports annotation-based configuration.
- AnnotationConfigRegistry
- Annotation-Based Configuration Registry
- AnnotationTypeFilter
- A TypeFilter that matches classes based on the presence of specific annotations.
- ApplicationAnnotatedLifecycleProcessor
-
Processor for application lifecycle annotations that discovers and invokes
methods annotated with
@OnApplicationStoppingand@OnApplicationStopped. - ApplicationContext
- The central interface for a JetLeaf application context.
- ApplicationContextEvent
- A base class for all events that are published within the context of an ApplicationContext.
-
ApplicationContextInitializer<
T extends ConfigurableApplicationContext> - Strategy interface for initializing an ApplicationContext before it is refreshed.
- ApplicationConversionService
- A JetLeaf-managed, application-wide conversion service responsible for managing and coordinating all registered type converters.
- ApplicationEnvironment
- A concrete environment for standard JetLeaf applications.
- ApplicationEvent
- A base class for application-specific events within the JetLeaf framework.
- ApplicationEventBus
-
Defines the contract for an event multicaster that manages the registration,
removal, and dispatching of
ApplicationEvents toApplicationListeners. -
ApplicationEventListener<
E extends ApplicationEvent> - A listener for a specific type of ApplicationEvent.
- ApplicationEventMethodAdapter
- An adapter class in Jetleaf that bridges ApplicationEvents with listener methods.
- ApplicationModule
- An interface in Jetleaf that defines a configurable application module.
- AssignableTypeFilter
- A TypeFilter that matches classes assignable to a specific target type.
- CompletedInitializationEvent
- Event published when the ApplicationContext has completed its initialization phase.
- ConfigurableApplicationContext
- A specialized ApplicationContext that allows for full configuration and lifecycle management.
- ContextClosedEvent
- Event published when an ApplicationContext is closed.
- ContextFailedEvent
- Event published when the ApplicationContext fails to start or refresh.
- ContextReadyEvent
- Event published when the ApplicationContext is ready.
- ContextRestartedEvent
- Event published when the ApplicationContext is restarted.
- ContextSetupEvent
- Event published when the ApplicationContext is refreshed or initialized.
- ContextStartedEvent
- Event published when the ApplicationContext is started or restarted.
- ContextStoppedEvent
- Event published when the ApplicationContext is explicitly stopped.
- ConversionServiceConfigurer
-
A JetLeaf extension interface for programmatically configuring
type conversion within the applicationβs
ConversionService. - EventObject
- A base class for all framework-level events.
- ExitCodeEvent
- An ApplicationEvent that signals the application should exit with a specific exit code.
- ExitCodeExceptionHandler
- A strategy interface for mapping a specific Exception to a process exit code.
- ExitCodeGenerator
- Strategy interface for determining the exit code returned from a JetLeaf application or a process.
- ExitCodeGenerators
- A container and manager for multiple ExitCodeGenerator instances.
- GenericApplicationContext
-
Generic ApplicationContext implementation that holds a single internal
DefaultListablePodFactoryinstance and does not assume a specific pod definition format. - ImportClass
- π« Represents a logical import entry with qualification and enablement metadata.
- ImportSelector
- π« A strategy interface for selecting which imports should be applied.
- KeepAlive
- A lifecycle-aware component that keeps the Dart VM alive as long as the ApplicationContext is running.
- Lifecycle
- A common interface defining methods for start/stop lifecycle control.
- LifecycleProcessor
- Defines a contract for components that participate in the application lifecycle.
- Phased
- Interface for objects that may participate in a phased process such as lifecycle management.
-
PodFactoryCustomizer<
T extends ConfigurablePodFactory> -
A lifecycle hook interface for customizing the
PodFactorybefore it is fully initialized or configured within the JetLeaf framework. - PodFactoryPostProcessor
- Factory hook that allows for custom modification of an application context's pod definitions, adapting the pod property values of the context's underlying pod factory.
- PodPostProcessorManager
- Manager for coordinating pod factory post-processors and pod-aware processors with proper ordering and lifecycle management.
- PodRegistrar
- A contract in JetLeaf for components that can register pods into the applicationβs dependency container.
- PodRegistry
- A contract in JetLeaf that provides methods for managing pods in the container.
-
PodSpec<
T> -
A concrete implementation of the
`Spec`API in Jetleaf. - PodSpecContext
-
An implementation of
`SpecContext`in Jetleaf that resolves dependencies during pod creation and supplier evaluation. - RegexPatternTypeFilter
- A TypeFilter that matches classes based on regular expression patterns against class names.
- SimpleApplicationEventBus
- A straightforward implementation of ApplicationEventBus that manages application event listeners.
- SmartLifecycle
- An extension of the Lifecycle interface for those objects that require to be started upon ApplicationContext refresh and/or shutdown in a particular order.
-
Spec<
T> - A Jetleaf definition describing how a pod should be instantiated, configured, and managed inside the container.
- SpecContext
- A context object in Jetleaf provided to suppliers and pod definitions for resolving dependencies at runtime.
- TypeFilter
- Abstract base class for type filtering strategies used in component scanning.
Enums
- ApplicationType
- Enumeration of types of applications that can be run in a JetLeaf environment.