ComponentScan class final

Annotation for Jetleaf component scanning.

@ComponentScan is used to instruct Jetleaf to scan specific packages or classes for annotated components (e.g., @Component, @Service, @Repository, @Controller) and automatically register them in the application context.

Key Features

  • Scans for annotated components in specified base packages or classes.
  • Allows inclusion or exclusion of classes using filters.
  • Supports default filters (e.g., built-in Jetleaf stereotypes).
  • Allows customizing name generation and scope resolution.

Usage

Developers apply this annotation at the configuration class level:

@ComponentScan(
  basePackages: ['com.example.myapp.services', 'com.example.myapp.repositories'],
  includeFilters: [
    ComponentScanFilter(
      type: FilterType.ANNOTATION,
      classes: [SpecialComponent],
    )
  ],
  excludeFilters: [
    ComponentScanFilter(
      type: FilterType.REGEX,
      pattern: '.*Internal.*'
    )
  ],
  useDefaultFilters: true,
)
class MyAppConfiguration {}

Notes

  • basePackages and basePackageClasses are mutually supportive: either specify string-based packages or anchor by class references.
  • Default filters include stereotypes like @Component, @Service, etc.
  • Advanced users can override scopeResolver and nameGenerator to plug in custom resolution or naming strategies.

Constructors

ComponentScan({List<String> basePackages = const [], List<ClassType<Object>> basePackageClasses = const [], List<ComponentScanFilter> includeFilters = const [], List<ComponentScanFilter> excludeFilters = const [], bool useDefaultFilters = true, ScopeMetadataResolver? scopeResolver, PodNameGenerator? nameGenerator})
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setter
basePackageClasses List<ClassType<Object>>
Base package classes (alternative to specifying string packages).
final
basePackages List<String>
Annotation for Jetleaf component scanning.
final
excludeFilters List<ComponentScanFilter>
Exclude filters for component scanning.
final
hashCode int
The hash code for this object.
no setterinherited
includeFilters List<ComponentScanFilter>
Include filters for component scanning.
final
nameGenerator → PodNameGenerator?
Custom name generator class.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scopeResolver → ScopeMetadataResolver?
Custom scope resolver class.
final
useDefaultFilters bool
Whether to use default filters (@Component, @Service, etc.).
final

Methods

equalizedProperties() List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
equals(Object other) bool
Checks whether the given object is logically equivalent to this annotation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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