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 contexts
  • generic_application_context.dart β€” generic implementation of an application context
  • annotation_config_application_context.dart β€” context supporting annotation-based configuration
  • pod_post_processor_manager.dart β€” manages lifecycle post- processing of pods
  • pod_spec.dart β€” defines pod metadata and specifications

⚑ Event Infrastructure

Application event publishing and listener support:

  • application_event.dart β€” base class for application events
  • event_listener.dart β€” interface for event listeners
  • application_event_method_adapter.dart β€” adapts methods as event listeners
  • simple_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 codes
  • exit_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 abstraction
  • annotation_type_filter.dart β€” filter based on annotations
  • assignable_type_filter.dart β€” filter based on type assignability
  • regex_pattern_type_filter.dart β€” filter based on class name patterns

πŸ”„ Lifecycle Management

Supports bean/pod lifecycle and annotated lifecycle processing:

  • lifecycle.dart β€” core lifecycle definitions
  • application_annotated_lifecycle_processor.dart β€” processes annotated lifecycle hooks
  • lifecycle_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 required
  • helpers.dart β€” general-purpose context helpers
  • application_context.dart β€” interface for accessing the application context
  • application_type.dart β€” type metadata for applications
  • application_module.dart β€” defines modules within the application context
  • pod_registrar.dart β€” pod/component registration support
  • application_conversion_service.dart β€” handles type conversion within the application
  • application_environment.dart β€” access to environment configuration
  • pod_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 @OnApplicationStopping and @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 to ApplicationListeners.
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 DefaultListablePodFactory instance 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 PodFactory before 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.