ARTICLE AD BOX
I'm using `@ConditionalOnProperty` to select between two algorithm implementations at startup:
java @Bean @ConditionalOnProperty(name = "app.tree-strategy", havingValue = "collections") public TreeAlgorithmStrategy collectionsStrategy() { return new CollectionsTreeAlgorithm(); } @Bean @ConditionalOnProperty(name = "app.tree-strategy", havingValue = "custom", matchIfMissing = true) public TreeAlgorithmStrategy customStrategy() { return new CustomTreeAlgorithm(); }The selected bean gets injected into the service via constructor. It works, but the strategy is fixed at application startup — there's no way to switch it per-request.
Is this genuinely the GoF Strategy Pattern, or is it closer to a Factory/Configuration approach? And if I want per-request switching (e.g. ?algo=custom), should I drop @ConditionalOnProperty and inject a Map<String, TreeAlgorithmStrategy> instead?
