László Stahorszki opened SPR-16971 and commented

My suggestion would be some kind of a generic data container, whose scope can be parameterized. There could be some annotation, let's say

@ScopedContainer(scope = "some_scope")

that can be applied to fields, or setter methods.

A typical use-case would be, when I want to store some data in a bean of scope singleton, but I need the data List to be session scoped. I could then write a code:

@Component
public class MySingletonBean {

    @ScopedContainer(scope="session")
    private List<String> dataForSession;

    public List<String> getStrings() {
        return dataForSession;
    }
    ...
}

A work around for this feature is creating a generic bean for every scope and using proxy to inject, but I think we could all at some point make use of some feature like this.


No further details from SPR-16971

Comment From: snicoll

Thanks for the suggestion but @Scope is what you should be doing for this.