-
Couldn't load subscription status.
- Fork 38.8k
Description
Chris Beams opened SPR-8171 and commented
This one is particularly sticky. aop:scoped-proxy is the one and only BeanDefinitionDecorator in existence, so there's no precedent for supporting such a beast with the FeatureSpecification model.
Nor necessarily should there be. Much like <context:spring-configured/>, this is likely a 'feature' that should take a different form when it comes to actual configuration. Just brainstorming, a @ScopedProxy annotation may be appropriate, perhaps at the parameter level on @Bean methods dependent on the object to be proxied:
@Bean
@Scope("session")
public UserPrefs userPrefs() {
return ...;
}
@Bean
public FooController fooController(@ScopedProxy UserPrefs userPrefs) {
}
Such an approach would resolve an often-mentioned claim that <aop:scoped-proxy/>) being declared on the scoped bean itself is the wrong location - that it should be inverted, such that the caller asks for the proxy only if needed. The exact approach above would suffer from the inability to call (inject) @Bean methods that accept parameters, but that's digressing a bit at this stage.
This issue is a sub-task of #12694