annotation library
π·οΈ Jetleaf Core Annotations Subsystem
This library provides the complete declarative metadata annotation suite for Jetleaf applications. Annotations enable declarative configuration, dependency injection, lifecycle interception, conditional component activation, and architectural stereotyping without runtime boilerplate.
π¦ Annotation Hierarchy
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Jetleaf Annotations β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ Stereotypes: @Component, @Service, @Repository β
β β’ Configuration: @Configuration, @Pod, @Import β
β β’ Injection: @Autowired, @Value, @Qualifier, @Primaryβ
β β’ Lifecycle: @PostConstruct, @PreDestroy, @Lazy β
β β’ Conditionals: @Conditional, @Profile, @Conditional...β
β β’ Order & Scopes: @Order, @Scope β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π¦ Exports Categorization
ποΈ Stereotypes & Components
- Component β marks a target Dart class as an auto-detectable managed pod.
- Service β specializes Component for business service layers.
- Repository β specializes Component for data access and storage layers.
Controllerβ specializes Component for web and presentation routing layers.
βοΈ Configuration & Module Definition
- Configuration β marks a class containing pod definitions annotated with
@Pod. - Pod β marks factory methods inside a
@Configurationclass as pod producers.
π Dependency Injection & Wiring
- Autowired β marks constructors, fields, or setter methods for automatic dependency resolution.
- Value β injects property values from active environment sources (
@Value('\${server.port:8080}')). - Qualifier β specifies the unique name or qualifier when multiple candidate pods exist.
- Primary β designates a pod definition as the primary candidate when multiple matches exist.
π Lifecycle & Ordering
- PostConstruct β marks a method to execute immediately after dependency injection completes.
- PreDestroy β marks a method to execute before singleton disposal during context shutdown.
- Order β sets priority or execution order for pods, interceptors, and listeners.
- Lazy β defers singleton instantiation until first requested.
π Conditionals & Profiles
- Conditional β base annotation associating a custom Condition predicate.
- Profile β restricts component registration to specific active environment profiles.
π― Usage Example: Declarative Component & Injection
import 'package:jetleaf_core/annotation.dart';
@Configuration()
class ApplicationConfig {
@Pod()
DatabaseDriver databaseDriver(@Value('\${db.url:localhost}') String url) {
return DatabaseDriver(url);
}
}
@Service()
class OrderService {
final DatabaseDriver driver;
@Autowired()
OrderService(this.driver);
@PostConstruct()
void init() {
print('OrderService initialized and ready.');
}
@PreDestroy()
void shutdown() {
print('OrderService shutting down.');
}
}
Classes
- AutoConfiguration
- Declares a class as a source of automatic configuration.
- Autowired
- Autowired annotation for dependency injection
- AutowiredIgnore
- An annotation used to mark a field as ignored by the dependency injection container.
- Cleanup
- Marks a method to be invoked after a pod is destroyed.
- Component
- Component annotation for generic Jetleaf components
- ComponentScan
- Annotation for Jetleaf component scanning.
- ComponentScanFilter
- Represents a filter definition for component scanning.
- Conditional
- An annotation that conditionally enables or disables Jetleaf-managed constructs such as Component, Pod, or configuration classes based on one or more declarative Condition evaluators.
- ConditionalOnAsset
- An annotation that conditionally activates a Component, Pod, or configuration class based on the presence of a specific asset in the application's resources.
- ConditionalOnClass
- An annotation that conditionally activates a Component, Pod, or configuration class only if specific classes are present in the Dart runtime or compilation environment.
- ConditionalOnDart
- An annotation that conditionally activates a Component, Pod, or configuration class based on the current Dart SDK version.
- ConditionalOnExpression
- An annotation that conditionally activates a Component, Pod, or configuration class based on the evaluation of a custom expression.
- ConditionalOnMissingClass
- An annotation that conditionally activates a Component, Pod, or configuration class only if certain classes are absent from the Dart runtime or compilation environment.
- ConditionalOnMissingPod
- An annotation that activates a component only when specific pods are absent from the ConditionalContext.
- ConditionalOnPod
- An annotation that conditionally activates a Component, Pod, or configuration class based on the presence of other pods within the current ConditionalContext.
- ConditionalOnProfile
- An annotation that conditionally activates a Component, Pod, or configuration class based on the currently active profiles in the ConditionalContext.
- ConditionalOnProperty
- An annotation that conditionally enables a Component, Pod, or configuration class based on the value(s) of one or more properties.
- Configuration
- Configuration annotation for configuration classes
- ConfigurationProperty
- Annotation used to bind externalized configuration properties from the Environment into a Dart object.
- DependsOn
- A Jetleaf annotation that declares explicit dependencies between pods.
- Description
- Provides a human-readable description of a class or method.
- EventListener
- Annotation to mark a method that should run when the application is listening to a specific type of ApplicationEvent.
-
EventType<
T extends ApplicationEvent> - π« Represents a typed application event associated with a specific package.
- Import
-
The
Importannotation in Jetleaf is used to import other configuration classes. -
KeyValueOf<
K, V> - KeyValueOf Annotation
- Lazy
- Indicates that a pod should be lazily initialized.
- Named
- Explicitly specifies a name for a Pod (Dependency Injection component) that overrides all other naming mechanisms in the Jetleaf framework.
- OnApplicationFailed
- Annotation to mark a method that should run when the application fails to start or refresh.
- OnApplicationReady
- Annotation to mark a method that should run when the application is fully ready to serve requests.
- OnApplicationStarted
- Annotation to mark a method that should run when the application has started, meaning the context is refreshed but the app is not yet fully ready.
- OnApplicationStarting
- Annotation to mark a method that should run when the application is starting, before the context refresh occurs.
- OnApplicationStopped
- Annotation to mark a method that should run when the application has fully stopped.
- OnApplicationStopping
- Annotation to mark a method that should run when the application is stopping.
- OnContextLoaded
- Annotation to mark a method that should run when the application context has been loaded, but before it is fully refreshed.
- OnContextPrepared
- Annotation to mark a method that should run when the application context has been prepared.
- OnEnvironmentPrepared
- Annotation to mark a method that should run when the application environment has been prepared, but before the context is loaded.
- Order
- Specifies the order of precedence for a class when processed by the framework or runtime system.
- Pod
- Marks a method as a pod provider, enabling it to participate in the dependency injection (DI) lifecycle of the application.
- PostConstruct
- Marks a method to be invoked after a pod has been fully constructed and its dependencies injected, but before it is made available for use in the context.
- PreConstruct
- Marks a method to be invoked before a pod has been fully constructed and its dependencies injected, but before it is made available for use in the context.
- PreDestroy
- Marks a method to be invoked before a pod is destroyed.
- Primary
- Primary annotation for marking a primary pod
- Profile
- Profile annotation for profile-specific pods
- Qualifier
- A Jetleaf annotation used to disambiguate injection targets when multiple candidate pods of the same type exist.
- Repository
- Marks a class as a Repository Component for data access and persistence.
- RequiredAll
- An annotation used for dependency injection that automatically injects all eligible fields into a class.
- Role
- Declares the design role of a class or method within a Jetleaf application.
- RunAfter
- A reflective annotation that declares that the annotated interceptor, filter, or handler should execute after one or more specified targets within the Jetleaf request processing pipeline.
- RunBefore
- A reflective annotation that declares that the annotated interceptor, filter, or handler should execute before one or more specified targets within the Jetleaf request processing pipeline.
- Scope
- Annotation that specifies the scope of a pod within the Jetleaf container.
- Service
- Service annotation for service layer components
-
TargetType<
T> - TargetType Annotation
- Value
- Value annotation for property injection
- WhenConditional
- The base class for all annotations that are eligible for conditional evaluation in the Jetleaf framework.
Enums
- FilterType
- Enumeration of supported filter types for component scanning.