Skip to content

Investigate ScopedProxyBeanDefinitionDecorator (aop:scoped-proxy) [SPR-8171] #12822

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently applytype: taskA general task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions