scan method
Scans the given base packages for annotated components
Parameters
basePackages
: List of package names to scan. Only classes in these packages will be considered for registration.
Behavior
- Recursively inspects subpackages of each base package.
- Filters classes according to annotations recognized by the
application context (e.g.,
@Component
,@Service
). - Does not automatically register the classes; scanning is for discovery.
Example
registry.scan(['com.example.service', 'com.example.repository']);
Notes
- Implementations may cache scan results for performance.
- Can be called multiple times to scan additional packages.
Implementation
@override
Future<void> scan(List<String> basePackages) async {
final podFactory = getPodFactory();
final scanner = ClassPathPodDefinitionScanner(
ConditionEvaluator(getEnvironment(), podFactory, Runtime),
podFactory,
getMainApplicationClass()
);
final definitions = <PodDefinition>[];
for (final basePackage in basePackages) {
definitions.addAll(await scanner.doScan(basePackage));
}
for (final definition in definitions) {
await registerDefinition(definition.name, definition);
}
return Future.value();
}