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 SmartInitializingSingleton
                        

    Scans 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 = available Behavior: Scanner logs "scanning disabled", no package scanning occurs Use Case: Iteration 0 production - warnings work, scanning deferred to Iteration 1

    embabel.agent.platform.migration.warnings.enabled=false
    embabel.agent.platform.migration.scanning.enabled=false

    Bean State: scanningConfig = null, propertyWarner = null Behavior: Scanner logs "migration system completely disabled" Use Case: Production environments that want to disable all migration detection

    embabel.agent.platform.migration.warnings.enabled=true
    embabel.agent.platform.migration.scanning.enabled=true

    Bean State: scanningConfig = available, propertyWarner = available Behavior: Full package scanning with conditional annotation detection Use Case: Iteration 1+ production - complete migration detection system active

    embabel.agent.platform.migration.warnings.enabled=true
    # embabel.agent.platform.migration.scanning.enabled=false (default)

    Bean State: scanningConfig = null, propertyWarner = available Behavior: Property warnings work, but no @ConditionalOnProperty scanning Use Case: Users want property warnings but not bytecode scanning overhead

    The 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 initialized

    • Bean availability check → Verifies both scanning config and property warner are available

    • Package scanning → Finds classes in configured include packages (internal + external)

    • Annotation detection → Finds @ConditionalOnProperty and @ConfigurationProperties annotations on classes

    • Property extraction → Extracts property names from all annotation patterns:

    • Deprecation check → isDeprecatedProperty() returns true for all deprecated patterns

    • Warning generation → getRecommendedProperty() called with deprecated property name

    • Transformation → Explicit mapping lookup returns new property name

    • Warning issued → Logger warns about deprecated usage with recommended replacement property