Class DeprecatedPropertyScanner
-
- All Implemented Interfaces:
-
org.springframework.beans.factory.SmartInitializingSingleton
@Component()@ConditionalOnProperty(name = {"embabel.agent.platform.migration.scanning.enabled"}, havingValue = "true", matchIfMissing = false) public final class DeprecatedPropertyScanner implements SmartInitializingSingletonScans for deprecated @ConditionalOnProperty and @ConfigurationProperties annotations during application startup.
This component analyzes classes in configured packages to detect usage of deprecated properties in @ConditionalOnProperty and @ConfigurationProperties annotations, issuing warnings through the SimpleDeprecatedConfigWarner. Uses SmartInitializingSingleton to ensure all beans are fully available before scanning.
This scanner works with conditionally loaded beans based on migration configuration:
# Default behavior - no scanning property set # embabel.agent.platform.migration.scanning.enabled=false (implicit) embabel.agent.platform.migration.warnings.enabled=true (default via matchIfMissing=true)Bean State:
scanningConfig = null,propertyWarner = availableBehavior: Scanner logs "scanning disabled", no package scanning occurs Use Case: Iteration 0 production - warnings work, scanning deferred to Iteration 1embabel.agent.platform.migration.warnings.enabled=false embabel.agent.platform.migration.scanning.enabled=falseBean State:
scanningConfig = null,propertyWarner = nullBehavior: Scanner logs "migration system completely disabled" Use Case: Production environments that want to disable all migration detectionembabel.agent.platform.migration.warnings.enabled=true embabel.agent.platform.migration.scanning.enabled=trueBean State:
scanningConfig = available,propertyWarner = availableBehavior: Full package scanning with conditional annotation detection Use Case: Iteration 1+ production - complete migration detection system activeembabel.agent.platform.migration.warnings.enabled=true # embabel.agent.platform.migration.scanning.enabled=false (default)Bean State:
scanningConfig = null,propertyWarner = availableBehavior: Property warnings work, but no @ConditionalOnProperty scanning Use Case: Users want property warnings but not bytecode scanning overheadThe migration rules are automatically invoked during Spring application startup whenever deprecated conditional properties are detected in scanned classes:
Example Scenarios:
@ConditionalOnProperty Detection:
Scenario A: Direct Property -
@ConditionalOnProperty("embabel.anthropic.max-attempts")Scenario B: Prefix + Name -
@ConditionalOnProperty(name = "max-attempts", prefix = "embabel.anthropic")Scenario C: Prefix Only -
@ConditionalOnProperty(prefix = "embabel.autonomy")
@ConfigurationProperties Detection:
Scenario D: Deprecated Prefix -
@ConfigurationProperties(prefix = "embabel.autonomy")Scenario E: Legacy Platform -
@ConfigurationProperties("embabel.agent-platform.ranking")
Spring startup →
afterSingletonsInstantiated()called after all beans initializedBean availability check → Verifies both scanning config and property warner are available
Package scanning → Finds classes in configured include packages (internal + external)
Annotation detection → Finds
@ConditionalOnPropertyand@ConfigurationPropertiesannotations on classesProperty extraction → Extracts property names from all annotation patterns:
Deprecation check →
isDeprecatedProperty()returnstruefor all deprecated patternsWarning generation →
getRecommendedProperty()called with deprecated property nameTransformation → Explicit mapping lookup returns new property name
Warning issued → Logger warns about deprecated usage with recommended replacement property
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classDeprecatedPropertyScanner.PropertyMigrationRuleData class representing a property migration rule with pattern matching.
Used for runtime extensibility when explicit mappings are insufficient. Most migrations use explicit mappings in exactPropertyMappings for safety.
PropertyMigrationRule( pattern = Pattern.compile("custom\\.company\\.(.+)"), replacement = "embabel.agent.custom.$1", description = "Custom company namespace migration" )
-
Constructor Summary
Constructors Constructor Description DeprecatedPropertyScanner(ObjectProvider<DeprecatedPropertyScanningConfig> scanningConfigProvider, ObjectProvider<SimpleDeprecatedConfigWarner> propertyWarnerProvider, Environment environment)
-
Method Summary
Modifier and Type Method Description final Unitinit()UnitafterSingletonsInstantiated()Performs conditional property scanning after all singletons are initialized. final UnitaddMigrationRule(DeprecatedPropertyScanner.PropertyMigrationRule rule)Adds a new property migration rule at runtime. final List<DeprecatedPropertyScanner.PropertyMigrationRule>getMigrationRules()Gets all currently configured migration rules. -
-
Constructor Detail
-
DeprecatedPropertyScanner
DeprecatedPropertyScanner(ObjectProvider<DeprecatedPropertyScanningConfig> scanningConfigProvider, ObjectProvider<SimpleDeprecatedConfigWarner> propertyWarnerProvider, Environment environment)
-
-
Method Detail
-
afterSingletonsInstantiated
Unit afterSingletonsInstantiated()
Performs conditional property scanning after all singletons are initialized.
-
addMigrationRule
final Unit addMigrationRule(DeprecatedPropertyScanner.PropertyMigrationRule rule)
Adds a new property migration rule at runtime. Useful for extending migration support without code changes.
-
getMigrationRules
final List<DeprecatedPropertyScanner.PropertyMigrationRule> getMigrationRules()
Gets all currently configured migration rules.
-
-
-
-